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 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 TimeForm(forms.Form): date = forms.TimeField()
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')