mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-04 05:31:44 -04:00
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:
@@ -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={
|
||||
|
||||
Reference in New Issue
Block a user