Rename unclear "permissions" attributes

These are more than a list of permissions: each item includes the
label to use when displaying it as an option on a form. Switching
to a name that reflects how the attributes are used will help to
avoid confusion when we rename some of the other attributes in the
same file in later commits.
This commit is contained in:
Ben Thorner
2021-07-22 14:15:24 +01:00
parent f5580b87dc
commit a38baa0bd8
3 changed files with 17 additions and 10 deletions

View File

@@ -58,7 +58,11 @@ from app.models.feedback import PROBLEM_TICKET_TYPE, QUESTION_TICKET_TYPE
from app.models.organisation import Organisation
from app.utils import merge_jsonlike
from app.utils.user import distinct_email_addresses
from app.utils.user_permissions import broadcast_permissions, permissions, roles
from app.utils.user_permissions import (
broadcast_permission_options,
permission_options,
roles,
)
def get_time_value_and_label(future_time):
@@ -946,15 +950,15 @@ def filter_by_permissions(valuelist):
if valuelist is None:
return None
else:
return [entry for entry in valuelist if any(entry in role for role in permissions)]
return [entry for entry in valuelist if any(entry in role for role in permission_options)]
# guard against data entries that aren't a role in broadcast_permissions
# guard against data entries that aren't a role in broadcast_permission_options
def filter_by_broadcast_permissions(valuelist):
if valuelist is None:
return None
else:
return [entry for entry in valuelist if any(entry in role for role in broadcast_permissions)]
return [entry for entry in valuelist if any(entry in role for role in broadcast_permission_options)]
class BasePermissionsForm(StripWhitespaceForm):
@@ -985,7 +989,7 @@ class BasePermissionsForm(StripWhitespaceForm):
'Permissions',
filters=[filter_by_permissions],
choices=[
(value, label) for value, label in permissions
(value, label) for value, label in permission_options
],
param_extensions={
"hint": {"text": "All team members can see sent messages."}
@@ -1023,7 +1027,7 @@ class BroadcastPermissionsForm(BasePermissionsForm):
permissions_field = GovukCheckboxesField(
'Permissions',
choices=[
(value, label) for value, label in broadcast_permissions
(value, label) for value, label in broadcast_permission_options
],
filters=[filter_by_broadcast_permissions],
param_extensions={