diff --git a/yadc/forms.py b/yadc/forms.py index fa40844..854bf1a 100644 --- a/yadc/forms.py +++ b/yadc/forms.py @@ -22,15 +22,15 @@ class CSRFForm(Form): csrf_field_name = 'csrf_token' class LoginForm(CSRFForm): - username = StringField('Username', validators=[DataRequired()]) - password = PasswordField('Password', validators=[DataRequired()]) + username = StringField('Username', validators=[DataRequired()], render_kw=dict(placeholder="Username")) + password = PasswordField('Password', validators=[DataRequired()], render_kw=dict(placeholder="Password")) remember_me = BooleanField('Remember me') submit = SubmitField('Log In') from yadc.models import User 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') # def validate_email(form, field): @@ -39,10 +39,10 @@ class ResetPasswordForm(CSRFForm): # raise ValidationError('This') class RegisterForm(CSRFForm): - username = StringField('Username', validators=[DataRequired()]) - email = StringField('E-mail', validators=[DataRequired(), Email()]) - password = PasswordField('Password', validators=[DataRequired()]) - password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')]) + username = StringField('Username', validators=[DataRequired()], render_kw=dict(placeholder="Username")) + email = StringField('Email', validators=[DataRequired(), Email()], render_kw=dict(placeholder="Email")) + password = PasswordField('Password', validators=[DataRequired()], render_kw=dict(placeholder="Password")) + password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')], render_kw=dict(placeholder="Repeat password")) submit = SubmitField('Register') def validate_username(form, field): @@ -65,8 +65,8 @@ def validate_file(form, field): class UploadForm(CSRFForm): post_img = FileField('Image', validators=[validate_file], render_kw={'required':''}) - sauce = StringField('Sauce', validators=[DataRequired()], render_kw={'placeholder':'Source URL','autocomplete':'off'}) - tags = StringField('Tags', validators=[DataRequired()], render_kw={'placeholder':'Tags','autocomplete':'off'}) # CUSTOM VALIDATOR (also for Post edits) + sauce = StringField('Sauce', validators=[DataRequired()], 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) rating = RadioField('Rating', choices=[(e.name, e.name.capitalize()) for e in RATING], default=RATING.safe.name, @@ -88,14 +88,14 @@ class ChangeUserInfoForm(CSRFForm): userinfo_submit = SubmitField('Change your info') class ChangePassForm(CSRFForm): - password_current = PasswordField('Current password', validators=[DataRequired()]) - password = PasswordField('Password', validators=[DataRequired()]) - password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')]) + password_current = PasswordField('Current password', validators=[DataRequired()], render_kw=dict(placeholder="Current password")) + password = PasswordField('Password', validators=[DataRequired()], render_kw=dict(placeholder="New password")) + password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')], render_kw=dict(placeholder="Repeat password")) pass_submit = SubmitField('Change password') class ChangeMailForm(CSRFForm): - email = StringField('E-mail', validators=[DataRequired(), Email()], render_kw=dict(placeholder="E-mail")) - email_again = StringField('Repeat e-mail', validators=[DataRequired(), EqualTo('email')], render_kw=dict(placeholder="Repeat e-mail")) + email = StringField('Email', validators=[DataRequired(), Email()], render_kw=dict(placeholder="Email")) + email_again = StringField('Repeat email', validators=[DataRequired(), EqualTo('email')], render_kw=dict(placeholder="Repeat email")) mail_submit = SubmitField('Change email') class ChangeUserRatingForm(CSRFForm): @@ -106,7 +106,7 @@ class ChangeUserRatingForm(CSRFForm): rating_submit = SubmitField('Change default rating') 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()]) class DeleteUserDataForm(CSRFForm): @@ -136,8 +136,8 @@ def validate_create_required(form, field): raise ValidationError('Please fill out this field.') class UserForm(EditForm): - username = StringField('Username', validators=[validate_create_required]) - email = StringField('E-mail', validators=[optional(), Email()]) + username = StringField('Username', validators=[validate_create_required], render_kw=dict(placeholder='Username')) + email = StringField('Email', validators=[optional(), Email()], render_kw=dict(placeholder='Email')) user_status = SelectField('User status', choices=[(e.name, e.name.capitalize()) for e in USER_STATUS], validators=[optional()]) @@ -146,19 +146,19 @@ class UserForm(EditForm): validators=[optional()]) 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', choices=[(e.name, e.name.capitalize()) for e in RATING], validators=[optional()]) status = SelectField('Status', choices=[(e.name, e.name.capitalize()) for e in POST_STATUS], validators=[optional()]) - source = StringField('Source', render_kw={'autocomplete':'off'}) + source = StringField('Source', render_kw=dict(placeholder='Source URL', autocomplete='off')) approve = SubmitField('Approve') 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', choices=[(e.name, e.name.capitalize()) for e in TAG_CATEGORY], validators=[optional()]) @@ -166,7 +166,7 @@ class TagForm(EditForm): # Creation/editing only through post page class CommentForm(EditForm): 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): if (form.create.data or form.edit.data) and not field.data: diff --git a/yadc/templates/auth/login.html b/yadc/templates/auth/login.html index 288c661..bde84ba 100644 --- a/yadc/templates/auth/login.html +++ b/yadc/templates/auth/login.html @@ -6,9 +6,9 @@
{{ form.csrf_token }} - {{ form.username(placeholder="Username") }} + {{ form.username() }} - {{ form.password(placeholder="Password") }} + {{ form.password() }}