コード例 #1
0
ファイル: forms.py プロジェクト: SuboOx/GitLight
class IssueForm(forms.Form):
    issue_title = forms.CharField(widget=forms.TextInput(
        attrs={
            'class': 'form-control form-control-user',
            'placeholder': "Title"
        }))
    content = MDTextFormField()
コード例 #2
0
class CalendrierForm(forms.ModelForm):
    # titre           = forms.CharField(label="Titre")
    description     = MDTextFormField(label="le Calendrier")

    class Meta:
    	model = Calendrier
    	fields = "__all__"
コード例 #3
0
class PostForm(forms.Form):
	title=forms.CharField(label="标题", max_length=25, widget=forms.TextInput(
		attrs={'class': 'form-control', 'placeholder': "文章标题", 'autofocus': ''}))
	post=MDTextFormField()
	excerpt=forms.CharField(label="标题", max_length=125, widget=forms.TextInput(
		attrs={'class': 'form-control', 'placeholder': "文章摘要", 'autofocus': ''}))
	category=forms.CharField(widget=forms.Select(
		attrs={'class': 'form-control select2', 'data-placeholder': '点击选择类别'}))
	tag=forms.CharField(widget=forms.SelectMultiple(
		attrs={'class': 'form-control select2', 'multiple': 'multiple','data-placeholder': '点击添加标签'}))

	def __init__(self,*args,**kwargs):
		super(PostForm, self).__init__(*args,**kwargs)
		categorys = Category.objects.all()
		cate_lst = []
		for i in categorys:
			cate_lst.append((i.id, i.name))
		self.fields['category'].widget.choices = cate_lst

		tags = Tag.objects.all()
		tag_lst = []
		for i in tags:
			tag_lst.append((i.id, i.name))
		print(tag_lst)
		self.fields['tag'].widget.choices = tag_lst
コード例 #4
0
class AdminPostForm(PostFormMixin, forms.ModelForm):

    title = forms.CharField(
        label=_("Title"),
        max_length=90,
        widget=forms.TextInput(attrs={"style": "width: 50%;"}),
    )
    slug = forms.CharField(
        label=_("Slug"),
        widget=forms.TextInput(attrs={"style": "width: 50%;"}))
    teaser = forms.CharField(
        label=_("Teaser"),
        widget=forms.Textarea(attrs={"style": "width: 80%;"}),
    )
    content = MDTextFormField()
    description = forms.CharField(
        label=_("Description"),
        widget=forms.Textarea(attrs={"style": "width: 80%;"}),
        required=False)

    class Meta:
        model = Post
        fields = FIELDS

    class Media:
        js = settings.PINAX_BLOG_ADMIN_JS

    def save(self, blog=None):
        post = super().save(commit=False)
        if blog:
            post.blog = blog
        return self.save_post(post)
コード例 #5
0
class PostForm(PostFormMixin, forms.ModelForm):

    markup_choice = "markdown"

    teaser = forms.CharField(widget=forms.Textarea())
    content = MDTextFormField()

    class Meta:
        model = Post
        fields = [
            "section", "title", "teaser", "content", "description", "state"
        ]

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if Section.objects.count() < 2:
            self.section = Section.objects.first()
            del self.fields["section"]
        else:
            self.section = None

    def save(self, blog=None, author=None):
        post = super().save(commit=False)
        if blog:
            post.blog = blog
        if author:
            post.author = author
            post.image_set = ImageSet.objects.create(created_by=author)
        if self.section:
            post.section = self.section
        post.slug = slugify(post.title)
        post.markup = self.markup_choice
        return self.save_post(post)
コード例 #6
0
class HoraireForm(forms.ModelForm):
    # titre           = forms.CharField(label="Titre")
    description     = MDTextFormField(label="Les horaires")

    class Meta:
    	model = Horaire
    	fields= "__all__"
コード例 #7
0
ファイル: xadminforms.py プロジェクト: blackmonkey121/MySpace
class ArticleAdminForm(forms.ModelForm):

    desc = forms.CharField(
        widget=forms.Textarea(attrs={'style': 'height: 100px;width:100%'}),
        label='摘要',
        required=False)

    content = MDTextFormField(label='正文', required=False)

    category = forms.ModelChoiceField(
        queryset=Category.objects.all(),
        widget=autocomplete.ModelSelect2(url='category-autocomplete'),
        label='分类',
    )

    tag = forms.ModelMultipleChoiceField(
        queryset=Tag.objects.all(),
        widget=autocomplete.ModelSelect2Multiple(url='tag-autocomplete'),
        label='标签')

    class Meta:
        model = Article
        fields = (
            'category',
            'tag',
            'desc',
            'title',
            'content',
            'status',
            'visit',
        )
コード例 #8
0
ファイル: forms.py プロジェクト: vskedrin/itnotes-student
class LocalNotesForm(forms.ModelForm):
    # name = forms.CharField(max_length=150)
    content = MDTextFormField()

    class Meta:
        model = LocalThemeTree
        fields = ('name', 'content')

    def __init__(self, user, *args, **kwargs):
        super(LocalNotesForm, self).__init__(*args, **kwargs)
        self.user = user
        self.parent = None
        # self.fields['field1'].queryset = AnotherModel.objects.filter(pk=my_arg1)
    def set_parent(self, parent):
        self.parent = parent

    def save(self):
        result = {'error': False, 'message': ''}
        if not self.user.is_authenticated:
            result['error'] = True
            result[
                'message'] = 'Не авторизованный пользователь не может создавать заметки!'
        else:
            LocalThemeTree.objects.create(name=self.cleaned_data['name'],
                                          content=self.cleaned_data['content'],
                                          author=self.user,
                                          parent=self.parent)
        return result
コード例 #9
0
ファイル: forms.py プロジェクト: zhangxiucheng/Django--Shihu
class AnswerForm(forms.Form):
    title = forms.CharField()
    body = MDTextFormField()
    tags = forms.MultipleChoiceField()

    def __init__(self, *args, **kwargs):
        # 执行父类构造方法
        super(AnswerForm, self).__init__(*args, **kwargs)
コード例 #10
0
class MDEditorForm(forms.Form):
    title = forms.CharField()
    synopsis = forms.CharField()
    category = forms.ChoiceField(choices=CATEGORY_CHOICES,
                                 label="category",
                                 initial='',
                                 widget=forms.RadioSelect())
    content = MDTextFormField()
コード例 #11
0
class QuestionForm(forms.Form):
    title = forms.CharField(max_length=20, min_length=2,
                            widget=forms.TextInput(attrs={'class': 'form-control',
                                                          'placeholder': '请输入题目标题'}), label='题目标题')
    deadline = forms.DateTimeField(widget=forms.DateTimeInput(attrs={'type': 'datetime-local',
                                                                     'class': 'form-control'}),
                                   label='截至日期')
    question_text = MDTextFormField()
コード例 #12
0
class ArticleForm(forms.ModelForm):
    content = MDTextFormField()

    class Meta:
        model = Article
        fields = [
            'category', "title", "abstract", "content", "cover", "tags",
            "status"
        ]
コード例 #13
0
ファイル: models.py プロジェクト: RedFox2017/DjangoBlog
class MDEditorForm(forms.Form):
    title = forms.CharField(label='标题', max_length=128)
    brief = forms.CharField(label='简要',
                            max_length=128,
                            widget=forms.Textarea(attrs={'rows': 5}))
    cover = forms.ImageField(label='封面')
    category = forms.ChoiceField(label='分类',
                                 choices=CategoryInfo.objects.values_list(
                                     'id', 'c_name'))
    content = MDTextFormField(label='正文')
コード例 #14
0
ファイル: forms.py プロジェクト: tomlongcool/djangoa
class ArticleForm(forms.ModelForm):

    content = MDTextFormField()

    class Meta:
        model = Article
        fields = [
            'category', 'title', 'abstract', 'content', 'status', 'tags',
            'cover'
        ]
コード例 #15
0
class ArticleForm(forms.ModelForm):
    content = MDTextFormField()  # content改成用md来渲染

    class Meta:
        model = Article
        # 希望用户填的字段
        fields = [
            "category", "title", "abstract", "content", "cover", "tags",
            "status"
        ]
コード例 #16
0
ファイル: forms.py プロジェクト: Ngapa/Website
 class Meta:
     model = Post
     fields = ('judul', 'konten', 'kategori')
     widgets = {
         'judul':
         forms.TextInput(attrs={'class': 'form-control'}),
         'kategori':
         forms.Select(choices=choices_list, attrs={'class':
                                                   'form-control'}),
         'konten':
         MDTextFormField(),
     }
コード例 #17
0
class AnswerForm(forms.Form):
    answer_text = MDTextFormField()
    question_pk = forms.IntegerField(widget=forms.HiddenInput)

    def clean(self):
        # 问题存在验证
        question_pk = self.cleaned_data['question_pk']
        try:
            Question.objects.get(pk=question_pk)
        except Exception as e:
            raise ValidationError('问题不存在')

        return self.cleaned_data
コード例 #18
0
class HuntForm(forms.Form):
    content = MDTextFormField()
    start_date = forms.DateTimeField(
        widget=forms.DateTimeInput(attrs={
            'class': 'col-sm-6',
            'readonly': True
        }),
        label='',
        required=False)
    end_date = forms.DateTimeField(widget=forms.DateTimeInput(attrs={
        'class': 'col-sm-6',
        'readonly': True
    }),
                                   label='',
                                   required=False)
コード例 #19
0
class ArticleForm(forms.ModelForm):

    content = MDTextFormField()

    # category = forms.ModelChoiceField(queryset=ArticleCategory.objects.all(), widget=forms.Select(attrs={'class': 'ui search dropdown'}))
    class Meta:
        model = Article
        fields = ["title", "content", "category", "abstract", "tags", "status"]

        widgets = {
            'title': forms.TextInput(attrs={'placeholder': '文章标题'}),
            'tags': forms.TextInput(attrs={'placeholder': '多个标签使用英文逗号(,)隔开'}),
            'category': forms.Select(attrs={'class': 'ui search dropdown'}),
            'abstract': forms.Textarea(attrs={'placeholder': '文章摘要'})
        }
コード例 #20
0
ファイル: forms.py プロジェクト: sai11121209/Portfolio
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.fields['title'] = forms.CharField(
         label='',
         widget=forms.TextInput(attrs={
             'class': 'title',
             'placeholder': 'タイトル'
         }))
     self.fields['tags'] = forms.CharField(
         label='',
         widget=forms.TextInput(attrs={
             'class': 'tag',
             'placeholder': 'タグをスペース区切りで入力'
         }))
     self.fields['text'] = MDTextFormField()
コード例 #21
0
ファイル: xadminforms.py プロジェクト: blackmonkey121/MySpace
class TravelAdminForm(forms.ModelForm):

    context = MDTextFormField(label='旅途描述', required=False, )

    province = forms.ModelChoiceField(
        queryset=Province.objects.values('id', 'name').filter(status=Province.STATUS_NORMAL),
        widget=autocomplete.ModelSelect2(url='province-autocomplete'),
        label='省份',
    )

    class Meta:
        model = Travel
        fields = (
            'title', 'context', 'visit',
            'status', 'province'
        )
コード例 #22
0
ファイル: adminforms.py プロジェクト: ahaox/MyProBlog
class ArticleAdminForm(forms.ModelForm):
    desc = forms.CharField(widget=forms.Textarea, label='摘要', required=False)
    content = MDTextFormField(widget=MDEditorWidget(),
                              label='正文',
                              required=True)

    category = forms.ModelChoiceField(
        queryset=Category.objects.all(),
        widget=autocomplete.ModelSelect2(url='category-autocomplete'),
        label='分类',
    )
    tag = forms.ModelMultipleChoiceField(
        queryset=Tag.objects.all(),
        widget=autocomplete.ModelSelect2Multiple(url='tag-autocomplete'),
        label='标签',
    )
コード例 #23
0
class CycleForm(forms.ModelForm):
    nom = forms.CharField(label="nom du cycle")
    description = MDTextFormField(label="La description du cyle")

    class Meta:
        model = Cycle
        exclude = ["slug"]

    def save(self, commit=True):
        instance = super(CycleForm, self).save(commit=False)

        if not instance.slug:
            instance.slug = unique_slug_generator_identif(
                instance, instance.nom)
        if commit:
            instance.save()

        return instance
コード例 #24
0
class PresentionForm(forms.ModelForm):
    titre = forms.CharField(label="Titre")
    description = MDTextFormField(label="Description globale des cyles")

    class Meta:
        model = Presention
        exclude = ["slug"]

    def save(self, commit=True):
        instance = super(PresentionForm, self).save(commit=False)

        if not instance.slug:
            instance.slug = unique_slug_generator_identif(
                instance, instance.titre)
        if commit:
            instance.save()

        return instance
コード例 #25
0
class InfobuleForm(forms.ModelForm):
	info 			= forms.CharField(label="Infobule")
	contenu 		= MDTextFormField(label="Le contenu")

	class Meta:
		model = Infobule
		exclude = ["slug"]


	def save(self, commit=True):
		instance = super(InfobuleForm, self).save(commit=False)
		print("Voici instance", instance)

		if not instance.slug:
			instance.slug = unique_slug_generator_for_null(instance)
		if commit:
			instance.save()
		
		return instance
コード例 #26
0
class PartenaireForm(forms.ModelForm):
    nom = forms.CharField(label="Infobule")
    lien_site = forms.URLField(label="Lien de son site ou page")
    contenu = MDTextFormField(label="Le contenu")

    class Meta:
        model = Partenaire
        exclude = ["slug"]

    def save(self, commit=True):
        instance = super(PartenaireForm, self).save(commit=False)
        print("Voici instance", instance)

        if not instance.slug:
            instance.slug = unique_slug_generator_identif(
                instance, instance.nom)
        if commit:
            instance.save()

        return instance
コード例 #27
0
ファイル: forms.py プロジェクト: loveliuli/django-blog
class ArticleAddForm(forms.Form):
    name = forms.CharField(label=u'文章标题', max_length=50)
    cover = forms.ImageField(label=u'封面', )
    content = MDTextFormField(label=u'内容', min_length=50)
    type = forms.ChoiceField(label=u'分类', choices=BlogTypes)
    tags = TagField(label=u'标签', max_length=50)

    def save(self):
        cd = self.cleaned_data
        name = cd['name']
        cover = cd['cover']
        type = cd['type']
        content = cd['content']
        tags = cd['tags']
        article = Article(name=name,
                          cover=cover,
                          content=content,
                          type=type,
                          tags=tags)
        article.save()
コード例 #28
0
ファイル: forms.py プロジェクト: Ngapa/Website
    class Meta:
        model = Post
        fields = ('judul', 'author', 'kategori', 'konten')

        widgets = {
            'judul':
            forms.TextInput(attrs={'class': 'form-control'}),
            'author':
            forms.TextInput(
                attrs={
                    'class': 'form-control',
                    'id': 'author',
                    'value': '',
                    'type': 'hidden'
                }),
            'kategori':
            forms.Select(choices=choices_list, attrs={'class':
                                                      'form-control'}),
            'konten':
            MDTextFormField(),
        }
コード例 #29
0
ファイル: forms.py プロジェクト: liangliangyuese/blog
class ArticleForm(forms.Form):
    title = forms.CharField(label="文章标题", max_length=20)
    label = forms.CharField(label="文章标签", max_length=20)
    content = MDTextFormField(label="文章内容")

    def clean_title(self):
        title = self.cleaned_data.get("title")
        if len(title) < 6:
            raise forms.ValidationError("标题长度需要大于6")
        elif len(title) > 20:
            raise forms.ValidationError("标题长度需要小于20")
        else:
            return title

    def clean_label(self):
        label = self.cleaned_data.get("label")
        if len(label) < 6:
            raise forms.ValidationError("文章标签长度需要大于6")
        elif len(label) > 20:
            raise forms.ValidationError("文章标签长度需要小于20")
        else:
            return label
コード例 #30
0
ファイル: forms.py プロジェクト: liangliangyuese/blog
class AlterArticleForm(forms.Form):
    # TODO 文章修改表单--与接口交互渲染??
    id = forms.IntegerField(label="文章id")
    title = forms.CharField(label="文章标题", max_length=20)
    label = forms.CharField(label="文章标签", max_length=20)
    content = MDTextFormField(label="文章内容")