|
|
@ -1,6 +1,6 @@
|
|
|
|
from wtforms import Form
|
|
|
|
from wtforms import Form
|
|
|
|
from wtforms import StringField, PasswordField, BooleanField, SubmitField, FileField, MultipleFileField, ValidationError, RadioField, TextAreaField, HiddenField, SelectField
|
|
|
|
from wtforms import StringField, PasswordField, BooleanField, SubmitField, FileField, MultipleFileField, ValidationError, RadioField, TextAreaField, HiddenField, SelectField
|
|
|
|
from wtforms.validators import DataRequired, InputRequired, Email, EqualTo, AnyOf, optional, StopValidation
|
|
|
|
from wtforms.validators import DataRequired, InputRequired, Email, EqualTo, AnyOf, optional, StopValidation, URL
|
|
|
|
|
|
|
|
|
|
|
|
from werkzeug.utils import cached_property
|
|
|
|
from werkzeug.utils import cached_property
|
|
|
|
|
|
|
|
|
|
|
@ -65,7 +65,7 @@ def validate_file(form, field):
|
|
|
|
|
|
|
|
|
|
|
|
class UploadForm(CSRFForm):
|
|
|
|
class UploadForm(CSRFForm):
|
|
|
|
post_img = FileField('Image', validators=[validate_file], render_kw={'required':''})
|
|
|
|
post_img = FileField('Image', validators=[validate_file], render_kw={'required':''})
|
|
|
|
sauce = StringField('Sauce', validators=[DataRequired()], render_kw=dict(placeholder='Source URL', autocomplete='off'))
|
|
|
|
sauce = StringField('Sauce', validators=[DataRequired(), URL()], render_kw=dict(placeholder='Source URL', autocomplete='off'))
|
|
|
|
tags = StringField('Tags', validators=[DataRequired()], render_kw=dict(placeholder='Tags', autocomplete='off')) # CUSTOM VALIDATOR (also for Post edits)
|
|
|
|
tags = StringField('Tags', validators=[DataRequired()], render_kw=dict(placeholder='Tags', autocomplete='off')) # CUSTOM VALIDATOR (also for Post edits)
|
|
|
|
rating = RadioField('Rating',
|
|
|
|
rating = RadioField('Rating',
|
|
|
|
choices=[(e.name, e.name.capitalize()) for e in RATING],
|
|
|
|
choices=[(e.name, e.name.capitalize()) for e in RATING],
|
|
|
@ -153,7 +153,7 @@ class PostForm(EditForm):
|
|
|
|
status = SelectField('Status',
|
|
|
|
status = SelectField('Status',
|
|
|
|
choices=[(e.name, e.name.capitalize()) for e in POST_STATUS],
|
|
|
|
choices=[(e.name, e.name.capitalize()) for e in POST_STATUS],
|
|
|
|
validators=[optional()])
|
|
|
|
validators=[optional()])
|
|
|
|
source = StringField('Source', render_kw=dict(placeholder='Source URL', autocomplete='off'))
|
|
|
|
source = StringField('Source', validators=[optional(), URL()], render_kw=dict(placeholder='Source URL', autocomplete='off'))
|
|
|
|
|
|
|
|
|
|
|
|
referer = HiddenField()
|
|
|
|
referer = HiddenField()
|
|
|
|
approve = SubmitField('Approve')
|
|
|
|
approve = SubmitField('Approve')
|
|
|
|