Encapsulate view_activity logic within the form

This means that:
- we don’t have to manually set it after processing the form
- we can set it dynamically based on some other attribute later on
This commit is contained in:
Chris Hill-Scott
2018-06-12 11:44:34 +01:00
parent 650f4cc3d8
commit a220ab7877
3 changed files with 14 additions and 19 deletions

View File

@@ -147,9 +147,4 @@ def cancel_invited_user(service_id, invited_user_id):
def get_permissions_from_form(form):
# view_activity is a default role to be added to all users.
# All users will have at minimum view_activity to allow users to see notifications,
# templates, team members but no update privileges
selected_roles = {role for role in roles.keys() if form[role].data is True}
selected_roles.add('view_activity')
return selected_roles
return {role for role in roles.keys() if form[role].data is True}