Commit 1ff39cb62b3cbc67d1eff1e5eb1ff748aeb43b1a
1 parent
4187e230
wstęp do nagłówka w stylu SGJP
Showing
5 changed files
with
116 additions
and
31 deletions
dictionary/ajax_lexeme_view.py
... | ... | @@ -24,7 +24,7 @@ def get_inflection_tables(request, variant, lexeme_id): |
24 | 24 | raise AjaxError('access denied') |
25 | 25 | qualifiers = visible_qualifiers(request.user) |
26 | 26 | tables = lexeme.inflection_tables(variant, qualifiers=qualifiers) |
27 | - return {'tables': tables} | |
27 | + return {'tables': tables, 'lexeme': lexeme} | |
28 | 28 | |
29 | 29 | @ajax(method='get', template='inflection_table.html') |
30 | 30 | def table_preview(request, lexeme_id, pattern, inflection_characteristic, |
... | ... |
dictionary/models.py
... | ... | @@ -449,7 +449,7 @@ class Lexeme(Model): |
449 | 449 | homonym_numbers = (Lexeme.objects.filter( |
450 | 450 | entry=self.entry, part_of_speech=self.part_of_speech) |
451 | 451 | .exclude(pk=self.pk)).values_list('homonym_number', flat=True) |
452 | - for i in range(1, len(homonym_numbers) + 2): | |
452 | + for i in xrange(1, len(homonym_numbers) + 2): | |
453 | 453 | if i not in homonym_numbers: |
454 | 454 | self.homonym_number = i |
455 | 455 | break |
... | ... | @@ -493,6 +493,14 @@ class Lexeme(Model): |
493 | 493 | self.save() |
494 | 494 | self.history_set.get(column_name='usuniety').delete() |
495 | 495 | |
496 | + def sgjp_info(self): | |
497 | + commonness = Classification.objects.get(name=u'pospolitość') | |
498 | + info = { | |
499 | + 'SJPDor': bool(self.vocabularies.filter(id='SJPDor')), | |
500 | + 'commonness': self.classification_values(commonness) | |
501 | + } | |
502 | + return info | |
503 | + | |
496 | 504 | def __unicode__(self): |
497 | 505 | return '%s (%s)' % (self.entry, self.part_of_speech.symbol) |
498 | 506 | |
... | ... | @@ -607,7 +615,7 @@ class LexemeInflectionPattern(Model): |
607 | 615 | headers = tt.tableheader_set.all() |
608 | 616 | rows = set() |
609 | 617 | last_col = 0 |
610 | - cells = [cell for cell in cells if self.forms(cell)] | |
618 | + #cells = [cell for cell in cells if self.forms(cell)] | |
611 | 619 | for cell in cells: |
612 | 620 | rows.add(cell.tablecell.row) |
613 | 621 | col = cell.tablecell.col + cell.tablecell.colspan - 1 |
... | ... | @@ -619,10 +627,10 @@ class LexemeInflectionPattern(Model): |
619 | 627 | if col > last_col: |
620 | 628 | last_col = col |
621 | 629 | table = [[{'type': 'empty'} |
622 | - for i in range(last_col)] for j in range(len(rows))] | |
630 | + for i in xrange(last_col)] for j in xrange(len(rows))] | |
623 | 631 | rows = sorted(rows) |
624 | 632 | # słownik: nr rzędu w bazie -> rzeczywisty numer rzędu |
625 | - row_translate = dict(zip(rows, range(len(rows)))) | |
633 | + row_translate = dict(zip(rows, xrange(len(rows)))) | |
626 | 634 | for cell in cells: |
627 | 635 | x = cell.tablecell.col - 1 |
628 | 636 | y = row_translate[cell.tablecell.row] |
... | ... | @@ -637,8 +645,8 @@ class LexemeInflectionPattern(Model): |
637 | 645 | 'rowspan': cell.tablecell.rowspan, |
638 | 646 | 'colspan': cell.tablecell.colspan, |
639 | 647 | } |
640 | - for i in range(cell.tablecell.colspan): | |
641 | - for j in range(cell.tablecell.rowspan): | |
648 | + for i in xrange(cell.tablecell.colspan): | |
649 | + for j in xrange(cell.tablecell.rowspan): | |
642 | 650 | if (i, j) != (0, 0): |
643 | 651 | assert table[y+j][x+i]['type'] == 'empty' |
644 | 652 | table[y+j][x+i]['type'] = 'span' |
... | ... | @@ -657,8 +665,8 @@ class LexemeInflectionPattern(Model): |
657 | 665 | 'rowspan': header.rowspan, |
658 | 666 | 'colspan': header.colspan, |
659 | 667 | } |
660 | - for i in range(header.colspan): | |
661 | - for j in range(header.rowspan): | |
668 | + for i in xrange(header.colspan): | |
669 | + for j in xrange(header.rowspan): | |
662 | 670 | if (i, j) != (0, 0): |
663 | 671 | assert table[y+j][x+i]['type'] == 'empty' |
664 | 672 | table[y+j][x+i]['type'] = 'span' |
... | ... |
dictionary/templates/inflection_table.html
1 | -<table class='inflection-table scheme{{ inflection_characteristic.part_of_speech.color_scheme }}'> | |
2 | -<caption>{{ inflection_characteristic.symbol }}</caption> | |
1 | +<table class='inflection-table'> | |
2 | +{% if tables|length > 1 %} | |
3 | + <caption>{{ inflection_characteristic.symbol }}</caption> | |
4 | +{% endif %} | |
3 | 5 | {% for row in table %} |
4 | 6 | <tr> |
5 | 7 | {% for cell in row %} |
6 | 8 | {% if cell.type != 'span' %} |
7 | 9 | {% if cell.type == 'empty' %} |
8 | - <td class='blank' ></td> | |
10 | + <td class='empty' ></td> | |
9 | 11 | {% else %} |
10 | 12 | {% if cell.type == 'forms' %} |
11 | 13 | <td rowspan="{{ cell.rowspan }}" colspan="{{ cell.colspan }}"> |
... | ... |
dictionary/templates/inflection_tables.html
1 | -<div class="inflection-tables"> | |
2 | - {% for inflection_characteristic, table in tables %} | |
3 | - <div class="inflection-table-container"> | |
4 | - {% include "inflection_table.html" %} | |
5 | - </div> | |
6 | - {% endfor %} | |
7 | -</div> | |
8 | 1 | \ No newline at end of file |
2 | +<span class="entry-article scheme{{ lexeme.part_of_speech.color_scheme }}"> | |
3 | + <h1> | |
4 | + {{ lexeme.entry }} | |
5 | + {% if lexeme.pronunciation %} | |
6 | + <span class="pronunciation">[{{ lexeme.pronunciation|safe }}]</span> | |
7 | + {% endif %} | |
8 | + {% if lexeme.gloss %} | |
9 | + <span class="gloss">‘{{ lexeme.gloss|safe }}‘</span> | |
10 | + {% endif %} | |
11 | + </h1> | |
12 | + <p> | |
13 | + {{ lexeme.part_of_speech.full_name }} | |
14 | + {# kwalifikatory leksemu #} | |
15 | + {# nota #} | |
16 | + {# SJPDor #} | |
17 | + </p> | |
18 | + <p> | |
19 | + {{ lexeme.lip_data.inflection_characteristics }} | |
20 | + {% if tables|length == 1 %} | |
21 | + {{ lexeme.lip_data.patterns }} | |
22 | + {% endif %} | |
23 | + </p> | |
24 | + <p class="separator"></p> | |
25 | + <div class="inflection-tables"> | |
26 | + {% for inflection_characteristic, table in tables %} | |
27 | + <div class="inflection-table-container"> | |
28 | + {% include "inflection_table.html" %} | |
29 | + </div> | |
30 | + {% endfor %} | |
31 | + </div> | |
32 | +</span> | |
9 | 33 | \ No newline at end of file |
... | ... |
media/css/inflection_table.css
1 | +span.entry-article h1 { | |
2 | + padding: 5px; | |
3 | + font-size: large; | |
4 | +} | |
5 | + | |
6 | +span.pronunciation { | |
7 | + font-weight: normal; | |
8 | + font-size: small; | |
9 | +} | |
10 | + | |
11 | +span.gloss { | |
12 | + font-weight: normal; | |
13 | + font-size: small; | |
14 | + font-style: italic; | |
15 | +} | |
16 | + | |
17 | +span.entry-article caption { | |
18 | + padding: 3px; | |
19 | + text-align: left; | |
20 | +} | |
21 | + | |
22 | +span.entry-article .separator { | |
23 | + height: 5px; | |
24 | +} | |
25 | + | |
26 | +.inflection-tables { | |
27 | + overflow: auto; | |
28 | + letter-spacing: 20px; | |
29 | + text-align: center; | |
30 | + margin-top: 20px; | |
31 | +} | |
32 | + | |
1 | 33 | .inflection-table-container { |
2 | 34 | display: inline-block; |
35 | + letter-spacing: normal; | |
3 | 36 | vertical-align: top; |
4 | - overflow: auto; | |
5 | 37 | } |
6 | 38 | |
7 | 39 | table.inflection-table { |
8 | 40 | border-spacing: 5px; |
9 | - margin: 15px; | |
10 | 41 | } |
11 | 42 | |
12 | 43 | table.inflection-table td { |
... | ... | @@ -20,38 +51,58 @@ table.inflection-table td span.qualifiers { |
20 | 51 | font-style: italic; |
21 | 52 | } |
22 | 53 | |
23 | -table.scheme0 td { | |
54 | +.scheme0 .separator, | |
55 | +.scheme0 table.inflection-table td { | |
24 | 56 | background-color: #ebf3ff; |
25 | 57 | } |
26 | -table.scheme0 td.header-c, table.scheme0 td.header { | |
58 | +.scheme0 h1, | |
59 | +.scheme0 caption, | |
60 | +.scheme0 table.inflection-table td.header-c, | |
61 | +.scheme0 table.inflection-table td.header { | |
27 | 62 | background-color: #bfdbff; |
28 | 63 | } |
29 | 64 | |
30 | -table.scheme1 td { | |
65 | +.scheme1 .separator, | |
66 | +.scheme1 table.inflection-table td { | |
31 | 67 | background-color: #e2ffde; |
32 | 68 | } |
33 | -table.scheme1 td.header-c, table.scheme1 td.header { | |
69 | +.scheme1 h1, | |
70 | +.scheme1 caption, | |
71 | +.scheme1 table.inflection-table td.header-c, | |
72 | +.scheme1 table.inflection-table td.header { | |
34 | 73 | background-color: #b7ffae; |
35 | 74 | } |
36 | 75 | |
37 | -table.scheme2 td { | |
76 | +.scheme2 .separator, | |
77 | +.scheme2 table.inflection-table td { | |
38 | 78 | background-color: #ffebde; |
39 | 79 | } |
40 | -table.scheme2 td.header-c, table.scheme2 td.header { | |
80 | +.scheme2 h1, | |
81 | +.scheme2 caption, | |
82 | +.scheme2 table.inflection-table td.header-c, | |
83 | +.scheme2 table.inflection-table td.header { | |
41 | 84 | background-color: #ffdec7; |
42 | 85 | } |
43 | 86 | |
44 | -table.scheme3 td { | |
87 | +.scheme3 .separator, | |
88 | +.scheme3 table.inflection-table td { | |
45 | 89 | background-color: #f4deff; |
46 | 90 | } |
47 | -table.scheme3 td.header-c, table.scheme3 td.header { | |
91 | +.scheme3 h1, | |
92 | +.scheme3 caption, | |
93 | +.scheme3 table.inflection-table td.header-c, | |
94 | +.scheme3 table.inflection-table td.header { | |
48 | 95 | background-color: #e8beff; |
49 | 96 | } |
50 | 97 | |
51 | -table.scheme4 td { | |
98 | +.scheme4 .separator, | |
99 | +.scheme4 table.inflection-table td { | |
52 | 100 | background-color: #eeeeee; |
53 | 101 | } |
54 | -table.scheme4 td.header-c, table.scheme4 td.header { | |
102 | +.scheme4 h1, | |
103 | +.scheme4 caption, | |
104 | +.scheme4 table.inflection-table td.header-c, | |
105 | +.scheme4 table.inflection-table td.header { | |
55 | 106 | background-color: #aaaaaa; |
56 | 107 | } |
57 | 108 | |
... | ... |