Commit 29b4ed77cbc4961b2bf72c1e4d3d1453530e9476

Authored by janek37
1 parent 54a6b559

kwalifikatory formowe

dictionary/forms.py
... ... @@ -27,7 +27,7 @@ class QualifiersField(ModelMultipleChoiceField):
27 27 **kwargs)
28 28 self.to_field_name = None #?
29 29  
30   - def set_qualifiers(self, user, qualified=None, lexeme=None, type=None):
  30 + def set_qualifiers(self, user, qualified=None, lexeme=None, types=None):
31 31 # if qualified and qualified.id:
32 32 # if lexeme:
33 33 # vocabularies = lexeme.editable_vocabularies(user)
... ... @@ -36,8 +36,8 @@ class QualifiersField(ModelMultipleChoiceField):
36 36 # qualifiers = Qualifier.objects.filter(vocabulary__in=vocabularies)
37 37 # else:
38 38 qualifiers = editable_qualifiers(user)
39   - if type:
40   - qualifiers = qualifiers.filter(type=type)
  39 + if types:
  40 + qualifiers = qualifiers.filter(type__in=types)
41 41 if not qualifiers:
42 42 disable_field(self)
43 43 return
... ... @@ -104,9 +104,9 @@ class LexemeEditForm(ModelForm):
104 104 if other_editable_vocabs.count() == 0:
105 105 disable_field(self.fields['vocabularies'])
106 106 self.fields['style_qualifiers'].set_qualifiers(
107   - user, instance, type=Qualifier.TYPE_STYLE)
  107 + user, instance, types=[Qualifier.TYPE_STYLE])
108 108 self.fields['scope_qualifiers'].set_qualifiers(
109   - user, instance, type=Qualifier.TYPE_SCOPE)
  109 + user, instance, types=[Qualifier.TYPE_SCOPE])
110 110 if not editable and instance and instance.id:
111 111 for name, field in self.fields.iteritems():
112 112 if not name.startswith('qualifiers') and name != 'vocabularies':
... ... @@ -206,7 +206,8 @@ class LIPEditForm(ModelForm):
206 206 instance = getattr(self, 'instance', None)
207 207 self.fields['lexical_class'].initial = part_of_speech.lexical_class_id
208 208 self.fields['qualifiers'].set_qualifiers(
209   - user, instance, lexeme, type='styl')
  209 + user, instance, lexeme,
  210 + types=[Qualifier.TYPE_STYLE, Qualifier.TYPE_FORM])
210 211 if instance and instance.id:
211 212 self.fields['pattern_name'].initial = instance.pattern.name
212 213 if not editable:
... ... @@ -462,7 +463,8 @@ class QualifierForm(Form):
462 463 def __init__(self, user, qualified=None, editable=True,
463 464 **kwargs):
464 465 super(QualifierForm, self).__init__(**kwargs)
465   - self.fields['qualifiers'].set_qualifiers(user, qualified, type='styl')
  466 + self.fields['qualifiers'].set_qualifiers(
  467 + user, qualified, types=[Qualifier.TYPE_STYLE, Qualifier.TYPE_FORM])
466 468 if not editable:
467 469 disable_field(self.fields['qualifiers'])
468 470  
... ...
dictionary/models.py
... ... @@ -85,9 +85,11 @@ def get_exclusion_classes():
85 85 class Qualifier(Model):
86 86 TYPE_STYLE = 'styl'
87 87 TYPE_SCOPE = 'zakr'
  88 + TYPE_FORM = 'form'
88 89 TYPE_CHOICES = (
89 90 (TYPE_STYLE, 'stylistyczny'),
90 91 (TYPE_SCOPE, 'zakresowy'),
  92 + (TYPE_FORM, 'przy formach'),
91 93 )
92 94  
93 95 label = CharField(max_length=64, db_column='kwal', verbose_name=u'nazwa')
... ...