added manager user type
This commit is contained in:
6
forms.py
6
forms.py
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user