forms.py 1.39 KB
# -*- coding: utf-8 -*-
from django.forms import Form, ModelMultipleChoiceField, ModelChoiceField, \
    BooleanField, CharField

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)
    # copyright = CharField(widget=Textarea(attrs={'cols': 80, 'rows': 40}))
    # 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)