class ContentForm(forms.Form): title = forms.CharField( required=True, max_length=64, widget=forms.TextInput(attrs={'class': 'input-text'}), error_messages={'required': '内容名不能为空'}) sort = forms.IntegerField( required=True, min_value=1, max_value=9, widget=forms.NumberInput(attrs={'class': 'input-text'}), error_messages={ 'required': '排序值不能为空', 'invalid': '必须输入一个整数', 'min_value': '最小数值为1', 'max_value': '最大数值为9' }) content = SummernoteTextFormField( required=True, max_length=10240, error_messages={'required': '内容名不能为空'}, widget=forms.TextInput(attrs={'class': 'input-text'}), ) column = forms.IntegerField(required=True, widget=forms.Select(attrs={'class': 'select'}, ), error_messages={'required': '必须选择一个选项'})
class PostForm(ModelForm): content = SummernoteTextFormField() description = SummernoteTextField() class Meta: model = Post fields = ('title', 'category', 'post_image', 'description', 'content')
class SendMultiMailForm(forms.Form): title = forms.CharField( label='邮件标题', max_length=32, required=True, initial='通知 - 推免报名系统', widget=forms.TextInput(attrs={'class': 'form-control'})) content = SummernoteTextFormField( label='邮件正文', required=True, widget=SummernoteWidget(attrs={'class': 'form-control'})) attach = forms.FileField( label='附件', allow_empty_file=False, max_length=128, required=False, widget=forms.ClearableFileInput(attrs={'multiple': True})) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) q = choices = User.objects.annotate( label=Concat('last_name', 'first_name', V('('), 'person_id', V(')'), output_field=CharField())).values('id', 'label') self.fields['to'] = forms.MultipleChoiceField( label='收件人', choices=[(o['id'], o['label']) for o in q], required=True, widget=forms.SelectMultiple(attrs={'class': 'form-control'}))
class ProgrammingLanguageForm(forms.ModelForm): programming_language_skill_details = SummernoteTextFormField() class Meta: model = ProgrammingLanguageSkill fields = [ 'programming_language_skill', 'programming_language_skill_details' ]
class MassEmailForm(forms.Form): RECIPIENT_CHOICES = (('1', 'Do wszystkich'), ('2', 'Artykuł zgłoszony jako gotowy'), ('3', 'Artykuł uznany jako "Przyjęty"')) subject = forms.CharField(label='Temat') recipients = forms.ChoiceField(label='Adresaci', choices=RECIPIENT_CHOICES) content = SummernoteTextFormField(label='Treść')
class NewCommentForm(forms.ModelForm): body = SummernoteTextFormField() # body = forms.CharField(widget=FroalaEditor(theme='dark')) class Meta: model = NewComment fields = ('body', )
def test_formfield(self): from django import forms from django_summernote.fields import SummernoteTextFormField class SimpleForm(forms.Form): foobar = SummernoteTextFormField() f = SimpleForm() html = f.as_p() url = reverse('django_summernote-editor', kwargs={'id': 'id_foobar'}) assert url in html assert 'id="id_foobar"' in html illegal_tags = '<script></script>' form_field = SummernoteTextFormField() cleaned_text = form_field.clean(illegal_tags) self.assertEqual(cleaned_text, '<script></script>')
class ArticleForm(forms.Form): title = forms.CharField(max_length=8, label=' 文章标题') content = SummernoteTextFormField(required=True, max_length=10240, label="文章内容") type = forms.IntegerField( label="文章类别", widget=forms.Select( choices=ArticleType.objects.all().values_list('id', 'title')))
class EducationForm(forms.ModelForm): details_of_education = SummernoteTextFormField() class Meta: model = Education fields = [ 'name_of_education', 'start_date_of_education', 'end_date_of_education', 'details_of_education' ]
class ProjectForm(forms.ModelForm): details_of_project_experience = SummernoteTextFormField() class Meta: model = Project fields = [ 'name_of_project_experience', 'project_job_title', 'start_date_of_project_experience', 'end_date_of_project_experience', 'details_of_project_experience' ]
class WorkExperienceForm(forms.ModelForm): details_of_work_and_internship = SummernoteTextFormField() class Meta: model = WorkExperience fields = [ 'name_of_work_and_internship', 'job_title', 'start_date_of_work_and_internship', 'end_date_of_work_and_internship', 'details_of_work_and_internship' ]
class ColumnForm(forms.Form): articleType = forms.IntegerField( required=True, widget=forms.Select(attrs={'class': 'select'}, choices=ArticleType.objects.all().values_list( 'id', 'title')), error_messages={'required': '必须选择一个选项'}) title = SummernoteTextFormField( required=True, max_length=64, widget=forms.TextInput(attrs={'class': 'input-text'}), error_messages={'required': '栏目名不能为空'}) template = forms.IntegerField(required=True, widget=forms.Select( attrs={'class': 'select'}, choices=[ (1, '一行一列'), (2, '一行两列'), (3, '三行三列'), ]), error_messages={'required': '必须选择一个选项'}) isfluid = forms.IntegerField( required=True, widget=forms.RadioSelect(attrs={'class': 'radio'}, choices=[ (1, '全部宽度'), (2, '两侧白边'), ]), error_messages={'required': '必须选择一个选项'}, initial=[ 1, ], ) istitle = forms.IntegerField(required=True, widget=forms.RadioSelect( attrs={'class': 'radio'}, choices=[ (1, '显示标题栏'), (2, '隐藏标题栏'), ]), error_messages={'required': '必须选择一个选项'}, initial=[ 1, ]) sort = forms.IntegerField( required=True, widget=forms.NumberInput(attrs={'class': 'input-text'}), error_messages={ 'required': '排序值不能为空', 'invalid': '必须输入一个整数' })
class PaperCreationForm(forms.ModelForm): description = SummernoteTextFormField(label='Krótkie streszczenie') approved = forms.BooleanField(required=False,label=_('Gotowy do recenzji')) class Meta: model = Paper fields = ['title', 'club', 'keywords', 'description', 'approved'] exclude = ['author', 'reviewers', 'statement'] labels = dict(title=_('Tytuł'), club=_('Koło naukowe'), keywords=_('Słowa kluczowe'), description=_('Opis')) help_texts = dict(title=_('Tytuł'), keywords=_('Słowa kluczowe')) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['club'].queryset = StudentClub.objects.exclude(name='Brak')
class ReviewCreationForm(forms.ModelForm): text = SummernoteTextFormField(label='Treść recenzji') correspondence = GradeChoiceField(label=get_grade_label('correspondence'), queryset=Grade.objects.filter(tag='correspondence')) originality = GradeChoiceField(label=get_grade_label('originality'), queryset=Grade.objects.filter(tag='originality')) merits = GradeChoiceField(label=get_grade_label('merits'), queryset=Grade.objects.filter(tag='merits')) final_grade = GradeChoiceField(label=get_grade_label('final_grade'), queryset=Grade.objects.filter(tag='final_grade')) presentation = GradeChoiceField(label=get_grade_label('presentation'), queryset=Grade.objects.filter(tag='presentation')) class Meta: model = Review fields = ['correspondence', 'originality', 'merits', 'presentation', 'final_grade', 'text']
class ArticleForm(forms.ModelForm): text = SummernoteTextFormField() class Meta: model = Article fields = ('title', 'snippet', 'thumbnail', 'author', 'text') widgets = { 'author': forms.TextInput( attrs={ 'id': 'author-name', 'value': '', 'placeholder': ' ', 'readonly': '' }), }
class CommentAdminForm(forms.ModelForm): body = SummernoteTextFormField(label='Комментарий') class Meta: model = Comment fields = '__all__'
class NotesForm(forms.Form): title = forms.CharField() content = SummernoteTextFormField()
class PostForm(forms.Form): #restricted = forms.BooleanField() content = SummernoteTextFormField()
class CreateNewArticle (forms.Form): title = forms.CharField(max_length=200, label='Title of Document') text = SummernoteTextFormField(label='Document Body')
class PostForm(forms.Form): content = SummernoteTextFormField(widget=SummernoteInplaceWidget())
class ArticleForm(forms.Form): content = forms.CharField(widget=SummernoteWidget()) content = forms.CharField(widget=SummernoteTextFormField())
class SimpleForm(forms.Form): foobar = SummernoteTextFormField()
class BlogForm(forms.ModelForm): class Meta: model = Blog fields = ('title', 'content') content = SummernoteTextFormField()