class SettingsForm(forms.ModelForm): start = forms.DateField(input_formats=('%d.%m.%Y',), error_messages=RU_ERRORS, widget=forms.DateInput(attrs={'class': 'input-small form-control'})) finish = forms.DateField(input_formats=('%d.%m.%Y',), error_messages=RU_ERRORS, widget=forms.DateInput(attrs={'class': 'input-small form-control'})) time = forms.TimeField(input_formats=('%H:%M',), error_messages=RU_ERRORS, widget=forms.TimeInput(attrs={'class': 'form-control', 'id': 'alert-time-display', 'value': '12:00'})) email = forms.EmailField(required=False, error_messages=RU_ERRORS, widget=forms.EmailInput(attrs={'class': 'form-control', 'placeholder': u'Укажите email для оповещений'})) phone = forms.RegexField(r'^\+79\d{9}$', '^\+79\d{9}$', required=False, error_messages=RU_ERRORS, widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': u'+79123456789'})) user_time = forms.CharField(widget=forms.HiddenInput()) class Meta: model = Alert widgets = { 'alert_email': forms.CheckboxInput(attrs={'id': 'email-alert'}), 'alert_sms': forms.CheckboxInput(attrs={'id': 'sms-alert'}), 'period': forms.Select(attrs={'class': 'form-control'}), } exclude = ['user', 'alert_server_time'] def clean(self): cleaned_data = super(SettingsForm, self).clean() if cleaned_data.get('alert_email') and cleaned_data.get('email') == '': raise forms.ValidationError(u'Введите email') if cleaned_data.get('alert_sms') and cleaned_data.get('phone') == '': raise forms.ValidationError(u'Введите номер телефона') return cleaned_data
class AdvancedSearchForm(SearchFormBase): search_before = forms.DateField( label=_("Posted Before"), help_text= _("Exclude posts made before specified date from search. Use YYYY-MM-DD format, for example 2013-11-23." ), required=False) search_after = forms.DateField( label=_("Posted After"), help_text= _("Exclude posts made after specified date from search. Use YYYY-MM-DD format, for example 2013-11-23." ), required=False)
class GradebookFilterForm(forms.Form): cohort = forms.ModelChoiceField( queryset=None, widget=forms.Select( attrs={'onchange': 'submit_filter_form(this.form)'}), required=False) marking_period = forms.ModelChoiceField( queryset=None, widget=forms.Select( attrs={'onchange': 'submit_filter_form(this.form)'}), required=False) benchmark = forms.ModelMultipleChoiceField( queryset=None, required=False, widget=forms.SelectMultiple(attrs={'class': 'simple_multiselect'})) category = forms.ModelChoiceField( queryset=None, widget=forms.Select( attrs={'onchange': 'submit_filter_form(this.form)'}), required=False) assignment_type = forms.ModelChoiceField( queryset=None, widget=forms.Select( attrs={'onchange': 'submit_filter_form(this.form)'}), required=False) name = forms.CharField(required=False) date_begin = forms.DateField( required=False, widget=forms.DateInput(attrs={'placeholder': 'Later than'}), validators=settings.DATE_VALIDATORS) date_end = forms.DateField( required=False, widget=forms.DateInput(attrs={'placeholder': 'Earlier than'}), validators=settings.DATE_VALIDATORS) def update_querysets(self, course_section): self.fields['cohort'].queryset = Cohort.objects.filter( Q(percoursesectioncohort=None, student__coursesection=course_section) | Q(percoursesectioncohort__coursesection=course_section) ).distinct().order_by('name') self.fields['marking_period'].queryset = MarkingPeriod.objects.filter( coursesection=course_section).distinct() self.fields['benchmark'].queryset = Benchmark.objects.filter( item__course_section=course_section).distinct() self.fields[ 'assignment_type'].queryset = AssignmentType.objects.filter( item__course_section=course_section).distinct() self.fields['category'].queryset = Category.objects.filter( item__course_section=course_section).distinct()
class GenerateStatisticsForm(Form): provider_model = forms.ChoiceField(label=_('Report Type'), help_text=_('Select statistics provider.')) date_start = forms.DateField(label=_('Time Period'), help_text=_('Enter start and end date for time period you want to take data from to use in graph.'), initial=tz.now() - timedelta(days=7)) date_end = forms.DateField(initial=tz.now() + timedelta(days=1)) stats_precision = forms.ChoiceField(label=_('Graph Precision'), choices=(('day', _('For each day')), ('week', _('For each week')), ('month', _('For each month')), ('year', _('For each year')))) def __init__(self, *args, **kwargs): provider_choices = kwargs.get('provider_choices') del kwargs['provider_choices'] super(GenerateStatisticsForm, self).__init__(*args, **kwargs) self.fields['provider_model'] = forms.ChoiceField(choices=provider_choices)
class TiposImpuestosForms(forms.ModelForm): class Meta: model = TiposImpuestos def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_id = 'id-tpimpuestos' self.helper.form_class = 'form-horizontal' self.helper.form_method = 'post' self.helper.form_action = 'submit_survey' self.helper.layout = Layout( Fieldset( Div('id', css_class="control-group hidden"), Div(Div(Field('epigrafe'), css_class=s6), Div(Field('descripcion', css_class="input-xxlarge"), css_class=s6), css_class=s12), Div(Div(Field('aplica', css_class="input-large"), css_class=s6), Div('valor', css_class=s6), css_class=s12), ), FormActions(Submit("Update", "Guardar"), Button("cancel", "Cancelar"))) return super(TiposImpuestosForms, self).__init__(*args, **kwargs) id = forms.IntegerField(required=False) fechaalta = forms.DateField(required=False)
class TrendtimeForm(forms.Form): """ Form to display bank transaction sums with a timeline. """ CHART_LINE = 'line' CHART_BAR = 'bar' CHART_RADAR = 'radar' CHART_TYPES = ( (CHART_LINE, ugettext_lazy('Line')), (CHART_BAR, ugettext_lazy('Bar')), (CHART_RADAR, ugettext_lazy('Radar')), ) chart = forms.ChoiceField(choices=CHART_TYPES, initial=CHART_LINE) GRANULARITY_CHOICES = ( (GRANULARITY_WEEK, ugettext_lazy('Week')), (GRANULARITY_MONTH, ugettext_lazy('Month')), ) granularity = forms.ChoiceField( choices=GRANULARITY_CHOICES, initial=GRANULARITY_MONTH, ) date = forms.DateField(required=True, widget=Datepicker()) reconciled = forms.NullBooleanField(required=False) def __init__(self, *args, **kwargs): super(TrendtimeForm, self).__init__(*args, **kwargs) self.fields['reconciled'].widget.choices[0] = ('1', _('Reconciled?')) self.fields['date'].initial = formats.date_format( datetime.date.today(), 'SHORT_DATE_FORMAT', )
class TestCycleForm(ccforms.AddEditForm): name = forms.CharField() description = forms.CharField(widget=ccforms.BareTextarea) product = ccforms.ModelChoiceField() start_date = forms.DateField() end_date = forms.DateField(required=False) team = ccforms.ModelMultipleChoiceField(required=False) no_edit_fields = ["product"] field_mapping = {"start_date": "startDate", "end_date": "endDate"} assign_later = ["team"] entryclass = TestCycle listclass = TestCycleList extra_creation_data = { "communityAccessAllowed": True, "communityAuthoringAllowed": True, }
class ReplyUpdateAfterDoubleEntryForm(forms.ModelForm): originally_collected_on = floppyforms.DateField( required=False, help_text="""Set this if the date that data were entered into the system is not the date that the participant originally provided the responses (e.g. when retyping paper data). If the participant has just provided this data now, then leave blank. """ ) class Meta: model = Reply fields = ['originally_collected_on']
class AllFieldsForm(forms.Form): boolean = forms.BooleanField() char = forms.CharField(max_length=50) choices = forms.ChoiceField(choices=ALPHA_CHOICES) date = forms.DateField() datetime = forms.DateTimeField() decimal = forms.DecimalField(decimal_places=2, max_digits=4) email = forms.EmailField() file_field = forms.FileField() file_path = forms.FilePathField(path='uploads/') float_field = forms.FloatField() generic_ip_address = forms.GenericIPAddressField() image = forms.ImageField() integer = forms.IntegerField() ip_address = forms.IPAddressField() multiple_choices = forms.MultipleChoiceField(choices=ALPHA_CHOICES) null_boolean = forms.NullBooleanField() regex_field = forms.RegexField(regex='^\w+$', js_regex='^[a-zA-Z]+$') slug = forms.SlugField() split_datetime = forms.SplitDateTimeField() time = forms.TimeField() typed_choices = forms.TypedChoiceField(choices=NUMERIC_CHOICES, coerce=int) typed_multiple_choices = forms.TypedMultipleChoiceField( choices=NUMERIC_CHOICES, coerce=int) url = forms.URLField() # GIS fields. if gis_forms: osm_point = gis.PointField( widget=mixin(gis.PointWidget, gis.BaseOsmWidget)) osm_multipoint = gis.MultiPointField( widget=mixin(gis.MultiPointWidget, gis.BaseOsmWidget)) osm_linestring = gis.LineStringField( widget=mixin(gis.LineStringWidget, gis.BaseOsmWidget)) osm_multilinestring = gis.MultiLineStringField( widget=mixin(gis.MultiLineStringWidget, gis.BaseOsmWidget)) osm_polygon = gis.PolygonField( widget=mixin(gis.PolygonWidget, gis.BaseOsmWidget)) osm_multipolygon = gis.MultiPolygonField( widget=mixin(gis.MultiPolygonWidget, gis.BaseOsmWidget)) gmap_point = gis.PointField( widget=mixin(gis.PointWidget, BaseGMapWidget)) gmap_multipoint = gis.MultiPointField( widget=mixin(gis.MultiPointWidget, BaseGMapWidget)) gmap_linestring = gis.LineStringField( widget=mixin(gis.LineStringWidget, BaseGMapWidget)) gmap_multilinestring = gis.MultiLineStringField( widget=mixin(gis.MultiLineStringWidget, BaseGMapWidget)) gmap_polygon = gis.PolygonField( widget=mixin(gis.PolygonWidget, BaseGMapWidget)) gmap_multipolygon = gis.MultiPolygonField( widget=mixin(gis.MultiPolygonWidget, BaseGMapWidget))
class TestRunForm(ccforms.AddEditForm): name = forms.CharField() description = forms.CharField(widget=ccforms.BareTextarea) test_cycle = ccforms.ModelChoiceField(choice_attrs=product_id_attrs) start_date = forms.DateField() end_date = forms.DateField(required=False) team = ccforms.ModelMultipleChoiceField(required=False) suites = ccforms.ModelMultipleChoiceField(required=False, choice_attrs=product_id_attrs) no_edit_fields = ["test_cycle"] field_mapping = { "test_cycle": "testCycle", "start_date": "startDate", "end_date": "endDate" } assign_later = ["team", "suites"] entryclass = TestRun listclass = TestRunList extra_creation_data = { "selfAssignLimit": 0, "selfAssignAllowed": True, } def field_hook(self): if self.instance: if self.instance.status.DRAFT: self.fields["caseupdate"] = forms.BooleanField(initial=False, required=False) else: # no modifying suites on an active test run del self.fields["suites"] def clean_caseupdate(self): if self.instance and self.cleaned_data.get("caseupdate"): for itc in self.instance.includedtestcases: itc.delete(invalidate_cache=[ "IncludedTestSuiteList", "TestRunIncludedTestCaseList" ])
class StudentBulkChangeForm(forms.Form): grad_date = forms.DateField(widget=adminwidgets.AdminDateWidget(), required=False, validators=settings.DATE_VALIDATORS) year = forms.ModelChoiceField(queryset=GradeLevel.objects.all(), required=False) individual_education_program = forms.NullBooleanField(required=False) cohort = forms.ModelChoiceField(queryset=Cohort.objects.all(), required=False) cohort_primary = forms.BooleanField(required=False) award = forms.ModelChoiceField(queryset=Award.objects.all(), required=False) award_marking_period = forms.ModelChoiceField( queryset=MarkingPeriod.objects.all(), required=False)
class DocumentosUploadForm(forms.ModelForm): class Meta: model = Documentos exclude = ('user','fechaalta') def __init__(self, *args, **kwargs): prefijo="documentos" self.helper = FormHelper() self.helper.form_tag = False self.helper.layout = Layout( TR( Field('id',css_class="control-group hidden",template=campo), Field('appcc_id',css_class="control-group hidden",template=campo), Field('manautctrl_id',css_class="control-group hidden", template=campo), Field('planautoctrl_id',css_class="control-group hidden",template=campo), Field('cabreg_id',css_class="control-group hidden",template=campo), Field('detreg_id',css_class="control-group hidden",template=campo), Field('registros_id',css_class="control-group hidden",template=campo), Field('cuadgest_id',css_class="control-group hidden",template=campo), Field('relentes_id',css_class="control-group hidden",template=campo), Field('gestincid_id',css_class="control-group hidden",template=campo), Field('cabanali_id',css_class="control-group hidden",template=campo), Field('cabinftec_id',css_class="control-group hidden",template=campo), #TD(Field('fecha',css_class="control-group hidden", template="form/field_date_table.html")), #TD(Field('denominacion',css_class="control-group", template="form/field.html")), #TD(Field('archivos',css_class="control-group", template="form/field.html")), #TD(Field('DELETE',template="form/field.html")), css_class="form-row inline %s" % prefijo ) ,#cambiar por el prefijo ) super(DocumentosUploadForm, self).__init__(*args, **kwargs) id = forms.IntegerField(required=False) appcc_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) manautctrl_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) planautoctrl_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) cabreg_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) detreg_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) registros_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) cuadgest_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) relentes_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) gestincid_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) cabanali_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) cabinftec_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) fecha = forms.DateField(initial=datetime.date.today,required=False) denominacion = forms.CharField(max_length="200",required=False) archivos = forms.FileField(label='Selecciona un archivo',required=False)
class UploadForm(forms.Form): id = forms.IntegerField(required=False) appcc_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) manautctrl_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) planautoctrl_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) cabreg_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) detreg_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) registros_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) cuadgest_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) relentes_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) gestincid_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) cabanali_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) cabinftec_id = forms.IntegerField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'})) fecha = forms.DateField(initial=datetime.date.today,required=False) denominacion = forms.CharField(max_length="200",required=False) archivos = forms.FileField(label='Selecciona un archivo',required=False) contenido = forms.CharField(required=False,widget=forms.TextInput(attrs= {'class':'hidden'}))
class IndividualAssignForm(forms.Form): date_suggested = forms.DateField( initial=datetime.date.today, required=True, widget=forms.DateInput(attrs={'data-js-widget': 'datepicker'})) time_suggested = forms.TimeField(initial='18:00')
class PostalReplyForm(forms.Form, PostalScanMixin): scan_help_text = mark_safe( _("Uploaded scans can be PDF, JPG or PNG. Please make sure to <strong>redact/black out all private information concerning you</strong>." )) date = forms.DateField( widget=forms.TextInput(attrs={ "class": "form-control", "placeholder": _('mm/dd/YYYY') }), label=_("Send Date"), help_text=_("Please give the date the reply was sent."), localize=True) sender = forms.CharField( label=_("Sender Name"), widget=forms.TextInput(attrs={ "class": "form-control", "placeholder": _("Sender Name") }), required=True) subject = forms.CharField( label=_("Subject"), required=False, max_length=230, widget=forms.TextInput(attrs={ "class": "form-control", "placeholder": _("Subject") })) text = forms.CharField( label=_("Letter"), widget=forms.Textarea( attrs={ "placeholder": _("Letter text you have received"), "class": "form-control" }), required=False, help_text= _("The text can be left empty, instead you can upload scanned documents." )) scan = forms.FileField(label=_("Scanned Letter"), required=False, help_text=scan_help_text) not_publishable = forms.BooleanField( label=_("You are not allowed to publish some received documents"), initial=False, required=False, help_text= _('If the reply explicitly states that you are not allowed to publish some of the documents (e.g. due to copyright), check this.' )) def clean_date(self): date = self.cleaned_data['date'] now = timezone.now().date() if date > now: raise forms.ValidationError( _("Your reply date is in the future, that is not possible.")) return date def clean(self): cleaned_data = self.cleaned_data text = cleaned_data.get("text") scan = cleaned_data.get("scan") if not (text or scan): raise forms.ValidationError( _("You need to provide either the letter text or a scanned document." )) return cleaned_data
class TimeBasedForm(forms.Form): """A generic template for time and school year based forms""" this_year = forms.BooleanField( required=False, initial=True, widget=forms.CheckboxInput( attrs={'onclick': 'toggle("id_this_year")'})) all_years = forms.BooleanField( required=False, widget=forms.CheckboxInput( attrs={'onclick': 'toggle("id_all_years")'})) date_begin = forms.DateField(widget=adminwidgets.AdminDateWidget(), required=False, validators=settings.DATE_VALIDATORS) date_end = forms.DateField(widget=adminwidgets.AdminDateWidget(), required=False, validators=settings.DATE_VALIDATORS) # CourseMeet.day_choice is a tuple of tuples; need the first value from each inner tuple for initial schedule_days = forms.MultipleChoiceField( required=False, choices=CourseMeet.day_choice, help_text= '''On applicable reports, only the selected days will be included. Hold down "Control", or "Command" on a Mac, to select more than one.''' ) marking_period = forms.ModelMultipleChoiceField( required=False, queryset=MarkingPeriod.objects.all()) include_deleted = forms.BooleanField(required=False) class Media: js = ('/static/js/time_actions.js', ) def clean(self): data = self.cleaned_data if not data.get("this_year") and not data.get("all_years"): if not data.get("date_begin") or not data.get("date_end"): if not data.get("marking_period"): raise forms.ValidationError( "You must select this year, all years, specify a date, or select a marking period." ) return data def get_dates(self): """ Returns begining and start dates in a tuple Pass it form.cleaned_data """ data = self.cleaned_data if data['this_year'] and not data['marking_period']: start = SchoolYear.objects.get(active_year=True).start_date # if they want a date in the future, let them specify it explicitly end = min(date.today(), SchoolYear.objects.get(active_year=True).end_date) elif not data['this_year'] and not data['all_years'] and not data[ 'marking_period']: start = data['date_begin'] end = data['date_end'] elif data['marking_period']: start = data['marking_period'].all().order_by( 'start_date')[0].start_date end = data['marking_period'].all().order_by( '-end_date')[0].end_date else: # all of time start = date(1980, 1, 1) end = date(2980, 1, 1) return (start, end)
class StudentGradeReportWriterForm(forms.Form): date = forms.DateField(widget=adminwidgets.AdminDateWidget(), initial=date.today, validators=settings.DATE_VALIDATORS) template = forms.ModelChoiceField(required=False, queryset=Template.objects.all()) upload_template = forms.FileField( required=False, help_text="You may choose a template or upload one here") include_deleted = forms.BooleanField(required=False) all_students = forms.BooleanField( required=False, widget=forms.CheckboxInput(attrs={'onclick': ''})) student = AutoCompleteSelectMultipleField('student', required=False) sort_by = forms.ChoiceField(choices=(('last_name', 'Student last name'), ('year', 'School year'), ('cohort', 'Primary Cohort')), initial=1) filter_year = forms.ModelMultipleChoiceField( required=False, queryset=GradeLevel.objects.all()) filter_cohort = forms.ModelMultipleChoiceField( required=False, queryset=Cohort.objects.all()) omit_substitutions = forms.BooleanField( required=False ) # benchmark_grade only; displayed conditionally in template def clean(self): data = super(StudentGradeReportWriterForm, self).clean() if not data.get('student') and not data.get('all_students'): raise forms.ValidationError( "You must either check \"all students\" or select a student") if not data.get('template') and not data.get('upload_template'): raise forms.ValidationError( "You must either select a template or upload one.") return data def get_students(self, options, worker=False): """ Returns all students based on criteria. data should be form.cleaned_data """ if worker: from ecwsp.work_study.models import StudentWorker students = StudentWorker.objects.all() else: students = Student.objects.all() # if selecting individual students, don't filter out deleted # why? Because it's unintuitive to pick one student, forgot about "include # deleted" and hit go to recieve a blank sheet. if not options['all_students']: students = students.filter(id__in=options['student']) elif not options['include_deleted']: students = students.filter(is_active=True) if options['student'].count == 1: data['student'] = options['student'][0] if options['sort_by'] == "year": students = students.order_by('year', 'last_name', 'first_name') elif options['sort_by'] == "hoomroom": pass if options['filter_year']: students = students.filter(year__in=options['filter_year']) if options['filter_cohort']: students = students.filter(cohorts__in=options['filter_cohort']) return students
class RatioForm(forms.Form): """ Form to display bank transaction sums grouped by tags. """ SINGLE_CREDIT = 'single_credit' SINGLE_DEBIT = 'single_debit' SUM_CREDIT = 'sum_credit' SUM_DEBIT = 'sum_debit' TYPES = ( (ugettext_lazy('Sum'), ( (SUM_DEBIT, ugettext_lazy('Expenses')), (SUM_CREDIT, ugettext_lazy('Income')), )), (ugettext_lazy('Single'), ( (SINGLE_DEBIT, ugettext_lazy('Expenses')), (SINGLE_CREDIT, ugettext_lazy('Income')), )), ) type = forms.ChoiceField(choices=TYPES, initial=SUM_DEBIT) CHART_DOUGHNUT = 'doughtnut' CHART_PIE = 'pie' CHART_POLAR = 'polar' CHART_TYPES = ( (CHART_DOUGHNUT, ugettext_lazy('Doughnut')), (CHART_PIE, ugettext_lazy('Pie')), (CHART_POLAR, ugettext_lazy('Polar area')), ) chart = forms.ChoiceField( choices=CHART_TYPES, initial=CHART_DOUGHNUT, required=False, ) date_start = forms.DateField( widget=Datepicker(attrs={ 'placeholder': ugettext_lazy('Date start'), }), ) date_end = forms.DateField( widget=Datepicker(attrs={ 'placeholder': ugettext_lazy('Date end'), }), ) reconciled = forms.NullBooleanField(required=False) tags = forms.ModelMultipleChoiceField( queryset=BankTransactionTag.objects.none(), required=False) sum_min = forms.DecimalField( max_digits=10, decimal_places=2, localize=True, required=False, widget=forms.NumberInput(attrs={ 'placeholder': _('Minimum sum'), }), ) sum_max = forms.DecimalField( max_digits=10, decimal_places=2, localize=True, required=False, widget=forms.NumberInput(attrs={ 'placeholder': _('Maximum sum'), }), ) def __init__(self, user, *args, **kwargs): super(RatioForm, self).__init__(*args, **kwargs) self.fields['tags'].queryset = ( BankTransactionTag.objects.get_user_tags_queryset(user)) self.fields['reconciled'].widget.choices[0] = ('1', _('Reconciled?')) def clean(self): cleaned_data = super(RatioForm, self).clean() date_start = cleaned_data.get('date_start') date_end = cleaned_data.get('date_end') if date_start and date_end and date_start > date_end: raise forms.ValidationError( _("Date start could not be greater than date end."), code='date_start_greater', ) sum_min = cleaned_data.get('sum_min', None) sum_max = cleaned_data.get('sum_max', None) if sum_min is not None and sum_max is not None and sum_min > sum_max: raise forms.ValidationError( _("Minimum sum could not be greater than maximum sum."), code='sum_min_greater', ) return cleaned_data
class DateForm(forms.Form): date = forms.DateField()
class SelectDateForm(forms.Form): dt = forms.DateField(widget=forms.SelectDateWidget(required=False))
class SelectDateForm(forms.Form): dt = forms.DateField(initial='%s-09-09' % today.year, widget=forms.SelectDateWidget)
class SelectDateForm(forms.Form): dt = forms.DateField(initial=today, widget=forms.SelectDateWidget)
class DateForm(forms.Form): date = forms.DateField(initial=datetime.date(2014, 1, 31))