Update profile page with avatar

This commit is contained in:
Inga Kirschnick
2022-12-05 09:40:02 +01:00
parent 620d9d1ea2
commit be517a04af
10 changed files with 160 additions and 155 deletions

View File

@ -47,79 +47,6 @@ class ChangePasswordForm(FlaskForm):
if not self.user.verify_password(field.data):
raise ValidationError('Invalid password')
class EditProfileSettingsForm(FlaskForm):
user_avatar = FileField(
'Image File'
)
email = StringField(
'E-Mail',
validators=[InputRequired(), Length(max=254), Email()]
)
username = StringField(
'Username',
validators=[
InputRequired(),
Length(max=64),
Regexp(
USERNAME_REGEX,
message=(
'Usernames must have only letters, numbers, dots or '
'underscores'
)
)
]
)
full_name = StringField(
'Full name',
validators=[Length(max=128)]
)
about_me = TextAreaField(
'About me',
validators=[
Length(max=254)
]
)
website = StringField(
'Website',
validators=[
Length(max=254)
]
)
organization = StringField(
'Organization',
validators=[
Length(max=128)
]
)
location = StringField(
'Location',
validators=[
Length(max=128)
]
)
submit = SubmitField()
def __init__(self, user, *args, **kwargs):
super().__init__(*args, **kwargs)
self.user = user
def validate_email(self, field):
if (field.data != self.user.email
and User.query.filter_by(email=field.data).first()):
raise ValidationError('Email already registered')
def validate_username(self, field):
if (field.data != self.user.username
and User.query.filter_by(username=field.data).first()):
raise ValidationError('Username already in use')
def validate_image_file(self, field):
if not field.data.filename.lower().endswith('.jpg' or '.png' or '.jpeg'):
raise ValidationError('only .jpg, .png and .jpeg!')
class EditNotificationSettingsForm(FlaskForm):
job_status_mail_notification_level = SelectField(
'Job status mail notification level',
@ -136,7 +63,14 @@ class EditNotificationSettingsForm(FlaskForm):
]
class EditPrivacySettingsForm(FlaskForm):
public_profile = BooleanField(
'Public profile'
private_profile = BooleanField(
'Private profile'
)
private_email = BooleanField(
'Private email'
)
only_username = BooleanField(
'Show only username'
)
submit = SubmitField()