forms.py
1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
from django.forms import Form, ModelMultipleChoiceField, ModelChoiceField, \
BooleanField, CharField, Textarea
from dictionary.forms import QualifierField
from dictionary.models import Vocabulary, Variant, visible_vocabularies
class ExportForm(Form):
vocabs = ModelMultipleChoiceField(
queryset=Vocabulary.objects.all(), label=u'słowniki')
antivocabs = ModelMultipleChoiceField(
queryset=Vocabulary.objects.all(), label=u'antysłowniki',
required=False)
variant = ModelChoiceField(
queryset=Variant.objects.filter(type=Variant.TYPE_EXPORT),
label=u'wariant')
# refl = BooleanField(label=u'tagi z "refl"', required=False)
commonness = BooleanField(label=u'etykiety pospolitości', required=False,
initial=True)
dict_id = CharField(
label=u'identyfikator słownika',
help_text=u'Znaczniki %Y, %m i %d wstawiają odpowiednio aktualny '
u'rok, miesiąc i dzień')
copyright = CharField(widget=Textarea(attrs={'cols': 80, 'rows': 20}))
# excluding_qualifiers = QualifiersField(
# required=False, label=u'kwal. wykluczające')
def __init__(self, user, **kwargs):
super(ExportForm, self).__init__(**kwargs)
self.fields['vocabs'].queryset = visible_vocabularies(user)
self.fields['antivocabs'].queryset = visible_vocabularies(user)
self.fields['vocabs'].help_text = u''
self.fields['antivocabs'].help_text = u''
class MagicQualifierForm(Form):
qualifier = QualifierField(label=u'kwal. leksemu')
regex = CharField(label=u'wzorzec tagu', required=False)