class UpdateLineForm(forms.Form): admission_condition_line = forms.IntegerField(widget=forms.HiddenInput()) section = forms.CharField(widget=forms.HiddenInput()) language = forms.CharField(widget=forms.HiddenInput()) diploma = forms.CharField(widget=forms.Textarea, required=False) conditions = RichTextFormField(**PARAMETERS_FOR_RICH_TEXT) access = forms.ChoiceField(choices=CONDITION_ADMISSION_ACCESSES, required=False) remarks = RichTextFormField(**PARAMETERS_FOR_RICH_TEXT)
class AddBlogForm(forms.Form): title = forms.CharField( max_length=100, widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Enter blog title', })) image = forms.ImageField(widget=forms.ClearableFileInput( attrs={ 'style': 'display:block;', })) description = RichTextFormField() def clean(self): title = self.cleaned_data.get('title') image = self.cleaned_data.get('image') description = self.cleaned_data.get('description') def deploy(self): title = self.cleaned_data.get('title') image = self.cleaned_data.get('image') description = self.cleaned_data.get('description') blog, created = store_model.FoodBlog.objects.get_or_create( title=title, description=description) blog.post_image = image blog.save() return blog
class EmailForm(forms.Form): Subject = forms.CharField(label='Subject', max_length=100, min_length=5, widget=forms.Textarea( attrs={ 'class': 'form-control', 'id': 'subject', 'placeholder': 'Type Something....' })) Message = RichTextFormField(widget=forms.TextInput( attrs={ 'class': 'form-control', 'id': 'message', 'placeholder': 'Type Something....' })) class Meta: fields = ('__all__') def __init__(self, *args, **kwargs): super(EmailForm, self).__init__(*args, **kwargs) # Call to ModelForm constructor self.fields['Subject'].widget.attrs['cols'] = 0 self.fields['Subject'].widget.attrs['rows'] = 2
class LogEditForm(forms.Form): logTime = forms.DateTimeField( label=u"日期时间", required=True, widget=TextInputWidget(attrs={'id': 'logTime'})) logStatus = forms.CharField( label=u"状态", max_length=50, required=True, widget=TextInputWidget(attrs={'id': 'logStatus'})) realName = forms.CharField( label=u"提交人", max_length=50, required=True, widget=TextInputWidget(attrs={'id': 'realName'})) logContent = RichTextFormField( label=u"日志正文", required=True, widget=TextAreaWidget(attrs={'id': 'logContent'})) formState = forms.CharField(max_length=50, widget=forms.HiddenInput) CHOICES = (( 'success', '成功', ), ( 'warning', '存在问题', ), ( 'danger', '失败', )) logGeneral = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES)
class UserCreationForm(forms.ModelForm): """A form for creating new users. Includes all the required fields, plus a repeated password.""" bio = RichTextFormField(label=u'О себе') password1 = forms.CharField(label='Password', widget=forms.PasswordInput) password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput) class Meta: model = User fields = SHARED_FORM_FIELDS widgets = {'country': CountrySelectWidget()} def clean_password2(self): # Check that the two password entries match password1 = self.cleaned_data.get("password1") password2 = self.cleaned_data.get("password2") if password1 and password2 and password1 != password2: raise forms.ValidationError("Passwords don't match") return password2 def signup(self, request, user): user.email = self.cleaned_data['email'] user.save() def save(self, commit=True): # Save the provided password in hashed format user = super(UserCreationForm, self).save(commit=False) user.set_password(self.cleaned_data["password1"]) if commit: user.save() return user
class TicketCreateForm(forms.ModelForm): comment = RichTextFormField() assignee = ProfileChoiceField() class Meta: model = Ticket fields = ['title', 'assignee', 'priority', 'project', 'state', 'customer', 'comment']
class ExperienceForm(forms.Form): company = forms.CharField(max_length=100, required=False) # job_location = forms.CharField(max_length=100, required=False) position = forms.CharField(max_length=100, required=False) start_date = forms.CharField(required=False) end_date = forms.CharField(required=False) description = RichTextFormField(required=False)
class NewTopicForm(forms.Form): title = forms.CharField(label='标题', max_length=100, widget=forms.TextInput( attrs={ 'id': 'title', 'placeholder': '请输入主题标题', 'class': 'mdl-textfield__input' }), error_messages={'required': '标题不能为空'}) subject = RichTextFormField(label='内容', max_length=4000, widget=forms.Textarea(attrs={ 'id': 'subject', 'placeholder': '请在此输入内容' }), required=False) def clean_title(self): title = self.cleaned_data.get('title') return title def clean_subject(self): subject = self.cleaned_data.get('subject') return subject
class Meta: model = Blog fields = ['title', 'context', 'image', 'music'] widgets = { 'title': forms.TextInput( attrs={ 'type': 'text', 'class': 'form-control', 'placeholder': 'Enter Blog Title' }), 'context': RichTextFormField(), 'image': forms.ClearableFileInput(attrs={ 'type': 'file', 'class': 'form-control' }), 'music': forms.ClearableFileInput(attrs={ 'type': 'file', 'class': 'form-control' }), }
class ActivityCraftPublishForm(forms.ModelForm): """草稿箱列表页发布活动表单""" logo = forms.ImageField(required=True, label="活动图标", help_text="请务必上传") file = forms.FileField(required=False, label="活动策划表", help_text="请上传.doc或.docx后缀的文档,若没有可以不上传") sponsor = forms.CharField(required=True, label="主办方", max_length=255) credit_type = forms.ChoiceField(choices=Activity.TYPE, label="学时类别", required=True) nums = forms.IntegerField(label="名额数量", help_text="若无名额限制,请不要填写该内容", required=False) place = forms.CharField(required=True, label="活动地点") time = forms.CharField(required=True, label="活动时间") deadline = forms.DateTimeField(required=True, label="活动截止日期", help_text="请选择大于现在的日期") desc = RichTextFormField(required=True, label="活动描述") join_type = forms.ChoiceField(choices=JOIN_TYPE, label="参与身份", required=True) score = forms.FloatField(required=True, label="获得学时") class Meta: exclude = ("user", "uid", "is_verify", "is_academy_verify", "is_school_verify", "to", "is_verifying", "reason", "to_school", "stop", "is_craft", "mark_score") model = Activity def clean_credit_type(self): # 学时类别选择了 未选择 ,验证失败 credit_type = self.cleaned_data['credit_type'] if credit_type == "n": raise forms.ValidationError("请选择学时类别") return credit_type def clean_deadline(self): # 验证活动截止时间 deadline = self.cleaned_data.get("deadline") if deadline: if datetime.now() > deadline: raise forms.ValidationError("活动截止时间设置错误") return deadline def clean(self): cd = self.cleaned_data desc, score, nums, logo= cd.get("desc"), cd.get("score"), cd.get("nums"), \ cd.get("logo") if not desc: raise forms.ValidationError("请填写活动描述!") if not (score and score > 0): raise forms.ValidationError("获得学时不得小于0!") if nums: if nums < 0: raise forms.ValidationError("名额数量不得小于0!") if not logo: raise forms.ValidationError("请上传活动图标!") return cd
class UpdateForm(forms.Form): forum = forms.ChoiceField(choices=[(choice.pk, choice.title) for choice in Forum.objects.all()]) title = forms.CharField(help_text='標題', max_length=50) body = RichTextFormField()
class Meta: model = Articulo fields = ['nombre', 'tipo', 'precio', 'cantidad', 'descripcion'] widgets = { 'nombre': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Nombre' }), 'tipo': forms.Select(attrs={'class': 'form-control'}), 'precio': forms.NumberInput(attrs={ 'class': 'form-control', 'placeholder': 'precio' }), 'cantidad': forms.NumberInput(attrs={ 'class': 'form-control', 'placeholder': 'cantidad' }), 'descripcion': RichTextFormField(), } labels = { 'nombre': '', 'tipo': '', 'precio': '', 'cantidad': '', 'descripcion': '', }
class UserForm(forms.ModelForm): uname = forms.CharField(max_length=20) password = forms.CharField(max_length=50) brief = RichTextFormField() class Meta: model = User fields = ['uname', 'password', 'brief']
class DocumentEditionForm(forms.ModelForm): """ Formulary designed to edit instances of documents """ body = RichTextFormField(label="", required=False) id = forms.CharField(widget=forms.HiddenInput()) class Meta: model = Document fields = ['body', 'id']
class Meta: model = HuckYou # fields = ('article', 'title', 'text', ) fields = ('article', ) widgets = { 'article': RichTextFormField(), 'file': CKEditorUploadingWidget(), }
class NewVenueAccountForm(VenueAccountForm): about = RichTextFormField(required=False) picture_src = forms.CharField(widget=AjaxCropWidget(), required=False) types = forms.ModelMultipleChoiceField( widget=forms.CheckboxSelectMultiple, queryset=VenueType.active_types.all(), required=False) phone = CAPhoneNumberField(required=False) fax = CAPhoneNumberField(required=False) about = RichTextFormField(required=False) tags = TagField(widget=VenueTagAutoSuggest(), required=False) social_links = forms.CharField(required=False, widget=forms.widgets.HiddenInput())
class CkEditorForm(forms.Form): title = forms.CharField(widget=TextInput(attrs={ 'placeholder': 'Title', 'maxlength': '80' })) content = RichTextFormField() location = forms.CharField(widget=TextInput(attrs={ 'placeholder': 'Location', 'maxlength': '30' }))
class FlatPageForm(forms.ModelForm): content = RichTextFormField() class Meta: model = FlatPage fields = '__all__' widgets = { 'template_name': forms.Select(choices=get_flatpage_template_choices()) }
class AdminArticleForm(forms.ModelForm): content = RichTextFormField( label=Article._meta.get_field('content').verbose_name) class Meta: model = Article fields = '__all__' widgets = { 'status': forms.RadioSelect, 'discussion_status': forms.RadioSelect }
class CommentForm(forms.ModelForm): state = forms.ModelChoiceField(State.objects.all(), widget=forms.RadioSelect, initial='resolved') body = RichTextFormField() def __init__(self, *args, **kwargs): super(CommentForm, self).__init__(*args, **kwargs) self.fields['body'].widget.attrs['placeholder'] = 'Enter your answer here' self.fields['body'].label = 'Answer body' class Meta: model = Comment fields = ('body', 'state', 'internal')
class MessageForm(forms.Form): name = forms.CharField( max_length=30, widget=forms.TextInput(attrs={'placeholder': '告诉我你叫什么名字吧.'})) email = forms.EmailField( max_length=30, widget=forms.TextInput(attrs={'placeholder': '方便找到你呀.'})) siteurl = forms.URLField( max_length=150, widget=forms.TextInput(attrs={'placeholder': '告诉我你的窝吧.'})) #body = forms.CharField(widget=forms.Textarea(attrs={'placeholder': '想说点什么呀.'})) body = RichTextFormField(config_name='content')
class UserProfileEditForm(forms.ModelForm): avatar = forms.ImageField(required=False) aboutme = RichTextFormField( required=False, external_plugin_resources=[( 'youtube', '/static/base/vendor/ckeditor_plugins/youtube/youtube/', 'plugin.js', )]) class Meta: model = User fields = ['email']
class TopicForm(forms.Form): """新主题表单""" title = forms.CharField(max_length=50, label=u'主题:') # username = forms.CharField(max_length=50,label=u'账号:') # ctgy = forms.CharField(max_length=50,label=u'所属板块:') # topic_ctgy = forms.CharField(max_length=50,label=u'主题类型:') content = RichTextFormField(label=u'内容:') def clean_content(self): icontent = self.cleaned_data['content'] nums = len(icontent) if nums < 2: raise forms.ValidationError("内容不能为空!") return icontent
class Meta: model = Blogs fields = ['blog_title', 'blog_description', 'blog_image'] widgets = { 'blog_title': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Blog Title' }), 'blog_description': RichTextFormField(), 'blog_image': forms.FileInput(attrs={'class': 'custom-file-input'}), }
class NoteForm(ModelForm): content = RichTextFormField() class Meta: model = Note fields = [ 'content', 'tags', 'reference', ] help_texts = { 'tags': 'Separate tags with ","', }
class Meta: model = Homework fields = [ 'hw_id', 'title', 'description', 'Lesson', 'file', 'answers', 'speaking' ] widgets = { 'description': RichTextFormField(), 'title': TextInput(attrs={ 'class': u'form-control', 'placeholder': u'Enter Title' }), }
class Meta: model = Post fields = ['title', 'description', 'date_added', 'tags', 'image', 'author', 'status'] widgets = { 'content': RichTextFormField()} labels = { "title": "Tytuł", "description": "Opis", "date_added": "Data dodania", "image": "Zdjęcie", "author": "Autor", "status": "Status", "tags": "Tagi", } help_texts = {'tags': "Rozdzielona przecinkami lista tagów", }
class PostForm(forms.ModelForm): title = forms.CharField( widget=forms.TextInput(attrs={'class': 'pass', 'placeholder': 'Начните ввод...'}) ) article_image = forms.ImageField( widget=forms.FileInput(attrs={'class': 'upload-image', 'id': 'upload-image', 'type': 'file', 'name': 'pic[]'}) ) body = RichTextFormField( widget=forms.Textarea(attrs={'class': 'bodyfield'}) ) class Meta: model = Post fields = ['title', 'article_image', 'body', 'tags', 'publicate_in']
class ContactForm(forms.Form): first_name = forms.CharField( label='', widget=forms.TextInput(attrs={ 'placeholder': 'First Name', 'class': 'form-control' })) last_name = forms.CharField( label='', widget=forms.TextInput(attrs={ 'placeholder': 'Last Name', 'class': 'form-control' })) email = forms.EmailField(label='', widget=forms.TextInput(attrs={ 'placeholder': 'E-Mail', 'class': 'form-control' })) subject = forms.CharField( label='', widget=forms.TextInput(attrs={ 'placeholder': 'Subject', 'class': 'form-control input_box' })) topic = forms.ChoiceField( choices=settings.FEED_BACK, label='', widget=forms.Select( attrs={'class': 'mdb-select md-form colorful-select dropdown-ins' })) message = RichTextFormField( label='', widget=CKEditorWidget(attrs={ 'placeholder': 'Message', 'class': 'form-control' })) captcha = ReCaptchaField(widget=ReCaptchaWidget(), label="") def __init__(self, *args, **kwargs): super(ContactForm, self).__init__(*args, **kwargs) self.fields['message'].widget.attrs['cols'] = 10 self.fields['message'].widget.attrs['rows'] = 20
class ReplyForm(forms.Form): post_id = forms.CharField(label='', widget=forms.TextInput(attrs={ 'id': 'post_id', 'type': '' }), required=True) reply = RichTextFormField(label='', max_length=4000, widget=forms.Textarea(attrs={ 'id': 'reply', 'placeholder': '请在此输入内容' }), required=True) def clean_reply(self): reply = self.cleaned_data.get('reply') return reply def clean_post_id(self): post_id = self.cleaned_data.get('post_id') return post_id