예제 #1
0
class FXform(Form):

    currency_from = CharField(widget=CurrencyWidget(),
                              min_length=3,
                              max_length=3)
    del currency_from.widget.attrs['minlength']

    currency_to = CharField(widget=CurrencyWidget(),
                            min_length=3,
                            max_length=3)
    del currency_to.widget.attrs['minlength']

    rate_from = FloatField(widget=TextWidget(6),
                           min_value=.001,
                           localize=True,
                           initial=1)

    rate_to = FloatField(widget=TextWidget(6),
                         min_value=.001,
                         localize=True,
                         initial=1)

    date_from = DateField(widget=DateWidget(), required=False)

    date_to = DateField(widget=DateWidget(), required=False)

    def clean_currency_from(self):
        data = self.cleaned_data['currency_from'].upper()
        if not CURRENCY_RE.match(data):
            raise ValidationError('Invalid currency format')
        if data == self.data['currency_to'].upper():
            raise ValidationError('Currencies must be different')
        return data

    def clean_currency_to(self):
        data = self.cleaned_data['currency_to'].upper()
        if not CURRENCY_RE.match(data):
            raise ValidationError('Invalid currency format')
        if data == self.data['currency_from'].upper():
            raise ValidationError('Currencies must be different')
        return data

    def clean(self):
        cleaned_data = super().clean()
        date_from = cleaned_data.get('date_from', None)
        date_to = cleaned_data.get('date_to', None)
        if date_from and date_to and date_from > date_to:
            msg = 'Invalid interval'
            self._errors['date_from'] = self.error_class([msg])
            self._errors['date_to'] = self.error_class([msg])
            del cleaned_data['date_from']
            del cleaned_data['date_to']
        return cleaned_data
예제 #2
0
파일: forms.py 프로젝트: dimov-cz/legal
class MainForm(Form):

    beg_date = DateField(
        widget=DateWidget(today=True),
        label='Počátek',
        help_text='(nezapočítává se)',
    )

    end_date = DateField(
        widget=DateWidget(today=True),
        label='Konec',
        help_text='(započítává se)',
    )
예제 #3
0
class MainForm(Form):

    beg_date = DateField(widget=DateWidget(today=True),
                         label='Počátek',
                         validators=(MinValueValidator(MIN_DATE),
                                     MaxValueValidator(MAX_DATE)),
                         initial=date.today)

    dur = IntegerField(widget=TextWidget(4),
                       validators=(MinValueValidator(MIN_DUR),
                                   MaxValueValidator(MAX_DUR)),
                       required=False)

    unit = CharField(required=False)

    preset = ChoiceField(widget=RadioWidget(),
                         choices=PRESETS,
                         label='Délka',
                         initial='none')

    def clean_dur(self):
        data = self.cleaned_data['dur']
        if 'submit_set_beg_date' not in self.data and self.data[
                'preset'] == 'none' and data is None:
            raise ValidationError('Duration may not be empty')
        return data
예제 #4
0
class TransForm(Form):

    description = CharField(widget=TextWidget(60),
                            max_length=255,
                            required=False,
                            label='Popis')

    transaction_type = ChoiceField(widget=RadioWidget(),
                                   choices=TR_OPTS,
                                   label='Typ',
                                   initial='balance')

    date = DateField(widget=DateWidget(today=True), label='Datum')

    amount = DecimalField(widget=TextWidget(15),
                          max_digits=15,
                          decimal_places=2,
                          min_value=.0,
                          required=False,
                          label='Částka',
                          localize=True)

    repayment_preference = ChoiceField(widget=RadioWidget(),
                                       choices=REP_OPTS,
                                       required=False,
                                       label='Přednost',
                                       initial='interest')

    def clean_amount(self):
        data = self.cleaned_data['amount']
        if self.data['transaction_type'] != 'balance' and not data:
            raise ValidationError('Amount is required')
        return data
예제 #5
0
파일: forms.py 프로젝트: dimov-cz/legal
class MainForm(Form):

    curr = CurrencyField(czk=False, label='Měna', initial='EUR')

    fx_date = DateField(widget=DateWidget(today=True),
                        label='ke dni',
                        initial=date.today)

    basis = AmountField(widget=TextWidget(15),
                        min_value=.01,
                        label='Základ',
                        localize=True)

    mpi_date = DateField(widget=DateWidget(today=True),
                         label='Ke dni',
                         initial=date.today)
예제 #6
0
class MainForm(Form):

    basis = AmountField(widget=TextWidget(15),
                        min_value=1,
                        label='Základ',
                        localize=True)
    basis.rounding = 2

    curr = CurrencyField(label='Měna', czk=True, initial='CZK')

    today = date.today()
    fx_date = DateField(widget=DateWidget(),
                        required=False,
                        label='ke dni',
                        initial=date(today.year, today.month, 1))

    model = CharField(label='Úprava', initial='4')

    opt = ChoiceField(widget=RadioWidget(),
                      choices=OPTS,
                      label='Zvláštní případy',
                      initial='none')

    def clean_fx_date(self):
        data = self.cleaned_data['fx_date']
        if self.data['curr_0'] != 'CZK' and not data:
            raise ValidationError('Date is required')
        return data
예제 #7
0
class BalanceForm(Form):

    description = CharField(widget=TextWidget(50),
                            max_length=50,
                            required=False,
                            label='Popis')

    date = DateField(widget=DateWidget(today=True), label='Datum')
예제 #8
0
class CreditForm(Form):

    description = CharField(widget=TextWidget(50),
                            max_length=50,
                            required=False,
                            label='Popis')

    date = DateField(widget=DateWidget(), label='Datum')

    amount = AmountField(widget=TextWidget(15),
                         min_value=.01,
                         label='Částka',
                         localize=True)

    currency = CurrencyField(label='Měna', initial='CZK')
예제 #9
0
파일: forms.py 프로젝트: dimov-cz/legal
class MainForm(Form):

    beg_date = DateField(widget=DateWidget(), label='Nástup trestu')

    years = IntegerField(widget=TextWidget(4),
                         required=False,
                         min_value=0,
                         label='let')

    months = IntegerField(widget=TextWidget(4),
                          required=False,
                          min_value=0,
                          label='měsíců')

    days = IntegerField(widget=TextWidget(4),
                        required=False,
                        min_value=0,
                        label='dnů')

    def clean_years(self):
        data = self.cleaned_data['years']
        if not (data or self.data['months'] or self.data['days']):
            raise ValidationError('Missing duration')
        return data

    def clean_months(self):
        data = self.cleaned_data['months']
        if not (data or self.data['years'] or self.data['days']):
            raise ValidationError('Missing duration')
        return data

    def clean_days(self):
        data = self.cleaned_data['days']
        if not (data or self.data['years'] or self.data['months']):
            raise ValidationError('Missing duration')
        return data
