added manager user type

This commit is contained in:
2025-06-05 14:43:06 +02:00
parent 164e8373a4
commit 33f6e0386b
24 changed files with 226 additions and 128 deletions

View File

@@ -14,6 +14,7 @@ class UserForm(FlaskForm):
position = StringField('Position (Optional)', validators=[Optional(), Length(max=100)])
notes = TextAreaField('Notes (Optional)', validators=[Optional()])
is_admin = BooleanField('Admin Role', default=False)
is_manager = BooleanField('Manager Role', default=False)
new_password = PasswordField('New Password (Optional)')
confirm_password = PasswordField('Confirm Password (Optional)')
profile_picture = FileField('Profile Picture (Optional)', validators=[FileAllowed(['jpg', 'jpeg', 'png', 'gif'], 'Images only!')])
@@ -30,6 +31,11 @@ class UserForm(FlaskForm):
if total_admins <= 1:
raise ValidationError('There must be at least one admin user in the system.')
def validate_is_manager(self, field):
# Prevent setting both admin and manager roles
if field.data and self.is_admin.data:
raise ValidationError('A user cannot be both an admin and a manager.')
def validate(self, extra_validators=None):
rv = super().validate(extra_validators=extra_validators)
if not rv: