コード例 #1
0
class SceneForm(ModelForm):
    description = MarkdownxFormField()
    characters = MarkdownxFormField()
    encounters = MarkdownxFormField()
    rewards = MarkdownxFormField()

    class Meta:
        model = Scene
        fields = ("name", "place", "description", "characters", "encounters",
                  "rewards", "sound_effects")
コード例 #2
0
class BookForm(forms.ModelForm):
    description = MarkdownxFormField()

    class Meta:
        model = Book
        # fields = '__all__'
        fields = ['name', 'pages', 'status', 'current_price', 'description']
コード例 #3
0
ファイル: forms.py プロジェクト: PudgyPoppins/AP-Crowd-2020
class PageBaseForm(ModelForm):
	content = MarkdownxFormField()
	class Meta:
		model = Page
		fields = ['title', 'slug', 'exam_date', 'protection', 'content', 'edit_summary']
		#labels = {'lat': _('Latitude'), 'lon': _('Longitude'), 'src_link': _('Image Url'), 'src_file': _('Image File')}
		help_texts = {'edit_summary': _('Briefly describe your changes'),}
		widgets = {
			#'tags': CheckboxSelectMultiple(),
		}

	def clean_title(self):
		title = self.cleaned_data['title']
		title = title.strip()
		title = " ".join(w.capitalize() for w in title.split())
		return title

	def clean_slug(self):
		slug = self.cleaned_data['slug']
		slug = slugify(slug)
		if slug in ['_create', '_update', '_clone', '_move', '_history']:
			raise ValidationError(_('Slug cannot have this value. (Try using a different word, or not using an underscore at the beginning.)'))
		if len(slug)>= 1 and not slug[0].isalpha():
			raise ValidationError(_('The first character of a slug must be a letter character.)'))
		return slug

	def clean_exam_date(self):
		date = self.cleaned_data['exam_date']
		return date

	def clean_protection(self):
		protection = self.cleaned_data['protection']
		if protection not in ['NO', 'LO', 'CO', 'NC']:
			raise ValidationError(_('Protection must be one of four values determined by this site. Refresh the page and try again.)'))
		return protection
コード例 #4
0
ファイル: forms.py プロジェクト: carpentries/amy
class GenericEmailScheduleForm(forms.ModelForm):
    body_template = MarkdownxFormField(
        label="Markdown body",
        widget=AdminMarkdownxWidget,
        required=True,
    )
    helper = BootstrapHelper(
        wider_labels=True,
        add_cancel_button=False,
        add_submit_button=False,
        form_tag=False,
    )

    class Meta:
        model = EmailTemplate
        fields = [
            "slug",
            "subject",
            "to_header",
            "from_header",
            "cc_header",
            "bcc_header",
            "reply_to_header",
            "body_template",
        ]
コード例 #5
0
class PostForm(forms.ModelForm):
    title = forms.CharField(label='Title', max_length=100)
    text = MarkdownxFormField()

    class Meta:
        model = Post
        fields = ['title', 'text']
コード例 #6
0
ファイル: forms.py プロジェクト: mengfa/yousi
class QuestionForm(forms.ModelForm):
    status = forms.CharField(widget=forms.HiddenInput())
    content = MarkdownxFormField()

    class Meta:
        model = Question
        fields = ["title", "content", "tags", "status"]
コード例 #7
0
class EmailMessageForm(forms.ModelForm):
    message = MarkdownxFormField()
    image = forms.ImageField(required=False)

    class Meta:
        model = EmailMessage
        fields = ["recipients", "title", "message", 'image']
コード例 #8
0
ファイル: forms.py プロジェクト: Palameng/Demo
class MyForm(forms.Form):

    content = MarkdownxFormField()

    class Meta:
        model = Article
        fields = ['comment']
コード例 #9
0
class PublicacionForm(forms.ModelForm):
    contenido = MarkdownxFormField()
    autor = forms.ModelChoiceField(get_user_model().objects.all(), required=False)

    class Meta:
        model = Publicacion
        fields = ['autor', 'titulo', 'fecha_publicacion', 'contenido']
        widgets = {
            'fecha_publicacion': forms.SelectDateWidget(attrs={'style': 'width: 32%; display: inline-block'})
        }

    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_tag = False
        fecha_publicacion = Div(Field('fecha_publicacion'))
        fecha_publicacion.css_class = 'col-md-4'
        titulo = Div(Field('titulo'))
        titulo.css_class = 'col-md-8'
        contenido = Div(Field('contenido'))
        contenido.css_class = 'col-8'
        tags = Div(Formset('tags'))
        tags.css_class = 'col-4'
        row = Div(titulo, fecha_publicacion, contenido, tags)
        row.css_class = 'row'
        self.helper.layout = Layout(row)
        super(PublicacionForm, self).__init__(*args, **kwargs)
コード例 #10
0
ファイル: forms.py プロジェクト: abercompsoc/website
class UserCommentForm(forms.ModelForm):

    bodytext = MarkdownxFormField()

    class Meta:
        model = Comment
        fields = ["bodytext"]
コード例 #11
0
ファイル: forms.py プロジェクト: gaybro8777/amy
class EventCreateForm(EventForm):
    comment = MarkdownxFormField(
        label="Comment",
        help_text="This will be added to comments after the event is created.",
        widget=forms.Textarea,
        required=False,
    )
コード例 #12
0
class Blog2(forms.Form):
    title = forms.CharField(max_length=32)
    # author = forms.CharField(max_length=16)
    # content = forms.CharField()
    content = MarkdownxFormField()
    catagory = forms.CharField()
    tag = forms.CharField()
コード例 #13
0
    def __init__(self, contest_id, user_id, *args, **kwargs):
        super(StatusForm, self).__init__(*args, **kwargs)
        self.fields['summary'] = MarkdownxFormField(required=True)
        cts = Contest.objects.get(id=contest_id)
        user = User.objects.get(id=user_id)
        STATUS_OF_AC = [
            ('1', 'Solved'),
            ('2', 'Upsolved'),
            ('3', 'Not Solved'),
        ]

        for i in range(0, cts.num_of_problem):
            self.fields['p' + str(i)] = forms.ChoiceField(label='Problem ' +
                                                          chr(ord('A') + i),
                                                          choices=STATUS_OF_AC)
            self.initial['p' + str(i)] = '3'
            # CONTRIBUTOR_FIELD = [
            #     ('1', user.userprofile.team_member_1),
            #     ('2', user.userprofile.team_member_2),
            #     ('4', user.userprofile.team_member_3),
            # ]
            CONTRIBUTOR_FIELD = [
                ('1', ""),
                ('2', ""),
                ('4', ""),
            ]
            self.fields['c' + str(i)] = forms.MultipleChoiceField(
                label='Contributor',
                choices=CONTRIBUTOR_FIELD,
                widget=forms.CheckboxSelectMultiple(),
                required=False)
            self.initial['c' + str(i)] = []
コード例 #14
0
ファイル: forms.py プロジェクト: IgnisDa/Inscribe
class NoteCreateOrUpdateForm(forms.ModelForm):
    body = MarkdownxFormField()

    class Meta:
        model = models.Note
        fields = "__all__"
        exclude = ("slug", "writer")
コード例 #15
0
ファイル: forms.py プロジェクト: 3pacccccc/zanhu
class QuestionForm(forms.ModelForm):
    status = forms.CharField(widget=forms.HiddenInput())
    content = MarkdownxFormField()

    class Meta:
        model = Question
        fields = ['title', 'content', 'tags', 'status']
コード例 #16
0
ファイル: forms.py プロジェクト: oneirism/reverie
class CharacterEntryForm(forms.ModelForm):
    """ A Reverie character form. """
    def __init__(self, *args, **kwargs):
        super(CharacterEntryForm, self).__init__(*args, **kwargs)

        self.fields['player'] = forms.ModelChoiceField(
            queryset=self.instance.campaign.players,
            required=False,
            widget=forms.Select(),
            empty_label="----",
        )

        self.fields['is_pc'].label = "Is Player Character"
        self.fields['slug'].label = "Slug Override (Optional)"

    description = MarkdownxFormField(
        widget=ReverieMarkdownWidget()
    )

    class Meta:
        model = Character

        fields = ['name', 'tagline', 'image', 'cropping', 'description', 'player', 'is_pc', 'slug']

        widgets = {
            'image': ImageCropWidget,
        }
コード例 #17
0
    class Meta():
        model = Post
        fields = ('author', 'title', 'text', 'thumbnail')

        widgets = {
            'title': forms.TextInput(attrs={'class': 'textinputclass'}),
            'text': MarkdownxFormField()
        }
コード例 #18
0
ファイル: forms.py プロジェクト: Yookyiss/segmentfault
class AnswerForm(forms.ModelForm):
    content = MarkdownxFormField()

    class Meta:
        model = Answer
        fields = [
            'content',
        ]
コード例 #19
0
class UpdatePageForm(ModelForm):
    title = CharField(max_length=100)
    # body = CharField(max_length=2000, widget=Textarea)
    body2 = MarkdownxFormField()

    class Meta:
        model = Page
        fields = ['body2']
コード例 #20
0
class BlogPostForm(forms.Form):
    '''
    Create or edit blog post
    '''
    title = forms.CharField(max_length=256)
    thumbnail = forms.ImageField(required=False)
    preview = forms.CharField(max_length=128)
    body = MarkdownxFormField()
コード例 #21
0
ファイル: forms.py プロジェクト: yanwarsolah/website
 class Meta:
     model = Comment
     fields = (
         'comment_content',
     )
     comment_content = MarkdownxFormField()
     exclude = ['comment_author']
     widgets = {'comment_author': forms.HiddenInput()}
コード例 #22
0
class QuestionForms(forms.ModelForm):

    content = MarkdownxFormField()

    class Meta:

        model = Question
        fields = ["title", "content", "tags", "status"]
コード例 #23
0
class ArticleForm(forms.ModelForm):
    status = forms.CharField(widget=forms.HiddenInput())  # 隐藏
    edited = forms.BooleanField(widget=forms.HiddenInput(), required=False, initial=False)  # 隐藏
    content = MarkdownxFormField()

    class Meta:
        model = Article
        fields = ["title", "content", "image", "tags", "status", "edited"]
コード例 #24
0
ファイル: forms.py プロジェクト: ruthaleks/travelblog
 class Meta:
     model = Post
     fields = ['title', 'post_content', 'travel_date']
     labels = {'title': '', 'travel_date': '', 'post_content': ''}
     widgets = {
         'post_content': MarkdownxFormField(),
         'travel_date': forms.SelectDateWidget(),
     }
コード例 #25
0
class ArticleForm(forms.ModelForm):

    content = MarkdownxFormField()
    status = forms.CharField(widget=forms.HiddenInput())  # 隐藏
    edited = forms.BooleanField(widget=forms.HiddenInput(), initial=False, required=False)
    class Meta:
        model = Article
        fields = ['title', 'content', 'image', 'tags', 'status', 'edited']
コード例 #26
0
class NewTopicForm(forms.ModelForm):
    description = MarkdownxFormField()

    class Meta:
        model = Topic
        fields = ['subject', 'description']
        widgets = {
            'description': MarkdownxWidget(attrs={'class': 'textarea'}),
        }
コード例 #27
0
ファイル: forms.py プロジェクト: Pysuper/ZanHu
class ArticleForm(forms.ModelForm):
    """用户发表文章的表单"""
    edited = forms.BooleanField(widget=forms.HiddenInput(), initial=False, required=False)  # initial初始化值,required用户可以不填写
    status = forms.CharField(widget=forms.HiddenInput())  # 对用户不可见
    content = MarkdownxFormField()

    class Meta:
        model = Article
        fields = ["title", "content", "image", "tags", "status", "edited"]
コード例 #28
0
class MemoForm(forms.ModelForm):
    content = MarkdownxFormField()

    class Meta:
        model = Memo
        fields = (
            'title',
            'content',
        )
コード例 #29
0
class ProfileForm(forms.ModelForm):
    """Profile Form + Fields for Photo Processing"""
    x = forms.FloatField(widget=forms.HiddenInput(), required=False)
    y = forms.FloatField(widget=forms.HiddenInput(), required=False)
    width = forms.FloatField(widget=forms.HiddenInput(), required=False)
    height = forms.FloatField(widget=forms.HiddenInput(), required=False)
    bio = MarkdownxFormField(validators=[MinLengthValidator(10)])

    class Meta:
        model = Profile
        fields = [
            'first_name',
            'last_name',
            'email',
            'email_verify',
            'date_of_birth',
            'bio',
            'city',
            'state',
            'country_of_residence',
            'favorite_animal',
            'hobby',
            'avatar',
            'x',
            'y',
            'width',
            'height',
        ]
        widgets = {
            # default date-format %m/%d/%Y will be used
            'date_of_birth': DatePickerInput(),
        }

    def clean(self):
        """Clean the whole form"""
        cleaned_data = super().clean()
        email = cleaned_data.get('email')
        verify = cleaned_data.get('email_verify')

        if email != verify:
            raise forms.ValidationError('Emails do not match')

    def save(self):
        """Override the Save method for saving the crop photo"""
        photo = super().save()

        x = self.cleaned_data.get('x')
        y = self.cleaned_data.get('y')
        w = self.cleaned_data.get('width')
        h = self.cleaned_data.get('height')

        if x is not None:
            image = Image.open(photo.avatar)
            cropped_image = image.crop((x, y, w + x, h + y))
            resized_image = cropped_image.resize((200, 200), Image.ANTIALIAS)
            resized_image.save(photo.avatar.path)
        return photo
コード例 #30
0
ファイル: forms.py プロジェクト: mkofoed/mkofoed
class PostCreateForm(forms.ModelForm):
    content = MarkdownxFormField()

    class Meta:
        model = Post
        exclude = ['date_created', 'date_modified', 'slug', 'author']
        help_texts = {
            'title': 'Title',
            'summary': 'Summary',
            'published': 'Published'}