예제 #10
0
class DebitForm(Form):

    description = CharField(widget=TextWidget(50),
                            max_length=50,
                            required=False,
                            label='Popis')

    fixed_amount = AmountField(widget=TextWidget(15),
                               min_value=.01,
                               required=False,
                               localize=True)

    fixed_currency = CurrencyField(label='v měně', initial='CZK')

    fixed_date = DateField(widget=DateWidget(),
                           required=False,
                           label='Splatnost')

    principal_debit = IntegerField(required=False, label='Z')

    principal_amount = AmountField(widget=TextWidget(15),
                                   min_value=.01,
                                   required=False,
                                   label='Částka',
                                   localize=True)

    principal_currency = CurrencyField(label='v měně', initial='CZK')

    date_from = DateField(widget=DateWidget(), required=False, label='Od')

    date_to = DateField(widget=DateWidget(), required=False, label='Do')

    model = ChoiceField(widget=RadioWidget(),
                        choices=DEB_OPTS,
                        initial='fixed')

    pa_rate = FloatField(widget=TextWidget(15),
                         min_value=0.0,
                         required=False,
                         localize=True)

    ydconv = CharField(label='Konvence', required=False)

    pm_rate = FloatField(widget=TextWidget(15),
                         min_value=0.0,
                         required=False,
                         localize=True)

    mdconv = CharField(label='Konvence', required=False)

    pd_rate = FloatField(widget=TextWidget(15),
                         min_value=0.0,
                         required=False,
                         localize=True)

    lock_fixed = BooleanField(widget=HiddenWidget(), required=False)

    def clean_fixed_amount(self):
        data = self.cleaned_data['fixed_amount']
        if self.data['model'] == 'fixed' and not data:
            raise ValidationError('Amount is required')
        return data

    def clean_fixed_currency(self):
        data = self.cleaned_data['fixed_currency']
        if self.data['model'] == 'fixed' and not data:
            raise ValidationError('Currency is required')
        return data

    def clean_fixed_date(self):
        data = self.cleaned_data['fixed_date']
        if self.data['model'] == 'fixed' and not data:
            raise ValidationError('Date is required')
        return data

    def clean_principal_amount(self):
        data = self.cleaned_data['principal_amount']
        if self.data['model'] != 'fixed' and self.cleaned_data[
                'principal_debit'] == 0 and not data:
            raise ValidationError('Principal amount is required')
        return data

    def clean_principal_currency(self):
        data = self.cleaned_data['principal_currency']
        if self.data['model'] != 'fixed' and self.cleaned_data[
                'principal_debit'] == 0 and not data:
            raise ValidationError('Principal currency is required')
        return data

    def clean_date_from(self):
        data = self.cleaned_data['date_from']
        if self.data['model'] != 'fixed' and self.cleaned_data[
                'principal_debit'] == 0 and not data:
            raise ValidationError('Starting date is required')
        return data

    def clean_pa_rate(self):
        data = self.cleaned_data['pa_rate']
        if self.data['model'] == 'per_annum' and not data:
            raise ValidationError('Interest rate is required')
        return data

    def clean_pm_rate(self):
        data = self.cleaned_data['pm_rate']
        if self.data['model'] == 'per_mensem' and not data:
            raise ValidationError('Interest rate is required')
        return data

    def clean_pd_rate(self):
        data = self.cleaned_data['pd_rate']
        if self.data['model'] == 'per_diem' and not data:
            raise ValidationError('Interest rate is required')
        return data

    def clean(self):
        cleaned_data = super().clean()
        date_from = cleaned_data.get('date_from', None)
        date_to = cleaned_data.get('date_to', None)
        if date_from and date_to and date_from > date_to:
            msg = 'Invalid interval'
            self._errors['date_from'] = self.error_class([msg])
            self._errors['date_to'] = self.error_class([msg])
            del cleaned_data['date_from']
            del cleaned_data['date_to']
        return cleaned_data
예제 #11
0
파일: forms.py 프로젝트: dimov-cz/legal
class MainForm(Form):

    date_from = DateField(widget=DateWidget(), required=False)

    date_to = DateField(widget=DateWidget(), required=False)

    court = CharField(widget=CourtWidget(supreme_administrative_court=True),
                      max_length=255,
                      required=False,
                      label='Soud')

    senate = IntegerField(widget=TextWidget(8),
                          min_value=0,
                          initial='',
                          required=False)

    register = CharField(widget=TextWidget(8),
                         max_length=30,
                         validators=(RegexValidator(regex=REGISTER_RE_STR), ),
                         initial='',
                         required=False)

    number = IntegerField(widget=TextWidget(8),
                          min_value=1,
                          initial='',
                          required=False)

    year = IntegerField(widget=TextWidget(8),
                        min_value=1,
                        initial='',
                        required=False)

    courtroom = CharField(max_length=255,
                          required=False,
                          label='Jednací síň',
                          initial='')

    judge = CharField(max_length=255,
                      required=False,
                      label='Řešitel',
                      initial='')

    party = CharField(widget=TextWidget(50),
                      required=False,
                      max_length=255,
                      label='Účastník řízení')

    party_opt = ChoiceField(widget=RadioWidget(),
                            choices=TEXT_OPTS,
                            initial='icontains')

    format = ChoiceField(widget=RadioWidget(),
                         choices=FORMAT_OPTS,
                         label='Výstupní formát',
                         initial='html')

    def clean(self):
        cleaned_data = super().clean()
        date_from = cleaned_data.get('date_from', None)
        date_to = cleaned_data.get('date_to', None)
        if date_from and date_to and date_from > date_to:
            msg = 'Invalid interval'
            self._errors['date_from'] = self.error_class([msg])
            self._errors['date_to'] = self.error_class([msg])
            del cleaned_data['date_from']
            del cleaned_data['date_to']
        return cleaned_data
