class BookForm(forms.ModelForm): choices = ((1, '1 Star'), (2, '2 Stars'), (3, '3 Stars'), (4, '4 Stars'), (5, '5 Stars')) reviews = forms.ChoiceField( choices=choices, widget=forms.RadioSelect(attrs={'class': 'form-inline'})) cover = CloudinaryJsFileField() preview_1 = CloudinaryJsFileField() preview_2 = CloudinaryJsFileField() preview_3 = CloudinaryJsFileField() class Meta: model = Book fields = ('__all__')
class LessonForm(forms.ModelForm): class Meta: model = Lesson fields = ('title', 'desc', 'cover', 'cost', 'syllabus', 'tags', 'tags', 'education_level', 'instructor') cover = CloudinaryJsFileField()
class ToyForm(forms.ModelForm): class Meta: model = Toy fields = ('title', 'brand', 'price', 'country', 'age', 'category', 'desc', 'features', 'cover') cover = CloudinaryJsFileField()
class LessonForm(forms.ModelForm): image = CloudinaryJsFileField(required=False) class Meta: model = Lesson fields = ('name', 'difficulty_level', 'description', 'average_class_size', 'price', 'image')
class WatchForm(forms.ModelForm): class Meta: model = Watch fields = ('watch_brand', 'watch_model', 'description', 'price', 'status', 'cover') cover = CloudinaryJsFileField()
class BookForm(forms.ModelForm): class Meta: model = Book exclude = ('owner', ) cover = CloudinaryJsFileField() def clean_ISBN(self): # extract out the data to be cleaned data = self.cleaned_data['ISBN'] # check if the ISBN already exists books = Book.objects.filter(ISBN=data) if books.count() > 0: raise ValidationError("The ISBN is not unique!") return data def clean_page_count(self): data = self.cleaned_data['page_count'] if data <= 0: raise ValidationError("Page count must be larger than 0") return data
class ListingForm(forms.ModelForm): class Meta: model = Listing fields = ['title', 'description', 'category', 'price', 'cover'] price = forms.IntegerField(label='Price (In Cents)') cover = CloudinaryJsFileField( label='Product Image (square img recommended)')
class ProductForm(forms.ModelForm): class Meta: model = Product fields = ('company', 'name', 'category', 'description', 'stock_qty', 'price', 'cover') cover = CloudinaryJsFileField()
class NewInvoice(forms.ModelForm): class Meta: model = Invoice fields = ( 'invoice', 'invoice_reference', 'car_plate', 'accounts_receivables', 'balance', 'accounts_payable', 'inv_date', 'cover' ) widgets = { 'inv_date': DateInput() } labels = { 'invoice': "Invoice for", 'invoice_reference': "Reference Number (if any)", 'car_plate': "Car plate (if applicable)", 'accounts_receivables': "Amount", 'balance': "Credit / Debit", 'accounts_payable': "Supplier", 'inv_date': "Invoice Date", } cover = CloudinaryJsFileField()
class DAServiceForm(forms.ModelForm): class Meta: model = DAService fields = ('item_name', 'price', 'short_desc', 'long_desc', 'stock', 'availability', 'discount', 'tag', 'category','cover') cover = CloudinaryJsFileField()
class Meta: model=follow profile=CloudinaryJsFileField() fields=[ 'profile', 'description' ]
class DirectUploadBackgroundPicBand(forms.Form): """ Form that allows client-side upload of a band background picture. """ background_pic = CloudinaryJsFileField(attrs={ 'id': "id_new_band_background_pic", 'accept': 'image/*' })
class DirectUploadProfilePic(forms.Form): """ Form to direcly upload a profile picture to cloudinary from client-side """ profile_picture = CloudinaryJsFileField(attrs={ 'id': "id_new_profile_pic", 'accept': 'image/*' })
class DirectUploadBackgroundPic(forms.Form): """ Form to direcly upload a background picture to cloudinary from client-side """ background_pic = CloudinaryJsFileField(attrs={ 'id': "id_new_background_pic", 'accept': 'image/*' })
class DirectUploadProfilePicBand(forms.Form): """ Form that allows client-side upload of a band profile picture. """ profile_picture = CloudinaryJsFileField(attrs={ 'id': "id_new_band_profile_pic", 'accept': 'image/*' })
def cloudinary_direct_upload_field(field_name="image", request=None): form = type("OnTheFlyForm", (Form,), {field_name : CloudinaryJsFileField() })() if request: cl_init_js_callbacks(form, request) value = form[field_name] if not PY3: value = unicode(value) return value
class DirectUploadBandPic(forms.Form): """ Form that allows client-side upload for a picture (no profile or background). """ band_pic = CloudinaryJsFileField(attrs={ 'id': "id_new_band_pic", 'accept': 'image/*' })
class ProductForm(forms.ModelForm) class Meta: model = Product # tuple are in round parenthesis # they are like lists in python # once we put something in a tuple, we cannot change the tuple anymore fields = ('name', 'selling_price', 'quantity', 'cover') cover = CloudinaryJsFileField()
class InstructorProfile(forms.ModelForm): class Meta: model = Instructor fields = ('instructor_full_name', 'instructor_preferred_name', 'cover', 'years_experience', 'instructor_mobile_number', 'qualifications') cover = CloudinaryJsFileField()
class Meta: model=People profile=CloudinaryJsFileField() fields=[ 'username', 'description', 'profile' ]
class DirectVideoUpload(forms.Form): """ Form that allows client-side upload of a video for a band. """ video = CloudinaryJsFileField(attrs={ 'id': "id_new_video", 'accept': "video/mp4,video/x-m4v,video/*" })
class FurnitureForm(forms.ModelForm): class Meta: model = Furniture fields = ('name', 'model', 'desc', 'quantity', 'category', 'tags', 'color', 'materials', 'height', 'breath', 'length', 'weight', 'cost', 'picture') picture = CloudinaryJsFileField()
class PostPhotoDirectForm(PostForm): image = CloudinaryJsFileField(attrs={'style': "margin-top: 30px"}, options={ 'tags': "directly_uploaded", 'crop': 'limit', 'width': 500, 'height': 500 }, required=False)
class ProductForm(forms.ModelForm): cover = CloudinaryJsFileField() # 'meta' defines which model ('product') this form references class Meta: model = Product fields = ('name', 'cost', 'unit', 'quantity', 'category', 'part_number', 'description', 'supplier', 'cover')
class BookForm(forms.ModelForm): class Meta: model = Book # tuple are in round parenthesis # they are like lists in Python # once we put something in a tuple, we cannot change the tuple anymore fields = ('title', 'desc', 'ISBN', 'pageCount', 'genre', 'category', 'tags', 'authors', 'owner', 'cost', 'cover') cover = CloudinaryJsFileField()
class DirectUploadPic(forms.Form): """ Form to directly upload a picture to cloudinary from the client-side. """ picture = CloudinaryJsFileField( attrs={ 'id': "id_new_picture", 'accept': 'image/*' }, label="", )
class CreateCollection(forms.ModelForm): photos = CloudinaryJsFileField(attrs={'multiple': 1}, required=False) class Meta: model = Collection fields = ("title", "description", "tags") widgets = { 'description': forms.Textarea(attrs={'cols': 40, 'rows': 5, 'class':'form-control', 'placeholder':'Tell the story of the collection'}), 'title': forms.TextInput(attrs={'class':'form-control', 'placeholder':'Title Your Collection', 'required':'True'}), 'tags': TagWidget(attrs={'class':'form-control', 'placeholder':'add, tags, with, commas', 'required':'True'}), }
class PhotoForm(forms.ModelForm): image = CloudinaryJsFileField(attrs={ 'style': "display:none", 'id': "id_photo-image" }, options={ 'tags': ["augeo", "photo"], 'eager': [{ 'crop': 'fit', 'width': 240 }] }) class Meta: model = Photo fields = ('image', )
class CloudinaryJsTestFileForm(forms.Form): js_file_field = CloudinaryJsFileField(attrs={'style': "margin-top: 30px"}, options={ 'tags': "directly_uploaded", 'crop': 'limit', 'width': 1000, 'height': 1000, 'eager': [{ 'crop': 'fill', 'width': 150, 'height': 100 }] })
class EditAbstractUserForm(forms.ModelForm): avatar = CloudinaryJsFileField(required=False) class Meta: fields = ("bio", "location", "tags") widgets = { 'bio': forms.Textarea(attrs={ 'cols': 40, 'rows': 10 }), 'tags': TagWidget( attrs={ 'class': 'form-control', 'placeholder': 'add, tags, with, commas', 'required': 'False' }), } def __init__(self, *args, **kwargs): super(EditAbstractUserForm, self).__init__(*args, **kwargs) for fields in self.fields.items(): fields[1].widget.attrs.update({'class': 'form-control'})