05/06 Modify Director's can NOT change user role, Inspector can view own reports 2

This commit is contained in:
2026-05-06 12:14:46 -04:00
parent 7d7b4aafa8
commit c2d63b61a3
2 changed files with 503 additions and 292 deletions
+6 -1
View File
@@ -56,7 +56,12 @@ class UserForm(FlaskForm):
('inspector', 'Inspector'),
('project_manager', 'Project Manager'),
# 'customer' is intentionally excluded — customer accounts are managed via /customers
], validators=[DataRequired()])
], validators=[Optional()])
# NOTE: Optional() here because directors submit no role value (the field is
# hidden in user_form.html for them). Role enforcement is handled in the
# route: directors always keep/default to 'inspector'; only admins may set
# an arbitrary role. DataRequired() would cause validate_on_submit() to
# fail silently for directors, preventing any save at all.
def __init__(self, user=None, *args, **kwargs):
super().__init__(*args, **kwargs)