예제 #12
0
class DebtorForm(Form):

    curr_year = date.today().year

    desc = CharField(widget=TextWidget(50), max_length=255, label='Popis')

    court = CharField(widget=CourtWidget(ins_courts=True),
                      max_length=255,
                      required=False,
                      label='Insolvenční soud',
                      initial='')

    name = CharField(widget=TextWidget(50),
                     max_length=MAX_LENGTH,
                     required=False,
                     label='Příjmení/název')

    name_opt = ChoiceField(widget=RadioWidget(),
                           choices=TEXT_OPTS,
                           label='Posice',
                           initial='icontains')

    first_name = CharField(widget=TextWidget(50),
                           max_length=MAX_LENGTH,
                           required=False,
                           label='Jméno')

    first_name_opt = ChoiceField(widget=RadioWidget(),
                                 choices=TEXT_OPTS,
                                 label='Posice',
                                 initial='icontains')

    genid = CharField(widget=TextWidget(20),
                      required=False,
                      max_length=9,
                      validators=(RegexValidator(regex=IC_RE_STR), ),
                      label='IČO')

    taxid = CharField(widget=TextWidget(20),
                      required=False,
                      max_length=14,
                      label='DIČ')

    birthid = CharField(widget=TextWidget(20),
                        required=False,
                        max_length=11,
                        validators=(RegexValidator(regex=RC_FULL_RE_STR), ),
                        label='Rodné číslo')

    date_birth = DateField(widget=DateWidget(),
                           required=False,
                           label='Datum narození')

    year_birth_from = IntegerField(widget=TextWidget(4),
                                   min_value=1900,
                                   max_value=curr_year,
                                   initial='',
                                   required=False)

    year_birth_to = IntegerField(widget=TextWidget(4),
                                 min_value=1900,
                                 max_value=curr_year,
                                 initial='',
                                 required=False)

    def clean(self):
        cleaned_data = super().clean()
        year_birth_from = cleaned_data.get('year_birth_from', None)
        year_birth_to = cleaned_data.get('year_birth_to', None)
        if year_birth_from and year_birth_to and year_birth_from > year_birth_to:
            msg = 'Invalid interval'
            self._errors['year_birth_from'] = self.error_class([msg])
            self._errors['year_birth_to'] = self.error_class([msg])
            del cleaned_data['year_birth_from']
            del cleaned_data['year_birth_to']
        return cleaned_data
