class PrettyAdPictureForm(ModelForm): """ Pretty Ad Picture Form """ image = forms.ImageField(widget=forms.FileInput, required=False) def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_class = 'form-horizontal' self.helper.form_tag = False self.helper.layout = Layout( Div( #HTML(u'<button type="button" class="close" data-dismiss="alert">×</button> <h4>Photo n°{{ forloop.counter }}</h4>'), HTML(u'<h4>Photo n°{{ forloop.counter }}</h4>'), Layout( Div(Field('image', template="crispy_forms/no_label_field.html"), Field('title', placeholder="Description", template="crispy_forms/no_label_field.html"), Field('DELETE', template="crispy_forms/no_label_field.html"), css_class="pull-left")), css_class="alert alert-info clearfix", style="background-color:#fff;"), ) super(PrettyAdPictureForm, self).__init__(*args, **kwargs) if self.instance.image: html = "<div class='thumbnail'><img src='%s' width='350px' ></div>" % ( self.instance.image.url) self.helper.layout.fields[0].fields[1].fields.append( Div(HTML(html), css_class="pull-right")) class Meta: model = AdPicture
class PrettyAdPictureForm(ModelForm): """ Pretty Ad Picture Form """ image = forms.ImageField(widget=ImageThumbnailFileInput, required=False) class Meta: model = AdPicture
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 NewDiscussionForm(forms.Form): title = forms.CharField(label=_("title"), max_length=200, widget=forms.Textarea(attrs={ 'rows': '1', 'cols': '100' })) description = forms.CharField(label=_("description"), max_length=MAX_MESSAGE_INPUT_CHARS, widget=forms.Textarea(attrs={ 'rows': '6', 'cols': '100' })) location_desc = forms.CharField(label=u'כתובת', required=False, max_length=MAX_MESSAGE_INPUT_CHARS, widget=forms.Textarea(attrs={ 'rows': '1', 'cols': '100' })) tags = forms.CharField(required=False, label=u'תגיות מופרדות בפסיקים', widget=TagWidgetBig(attrs={ 'rows': 3, 'cols': 40 })) # parent_url = forms.URLInput(label=u"דף קשור", max_length=200, # widget=forms.Textarea( # attrs={'rows': '1', 'cols': '100'})) parent_url = forms.URLField( label=u'קישור לדף רלוונטי. לדוגמה http://hp.com', required=False, max_length=MAX_TEXT) parent_url_text = forms.CharField(label=u"שם הדף הקשור", required=False, max_length=MAX_TEXT, widget=forms.Textarea(attrs={ 'rows': '1', 'cols': '100' })) picture = forms.ImageField(required=False)
class UploadAvatarForm(Form): avatar_upload = forms.ImageField(label= _("Upload Image File"), help_text= _("Select image file on your computer you wish to use as forum avatar. You will be able to crop image after upload. Animations will be stripped."), error_messages={'invalid_image': _("Uploaded file is not correct image.")}) error_source = 'avatar_upload' def clean_avatar_upload(self): image = self.cleaned_data.get('avatar_upload', False) if image: if image._size > settings.upload_limit * 1024: if settings.upload_limit > 1024: limit = '%s Mb' % "{:10.2f}".format(float(settings.upload_limit / 1024.0)) else: limit = '%s Kb' % settings.upload_limit raise ValidationError(_("Avatar image cannot be larger than %(limit)s.") % {'limit': limit}) else: raise ValidationError(_("Couldn't read uploaded image")) return image
class EventForm(forms.Form): name = forms.CharField(widget=forms.TextInput( attrs={'placeholder': 'name your event'})) date = forms.DateTimeField(widget=forms.SplitDateTimeWidget) location = forms.CharField(widget=forms.TextInput( attrs={'placeholder': 'address'})) city = forms.CharField(widget=forms.TextInput( attrs={'placeholder': 'city'})) category = forms.ChoiceField(choices=CategoryOptions().CATEGORY_OPTIONS) description = forms.CharField(widget=forms.Textarea( attrs={'placeholder': 'don\'t be shy - tell us about it some more'})) budget = forms.IntegerField() max_people = forms.IntegerField() is_vegan = forms.BooleanField(required=False) is_kosher = forms.BooleanField(required=False) is_vegeterian = forms.BooleanField(required=False) rsvp = forms.ChoiceField(widget=forms.RadioSelect, choices=RsvpOptions().RSVP_OPTIONS) picture = forms.ImageField()
class UpdateTaskForm(forms.Form): status_description = forms.CharField( max_length=MAX_MESSAGE_INPUT_CHARS, widget=forms.Textarea(attrs={'rows': '3'})) result_picture = forms.ImageField(required=False)
class ImageNoteForm(forms.Form): image = forms.ImageField() point = forms.gis.PointField()