|
|
@ -22,15 +22,15 @@ class CSRFForm(Form):
|
|
|
|
csrf_field_name = 'csrf_token'
|
|
|
|
csrf_field_name = 'csrf_token'
|
|
|
|
|
|
|
|
|
|
|
|
class LoginForm(CSRFForm):
|
|
|
|
class LoginForm(CSRFForm):
|
|
|
|
username = StringField('Username', validators=[DataRequired()])
|
|
|
|
username = StringField('Username', validators=[DataRequired()], render_kw=dict(placeholder="Username"))
|
|
|
|
password = PasswordField('Password', validators=[DataRequired()])
|
|
|
|
password = PasswordField('Password', validators=[DataRequired()], render_kw=dict(placeholder="Password"))
|
|
|
|
remember_me = BooleanField('Remember me')
|
|
|
|
remember_me = BooleanField('Remember me')
|
|
|
|
submit = SubmitField('Log In')
|
|
|
|
submit = SubmitField('Log In')
|
|
|
|
|
|
|
|
|
|
|
|
from yadc.models import User
|
|
|
|
from yadc.models import User
|
|
|
|
|
|
|
|
|
|
|
|
class ResetPasswordForm(CSRFForm):
|
|
|
|
class ResetPasswordForm(CSRFForm):
|
|
|
|
email = StringField('E-mail', validators=[DataRequired(), Email()])
|
|
|
|
email = StringField('Email', validators=[DataRequired(), Email()], render_kw=dict(placeholder="Your email address"))
|
|
|
|
submit = SubmitField('Reset password')
|
|
|
|
submit = SubmitField('Reset password')
|
|
|
|
|
|
|
|
|
|
|
|
# def validate_email(form, field):
|
|
|
|
# def validate_email(form, field):
|
|
|
@ -39,10 +39,10 @@ class ResetPasswordForm(CSRFForm):
|
|
|
|
# raise ValidationError('This')
|
|
|
|
# raise ValidationError('This')
|
|
|
|
|
|
|
|
|
|
|
|
class RegisterForm(CSRFForm):
|
|
|
|
class RegisterForm(CSRFForm):
|
|
|
|
username = StringField('Username', validators=[DataRequired()])
|
|
|
|
username = StringField('Username', validators=[DataRequired()], render_kw=dict(placeholder="Username"))
|
|
|
|
email = StringField('E-mail', validators=[DataRequired(), Email()])
|
|
|
|
email = StringField('Email', validators=[DataRequired(), Email()], render_kw=dict(placeholder="Email"))
|
|
|
|
password = PasswordField('Password', validators=[DataRequired()])
|
|
|
|
password = PasswordField('Password', validators=[DataRequired()], render_kw=dict(placeholder="Password"))
|
|
|
|
password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')])
|
|
|
|
password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')], render_kw=dict(placeholder="Repeat password"))
|
|
|
|
submit = SubmitField('Register')
|
|
|
|
submit = SubmitField('Register')
|
|
|
|
|
|
|
|
|
|
|
|
def validate_username(form, field):
|
|
|
|
def validate_username(form, field):
|
|
|
@ -65,8 +65,8 @@ 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={'placeholder':'Source URL','autocomplete':'off'})
|
|
|
|
sauce = StringField('Sauce', validators=[DataRequired()], render_kw=dict(placeholder='Source URL', autocomplete='off'))
|
|
|
|
tags = StringField('Tags', validators=[DataRequired()], render_kw={'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],
|
|
|
|
default=RATING.safe.name,
|
|
|
|
default=RATING.safe.name,
|
|
|
@ -88,14 +88,14 @@ class ChangeUserInfoForm(CSRFForm):
|
|
|
|
userinfo_submit = SubmitField('Change your info')
|
|
|
|
userinfo_submit = SubmitField('Change your info')
|
|
|
|
|
|
|
|
|
|
|
|
class ChangePassForm(CSRFForm):
|
|
|
|
class ChangePassForm(CSRFForm):
|
|
|
|
password_current = PasswordField('Current password', validators=[DataRequired()])
|
|
|
|
password_current = PasswordField('Current password', validators=[DataRequired()], render_kw=dict(placeholder="Current password"))
|
|
|
|
password = PasswordField('Password', validators=[DataRequired()])
|
|
|
|
password = PasswordField('Password', validators=[DataRequired()], render_kw=dict(placeholder="New password"))
|
|
|
|
password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')])
|
|
|
|
password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')], render_kw=dict(placeholder="Repeat password"))
|
|
|
|
pass_submit = SubmitField('Change password')
|
|
|
|
pass_submit = SubmitField('Change password')
|
|
|
|
|
|
|
|
|
|
|
|
class ChangeMailForm(CSRFForm):
|
|
|
|
class ChangeMailForm(CSRFForm):
|
|
|
|
email = StringField('E-mail', validators=[DataRequired(), Email()], render_kw=dict(placeholder="E-mail"))
|
|
|
|
email = StringField('Email', validators=[DataRequired(), Email()], render_kw=dict(placeholder="Email"))
|
|
|
|
email_again = StringField('Repeat e-mail', validators=[DataRequired(), EqualTo('email')], render_kw=dict(placeholder="Repeat e-mail"))
|
|
|
|
email_again = StringField('Repeat email', validators=[DataRequired(), EqualTo('email')], render_kw=dict(placeholder="Repeat email"))
|
|
|
|
mail_submit = SubmitField('Change email')
|
|
|
|
mail_submit = SubmitField('Change email')
|
|
|
|
|
|
|
|
|
|
|
|
class ChangeUserRatingForm(CSRFForm):
|
|
|
|
class ChangeUserRatingForm(CSRFForm):
|
|
|
@ -106,7 +106,7 @@ class ChangeUserRatingForm(CSRFForm):
|
|
|
|
rating_submit = SubmitField('Change default rating')
|
|
|
|
rating_submit = SubmitField('Change default rating')
|
|
|
|
|
|
|
|
|
|
|
|
class ChangeTagBlacklistForm(CSRFForm):
|
|
|
|
class ChangeTagBlacklistForm(CSRFForm):
|
|
|
|
tags = StringField('Tags', render_kw={'placeholder':'Tags','autocomplete':'off'})
|
|
|
|
tags = StringField('Tags', render_kw=dict(placeholder='Tags', autocomplete='off'))
|
|
|
|
tags_submit = SubmitField('Change blacklisted tags', validators=[DataRequired()])
|
|
|
|
tags_submit = SubmitField('Change blacklisted tags', validators=[DataRequired()])
|
|
|
|
|
|
|
|
|
|
|
|
class DeleteUserDataForm(CSRFForm):
|
|
|
|
class DeleteUserDataForm(CSRFForm):
|
|
|
@ -136,8 +136,8 @@ def validate_create_required(form, field):
|
|
|
|
raise ValidationError('Please fill out this field.')
|
|
|
|
raise ValidationError('Please fill out this field.')
|
|
|
|
|
|
|
|
|
|
|
|
class UserForm(EditForm):
|
|
|
|
class UserForm(EditForm):
|
|
|
|
username = StringField('Username', validators=[validate_create_required])
|
|
|
|
username = StringField('Username', validators=[validate_create_required], render_kw=dict(placeholder='Username'))
|
|
|
|
email = StringField('E-mail', validators=[optional(), Email()])
|
|
|
|
email = StringField('Email', validators=[optional(), Email()], render_kw=dict(placeholder='Email'))
|
|
|
|
user_status = SelectField('User status',
|
|
|
|
user_status = SelectField('User status',
|
|
|
|
choices=[(e.name, e.name.capitalize()) for e in USER_STATUS],
|
|
|
|
choices=[(e.name, e.name.capitalize()) for e in USER_STATUS],
|
|
|
|
validators=[optional()])
|
|
|
|
validators=[optional()])
|
|
|
@ -146,19 +146,19 @@ class UserForm(EditForm):
|
|
|
|
validators=[optional()])
|
|
|
|
validators=[optional()])
|
|
|
|
|
|
|
|
|
|
|
|
class PostForm(EditForm):
|
|
|
|
class PostForm(EditForm):
|
|
|
|
tags = StringField('Tags', render_kw={'placeholder':'Tags','autocomplete':'off'})
|
|
|
|
tags = StringField('Tags', render_kw=dict(placeholder='Tags', autocomplete='off'))
|
|
|
|
rating = SelectField('Rating',
|
|
|
|
rating = SelectField('Rating',
|
|
|
|
choices=[(e.name, e.name.capitalize()) for e in RATING],
|
|
|
|
choices=[(e.name, e.name.capitalize()) for e in RATING],
|
|
|
|
validators=[optional()])
|
|
|
|
validators=[optional()])
|
|
|
|
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={'autocomplete':'off'})
|
|
|
|
source = StringField('Source', render_kw=dict(placeholder='Source URL', autocomplete='off'))
|
|
|
|
|
|
|
|
|
|
|
|
approve = SubmitField('Approve')
|
|
|
|
approve = SubmitField('Approve')
|
|
|
|
|
|
|
|
|
|
|
|
class TagForm(EditForm):
|
|
|
|
class TagForm(EditForm):
|
|
|
|
content = StringField('Content', validators=[validate_create_required], render_kw={'autocomplete':'off'})
|
|
|
|
content = StringField('Content', validators=[validate_create_required], render_kw=dict(autocomplete='off'))
|
|
|
|
category = SelectField('Category',
|
|
|
|
category = SelectField('Category',
|
|
|
|
choices=[(e.name, e.name.capitalize()) for e in TAG_CATEGORY],
|
|
|
|
choices=[(e.name, e.name.capitalize()) for e in TAG_CATEGORY],
|
|
|
|
validators=[optional()])
|
|
|
|
validators=[optional()])
|
|
|
@ -166,7 +166,7 @@ class TagForm(EditForm):
|
|
|
|
# Creation/editing only through post page
|
|
|
|
# Creation/editing only through post page
|
|
|
|
class CommentForm(EditForm):
|
|
|
|
class CommentForm(EditForm):
|
|
|
|
post_id = HiddenField(validators=[validate_create_required])
|
|
|
|
post_id = HiddenField(validators=[validate_create_required])
|
|
|
|
content = TextAreaField('Comment', render_kw={'autocomplete':'off'})
|
|
|
|
content = TextAreaField('Comment', render_kw=dict(autocomplete='off'))
|
|
|
|
|
|
|
|
|
|
|
|
def validate_content(form, field):
|
|
|
|
def validate_content(form, field):
|
|
|
|
if (form.create.data or form.edit.data) and not field.data:
|
|
|
|
if (form.create.data or form.edit.data) and not field.data:
|
|
|
|