예제 #13
0
class MainForm(Form):

    court = CharField(widget=CourtWidget(ins_courts=True),
                      max_length=255,
                      required=False,
                      label='Insolvenční soud',
                      initial='')

    senate = IntegerField(widget=TextWidget(8),
                          min_value=0,
                          initial='',
                          required=False)

    number = IntegerField(widget=TextWidget(8),
                          min_value=1,
                          initial='',
                          required=False)

    year = IntegerField(widget=TextWidget(8),
                        min_value=2008,
                        initial='',
                        required=False)

    date_first_from = DateField(widget=DateWidget(), required=False)

    date_first_to = DateField(widget=DateWidget(), required=False)

    date_last_from = DateField(widget=DateWidget(), required=False)

    date_last_to = DateField(widget=DateWidget(), required=False)

    name = CharField(widget=TextWidget(35),
                     required=False,
                     max_length=255,
                     label='Příjmení/název')

    name_opt = ChoiceField(widget=RadioWidget(),
                           choices=TEXT_OPTS,
                           initial='istartswith')

    first_name = CharField(widget=TextWidget(35),
                           required=False,
                           max_length=255,
                           label='Jméno')

    first_name_opt = ChoiceField(widget=RadioWidget(),
                                 choices=TEXT_OPTS,
                                 initial='istartswith')

    city = CharField(widget=TextWidget(35),
                     required=False,
                     max_length=255,
                     label='Obec')

    city_opt = ChoiceField(widget=RadioWidget(),
                           choices=TEXT_OPTS,
                           initial='istartswith')

    genid = CharField(widget=TextWidget(20),
                      required=False,
                      max_length=9,
                      validators=(RegexValidator(regex=IC_RE_STR), ),
                      label='IČO')

    taxid = CharField(widget=TextWidget(20),
                      required=False,
                      max_length=14,
                      label='DIČ')

    birthid = CharField(widget=TextWidget(20),
                        required=False,
                        max_length=11,
                        validators=(RegexValidator(regex=RC_FULL_RE_STR), ),
                        label='Rodné číslo')

    date_birth = DateField(widget=DateWidget(),
                           required=False,
                           label='Datum narození')

    year_birth_from = IntegerField(widget=TextWidget(4),
                                   min_value=1900,
                                   max_value=CURRYEAR,
                                   initial='',
                                   required=False)

    year_birth_to = IntegerField(widget=TextWidget(4),
                                 min_value=1900,
                                 max_value=CURRYEAR,
                                 initial='',
                                 required=False)

    role_debtor = InlineBooleanField(initial=True,
                                     required=False,
                                     label='dlužník')

    role_trustee = InlineBooleanField(required=False, label='správce')

    role_creditor = InlineBooleanField(required=False, label='věřitel')

    deleted = InlineBooleanField(required=False, label='včetně vyškrtnutých')

    creditors = InlineBooleanField(required=False,
                                   label='včetně seznamu věřitelů')

    format = ChoiceField(widget=RadioWidget(),
                         choices=FORMAT_OPTS,
                         label='Výstupní formát',
                         initial='html')

    def clean(self):
        cleaned_data = super().clean()
        date_first_from = cleaned_data.get('date_first_from', None)
        date_first_to = cleaned_data.get('date_first_to', None)
        if date_first_from and date_first_to and date_first_from > date_first_to:
            msg = 'Invalid interval'
            self._errors['date_first_from'] = self.error_class([msg])
            self._errors['date_first_to'] = self.error_class([msg])
            del cleaned_data['date_first_from']
            del cleaned_data['date_first_to']
        date_last_from = cleaned_data.get('date_last_from', None)
        date_last_to = cleaned_data.get('date_last_to', None)
        if date_last_from and date_last_to and date_last_from > date_last_to:
            msg = 'Invalid interval'
            self._errors['date_last_from'] = self.error_class([msg])
            self._errors['date_last_to'] = self.error_class([msg])
            del cleaned_data['date_last_from']
            del cleaned_data['date_last_to']
        year_birth_from = cleaned_data.get('year_birth_from', None)
        year_birth_to = cleaned_data.get('year_birth_to', None)
        if year_birth_from and year_birth_to and year_birth_from > year_birth_to:
            msg = 'Invalid interval'
            self._errors['year_birth_from'] = self.error_class([msg])
            self._errors['year_birth_to'] = self.error_class([msg])
            del cleaned_data['year_birth_from']
            del cleaned_data['year_birth_to']
        return cleaned_data
예제 #14
0
class MainForm(Form):

    date_posted_from = DateField(
        widget=DateWidget(),
        required=False)

    date_posted_to = DateField(
        widget=DateWidget(),
        required=False)

    publisher = CharField(
        widget=PublisherWidget(),
        max_length=255,
        required=False,
        label='Soud/státní zastupitelství')

    senate = IntegerField(
        widget=TextWidget(8),
        min_value=0,
        initial='',
        required=False)

    register = CharField(
        widget=TextWidget(8),
        max_length=30,
        initial='',
        required=False)

    number = IntegerField(
        widget=TextWidget(8),
        min_value=1,
        initial='',
        required=False)

    year = IntegerField(
        widget=TextWidget(8),
        min_value=1950,
        initial='',
        required=False)

    page = IntegerField(
        widget=TextWidget(8),
        min_value=1,
        initial='',
        required=False)

    agenda = CharField(
        max_length=255,
        required=False,
        label='Agenda',
        initial='')

    text = CharField(
        widget=TextWidget(60),
        required=False,
        max_length=255,
        label='V textu',
        validators=(SphinxQueryValidator(),))

    format = ChoiceField(
        widget=RadioWidget(),
        choices=FORMAT_OPTS,
        label='Výstupní formát',
        initial='html')

    def clean(self):
        cleaned_data = super().clean()
        date_posted_from = cleaned_data.get('date_posted_from', None)
        date_posted_to = cleaned_data.get('date_posted_to', None)
        if date_posted_from and date_posted_to and date_posted_from > date_posted_to:
            msg = 'Invalid interval'
            self._errors['date_posted_from'] = self.error_class([msg])
            self._errors['date_posted_to'] = self.error_class([msg])
            del cleaned_data['date_posted_from']
            del cleaned_data['date_posted_to']
        return cleaned_data