Commit 7ed30b474acb1dbd1fe58938b930e8dc943cbbb6
1 parent
c8942b45
poprawka do witka
Showing
3 changed files
with
15 additions
and
10 deletions
dictionary/ajax_lexeme_view.py
... | ... | @@ -5,11 +5,12 @@ from django.contrib.auth.models import User |
5 | 5 | from django.core.cache import cache |
6 | 6 | from django.db.models import Max |
7 | 7 | from dictionary.ajax_lexeme_slickgrid import LexemeQuery |
8 | +from dictionary.auto_derivatives import lexeme_derivatives | |
8 | 9 | from dictionary.models import Lexeme, LexemeInflectionPattern, PartOfSpeech, \ |
9 | 10 | Pattern, Vocabulary, Qualifier, prepare_table, ClassificationValue, \ |
10 | - CrossReference, get_root, InputLexeme, CrossReferenceType, \ | |
11 | + CrossReference, InputLexeme, CrossReferenceType, \ | |
11 | 12 | filter_visible, editable_vocabularies, visible_qualifiers, \ |
12 | - LexemeAttributeValue, Gender, LexemeAttribute, visible_vocabularies | |
13 | + LexemeAttributeValue, Gender, LexemeAttribute | |
13 | 14 | from dictionary.forms import LexemeEditForm, LIPEditForm, ClassificationForm, \ |
14 | 15 | CrossReferenceForm, ActionFieldForm, ACTION_FIELDS,\ |
15 | 16 | LexemeOpenAttributeForm, LexemeClosedAttributeForm, \ |
... | ... | @@ -184,14 +185,14 @@ def make_classification_forms(lexeme, vocabulary=None, part_of_speech=None, |
184 | 185 | part_of_speech = lexeme.part_of_speech |
185 | 186 | classifications = vocabulary.classifications.filter( |
186 | 187 | parts_of_speech=part_of_speech) |
187 | - classification_forms = [] | |
188 | + forms = [] | |
188 | 189 | for c in classifications: |
189 | 190 | values = lexeme.classification_values(c) |
190 | - classification_forms.append( | |
191 | + forms.append( | |
191 | 192 | ClassificationForm( |
192 | 193 | classification=c, values=values, prefix='cl' + str(c.pk), |
193 | 194 | editable=editable)) |
194 | - return classification_forms | |
195 | + return forms | |
195 | 196 | |
196 | 197 | |
197 | 198 | @render_ajax(template='classification_forms.html', method='get') |
... | ... | @@ -392,7 +393,11 @@ def update_lexeme(request, form_data): |
392 | 393 | id_list.insert(index, l.id) |
393 | 394 | key = query.cache_key() |
394 | 395 | cache.set(key, id_list) |
395 | - return {} | |
396 | + computed_derivatives = lexeme_derivatives(l) | |
397 | + crs = l.refs_to.values_list('to_lexeme__entry', 'type__symbol') | |
398 | + cr_set = set(tuple(cr) for cr in crs) | |
399 | + needed_derivatives = [d for d in computed_derivatives if d not in cr_set] | |
400 | + return {'derivatives': needed_derivatives} | |
396 | 401 | |
397 | 402 | |
398 | 403 | def update_lexeme_qualifiers(lexeme, user, form_dict, form_data): |
... | ... | @@ -533,8 +538,6 @@ def dynamic_action_fields(request, field_name): |
533 | 538 | def execute_group_actions(request, actions, filter): |
534 | 539 | if not request.user.has_perm('dictionary.change_lexeme'): |
535 | 540 | raise AjaxError('access denied') |
536 | - if isinstance(filter, unicode): | |
537 | - filters = json.loads(filter) | |
538 | 541 | query = LexemeQuery(filter=filter, sort_rules=[], user=request.user) |
539 | 542 | pk_list = query.get_id_list() |
540 | 543 | lexemes = Lexeme.objects.filter(pk__in=pk_list) |
... | ... |
dictionary/management/commands/import_witek.py
... | ... | @@ -50,7 +50,7 @@ def import_subst(elements, comment): |
50 | 50 | classification__name=u'pospolitość', label=commonness) |
51 | 51 | LexemeCV.objects.create(lexeme=l, classification_value=comm_value) |
52 | 52 | for i, ld in enumerate(lip_data): |
53 | - lip = LexemeInflectionPattern(lexeme=l, index=i, gender=gender) | |
53 | + lip = LexemeInflectionPattern(lexeme=l, index=i+1, gender=gender) | |
54 | 54 | if len(ld) == 1: |
55 | 55 | pattern = ld[0] |
56 | 56 | qualifier = None |
... | ... |
media/js/lexeme-edit.js
... | ... | @@ -362,7 +362,7 @@ $.extend(edit, { |
362 | 362 | form_data: form_data |
363 | 363 | }, |
364 | 364 | description: "Zapisanie zmian", |
365 | - callback: function () { | |
365 | + callback: function (data) { | |
366 | 366 | edit.hide_changed(); |
367 | 367 | var edit_id = edit.get_id(); |
368 | 368 | var grid_id = slickgrid.active_id(); |
... | ... | @@ -372,6 +372,8 @@ $.extend(edit, { |
372 | 372 | } else { |
373 | 373 | edit.load_content(edit_id); |
374 | 374 | } |
375 | + // TODO: zaproponować derywaty z data.derivatives | |
376 | + // nowe okienko dialogowe... | |
375 | 377 | }, |
376 | 378 | error_callback: function (xhr, status, error) { |
377 | 379 | common.error_alert(status + ': ' + error); |
... | ... |