Commit 3d61043b362e93e80762fa5278b9ebde70291c2b
1 parent
f63f546a
sprawdzanie zgodności wzoru z rodzajem przy zapisywaniu leksemu
--HG-- branch : beta
Showing
6 changed files
with
7 additions
and
40 deletions
common/static/js/common.js
1 | -/* global $dj, before_save, paginer, gettext, Cookies */ | |
1 | +/* global $dj, paginer, gettext, Cookies */ | |
2 | 2 | |
3 | 3 | $(function () { |
4 | 4 | "use strict"; |
... | ... | @@ -188,8 +188,6 @@ var common = (function() { |
188 | 188 | $.ajaxJSON = function (params) { |
189 | 189 | "use strict"; |
190 | 190 | var encoded_data = {}; |
191 | - if (params.save && !before_save()) | |
192 | - return false; | |
193 | 191 | if (params.async === undefined) |
194 | 192 | params.async = true; |
195 | 193 | $.each(params.data, function (key, value) { |
... | ... |
dictionary/ajax_lexeme_view.py
... | ... | @@ -585,17 +585,6 @@ def check_pos(request, pos_id, had_gender): |
585 | 585 | return {'answer': 'no'} |
586 | 586 | |
587 | 587 | |
588 | -@ajax(method='get') | |
589 | -def check_pattern(request, pattern_name, gender_id): | |
590 | - inflections = Inflection.objects.filter( | |
591 | - gender_id=gender_id, pattern__name=pattern_name) | |
592 | - inflections = inflections.exclude(lexeme__status__in=Lexeme.HIDDEN_STATUSES) | |
593 | - if inflections.exists(): | |
594 | - return {'answer': 'yes'} | |
595 | - else: | |
596 | - return {'answer': 'no'} | |
597 | - | |
598 | - | |
599 | 588 | START_ID = 1000000 |
600 | 589 | |
601 | 590 | |
... | ... |
dictionary/forms.py
... | ... | @@ -216,7 +216,8 @@ class InflectionEditForm(ModelForm): |
216 | 216 | self.fields['gender'].widget = HiddenInput() |
217 | 217 | self.fields['gender'].label = '' |
218 | 218 | instance = getattr(self, 'instance', None) |
219 | - self.fields['inflection_type'].initial = part_of_speech.inflection_type_id | |
219 | + self.fields['inflection_type'].initial = \ | |
220 | + part_of_speech.inflection_type_id | |
220 | 221 | self.fields['qualifiers'].set_qualifiers( |
221 | 222 | user, instance, types=[Qualifier.TYPE_STYLE, Qualifier.TYPE_FORM]) |
222 | 223 | if instance and instance.id: |
... | ... | @@ -238,6 +239,10 @@ class InflectionEditForm(ModelForm): |
238 | 239 | if pattern.type.inflection_type_id != it: |
239 | 240 | raise ValidationError( |
240 | 241 | _(u'The pattern doesn\'t match the part of speech')) |
242 | + genders = pattern.genders.all() | |
243 | + if genders and cleaned_data['gender'] not in genders: | |
244 | + raise ValidationError( | |
245 | + _(u'The pattern doesn\'t match the gender')) | |
241 | 246 | cleaned_data['pattern'] = pattern |
242 | 247 | return cleaned_data |
243 | 248 | |
... | ... |
dictionary/static/js/lexeme-edit.js
... | ... | @@ -410,7 +410,6 @@ $.extend(edit, { |
410 | 410 | var result = $.ajaxJSON({ |
411 | 411 | method: 'post', |
412 | 412 | url: $dj.ajax_update_lexeme, |
413 | - save: true, | |
414 | 413 | data: { |
415 | 414 | form_data: form_data |
416 | 415 | }, |
... | ... | @@ -679,28 +678,6 @@ function init_extra_attr_widgets() { |
679 | 678 | $('#extra-attributes').find('select[multiple]').multiSelect(); |
680 | 679 | } |
681 | 680 | |
682 | -function before_save() { | |
683 | - "use strict"; | |
684 | - // sprawdzić wzór z rodzajem | |
685 | - var ok = true; | |
686 | - $('.inflection-row').each(function () { | |
687 | - var gender = $(this).find('.gender').val(); | |
688 | - var pattern = $(this).find('.pattern').val(); | |
689 | - if (gender) { | |
690 | - var answer = $.ajaxJSON({ | |
691 | - method: 'get', | |
692 | - url: $dj.ajax_check_pattern, | |
693 | - data: {pattern_name: pattern, gender_id: gender}, | |
694 | - async: false | |
695 | - }).answer; | |
696 | - if (answer !== 'yes') | |
697 | - ok = false; | |
698 | - } | |
699 | - }); | |
700 | - return (ok || window.confirm( | |
701 | - gettext("The pattern doesn't match the gender — save anyway?"))); | |
702 | -} | |
703 | - | |
704 | 681 | var new_row_counter = 1; // potrzebne tylko dla niepowtarzalności idów |
705 | 682 | function get_new_row_html(id) { |
706 | 683 | "use strict"; |
... | ... |
dictionary/urls.py
... | ... | @@ -29,7 +29,6 @@ urlpatterns += patterns( |
29 | 29 | url(r'^ajax/new-cr-row/$', 'new_cross_reference_row'), |
30 | 30 | url(r'^ajax/delete-lexeme/$', 'delete_lexeme'), |
31 | 31 | url(r'^ajax/check-pos/$', 'check_pos'), |
32 | - url(r'^ajax/check-pattern/$', 'check_pattern'), | |
33 | 32 | url(r'^ajax/check-classifications/$', 'check_classifications'), |
34 | 33 | url(r'^ajax/create-lexeme/$', 'create_lexeme'), |
35 | 34 | url(r'^ajax/classification-forms/$', 'classification_forms'), |
... | ... |
dictionary/views.py
... | ... | @@ -143,7 +143,6 @@ def lexeme_view(request): |
143 | 143 | 'ajax_delete_lexeme': reverse('delete_lexeme'), |
144 | 144 | 'ajax_prompter_list': reverse('prompter_list'), |
145 | 145 | 'ajax_check_pos': reverse('check_pos'), |
146 | - 'ajax_check_pattern': reverse('check_pattern'), | |
147 | 146 | 'ajax_check_classifications': reverse('check_classifications'), |
148 | 147 | 'ajax_save_default_owner': reverse('save_default_owner'), |
149 | 148 | 'ajax_create_lexeme': reverse('create_lexeme'), |
... | ... |