Commit 4187e23028585c1f3a6dd0dc54ab54a3c26f3102

Authored by janek37
1 parent e79a9ad6

wstęp do tabelek w stylu SGJP

dictionary/management/commands/import_data.py
... ... @@ -10,10 +10,9 @@ from dictionary.models import *
10 10  
11 11 DEFAULT_DATABASE = 'data/sgjp.db'
12 12  
13   -MINI_MODE = False # do debugowania
14   -MINI_LEXEME_COUNT = 5000
15   -MINI_LEXEME_QUERY = "SELECT %s FROM leksemy WHERE pos IN ('v', 'ger', 'pact', 'ppas') ORDER BY haslo LIMIT ?"
16   -#MINI_LEXEME_QUERY = "SELECT %s FROM leksemy l WHERE EXISTS (SELECT * FROM odmieniasie WHERE nr = l.nr AND charfl = 'm1') LIMIT ?"
  13 +MINI_MODE = True # do debugowania
  14 +MINI_LEXEME_COUNT = 1000
  15 +MINI_LEXEME_QUERY = "SELECT %s FROM leksemy ORDER BY haslo COLLATE NOCASE LIMIT ?"
17 16  
18 17 SQL_MODE = True
19 18  
... ... @@ -77,6 +76,13 @@ BASIC_FORM_LABELS_POS = {
77 76 'pred': '5',
78 77 }
79 78  
  79 +TRANSLATE_CLASS = {
  80 + 'h': 'header',
  81 + 'c': 'header-c',
  82 + 'b': 'blank',
  83 + 'd': 'data',
  84 +}
  85 +
80 86 class Command(BaseCommand):
81 87 args = '<input db filename>'
82 88 help = 'Imports initial data'
... ... @@ -143,7 +149,7 @@ class ImportData(object):
143 149 'natural join odmieniasie join leksemy on leksemy.nr = odmieniasie.nr'):
144 150 lcs[row[1]] = row[0]
145 151  
146   - for row in self.sqlite_cursor.execute('SELECT pos FROM klasygramatyczne'):
  152 + for row in self.sqlite_cursor.execute('SELECT * FROM klasygramatyczne'):
147 153 lc = lcs.get(row['pos'], OTHER)
148 154 yield PartOfSpeech(
149 155 symbol=row['pos'],
... ... @@ -511,24 +517,23 @@ class ImportData(object):
511 517  
512 518 def new_table_headers(self):
513 519 for row in self.sqlite_cursor.execute('SELECT * FROM naglowkiwierszy'):
514   - if row['styl'] != 'b' and row['nagl']:
515   - tts = TableTemplate.objects.filter(
516   - variant__id=row['wariant'], pattern_type__symbol=row['typr'],
517   - inflection_characteristic__symbol=row['charfl'],
518   - inflection_characteristic__part_of_speech__symbol=row['pos'])
519   - if tts:
520   - tt = tts.get()
521   - yield TableHeader(
522   - table_template=tt,
523   - row=row['row'],
524   - col=row['col'],
525   - rowspan=row['rowspan'],
526   - colspan=row['colspan'],
527   - label=row['nagl'],
528   - css_class=row['styl'],
529   - )
530   - else:
531   - raise Exception('Brak szablonu dla nagłówka: %s', dict(row))
  520 + tts = TableTemplate.objects.filter(
  521 + variant__id=row['wariant'], pattern_type__symbol=row['typr'],
  522 + inflection_characteristic__symbol=row['charfl'],
  523 + inflection_characteristic__part_of_speech__symbol=row['pos'])
  524 + if tts:
  525 + tt = tts.get()
  526 + yield TableHeader(
  527 + table_template=tt,
  528 + row=row['row'],
  529 + col=row['col'],
  530 + rowspan=row['rowspan'],
  531 + colspan=row['colspan'],
  532 + label=row['nagl'],
  533 + css_class=TRANSLATE_CLASS[row['styl']],
  534 + )
  535 + else:
  536 + raise Exception('Brak szablonu dla nagłówka: %s', dict(row))
532 537  
533 538 def delete_and_import(self):
534 539 models = (
... ...
dictionary/templates/inflection_table.html
1   -<table class='inflection-table'>
2   -<caption>{{ inflection_characteristic.entry }}</caption>
  1 +<table class='inflection-table scheme{{ inflection_characteristic.part_of_speech.color_scheme }}'>
  2 +<caption>{{ inflection_characteristic.symbol }}</caption>
3 3 {% for row in table %}
4 4 <tr>
5 5 {% for cell in row %}
... ...
dictionary/templates/inflection_tables.html
1   -{% for inflection_characteristic, table in tables %}
2   - <div class="inflection-table-container">
3   - {% include "inflection_table.html" %}
4   - </div>
5   -{% endfor %}
  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>
6 8 \ No newline at end of file
... ...
media/css/inflection_table.css
1 1 .inflection-table-container {
2 2 display: inline-block;
3 3 vertical-align: top;
  4 + overflow: auto;
4 5 }
5 6  
6 7 table.inflection-table {
7   - border-width: 0;
8   - /*border-style: solid;
9   - border-color: gray;*/
10   - border-collapse: collapse;
11   - background-color: white;
  8 + border-spacing: 5px;
12 9 margin: 15px;
13 10 }
14 11  
15 12 table.inflection-table td {
16   - padding: 15px;
17   - border: 1px solid gray;
18   - background-color: #d9e5ed;
  13 + padding: 5px;
19 14 text-align: left;
  15 + background-color: #eeeeee;
20 16 }
21 17  
22 18 table.inflection-table td span.qualifiers {
... ... @@ -24,21 +20,47 @@ table.inflection-table td span.qualifiers {
24 20 font-style: italic;
25 21 }
26 22  
27   -table.inflection-table td.header-c, table.inflection-table td.header {
28   - background-color: #d8d8d8;
  23 +table.scheme0 td {
  24 + background-color: #ebf3ff;
  25 +}
  26 +table.scheme0 td.header-c, table.scheme0 td.header {
  27 + background-color: #bfdbff;
29 28 }
30 29  
31   -table.inflection-table td.header-c {
32   - text-align: center;
  30 +table.scheme1 td {
  31 + background-color: #e2ffde;
  32 +}
  33 +table.scheme1 td.header-c, table.scheme1 td.header {
  34 + background-color: #b7ffae;
33 35 }
34 36  
35   -table.inflection-table td.header {
36   - text-align: left;
  37 +table.scheme2 td {
  38 + background-color: #ffebde;
  39 +}
  40 +table.scheme2 td.header-c, table.scheme2 td.header {
  41 + background-color: #ffdec7;
  42 +}
  43 +
  44 +table.scheme3 td {
  45 + background-color: #f4deff;
  46 +}
  47 +table.scheme3 td.header-c, table.scheme3 td.header {
  48 + background-color: #e8beff;
  49 +}
  50 +
  51 +table.scheme4 td {
  52 + background-color: #eeeeee;
  53 +}
  54 +table.scheme4 td.header-c, table.scheme4 td.header {
  55 + background-color: #aaaaaa;
  56 +}
  57 +
  58 +table.inflection-table td.header-c {
  59 + text-align: center;
37 60 }
38 61  
39 62 table.inflection-table td.blank {
40   - border-width: 0;
41   - background-color: white;
  63 + background-color: transparent;
42 64 }
43 65  
44 66 ul.form-list {
... ...