mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
Add a ‘See dashboard’ permission
Our research and prototyping around ‘basic view’ found that: - a lot of users who send messages rarely or never look at the dashboard (yet it’s the first page they see when they sign in) - team managers like the idea of taking away things that users don’t need in order to make the interface simpler We’ve disentangled the simpler way of sending messages from being part of ‘basic view’. This means we can give managers the option of taking away the dashboard as an independent choice, not something that’s wrapped up in a separate ‘view’. I think that this checkbox is a more straightforward proposition than ‘basic view’ ever was (despite all the work we did to explain it and develop the nested checkbox pattern). In research users would often explain the feature back to us as being about hiding the dashboard – we should try to make Notify operate in terms of concepts that come naturally to people wherever possible.
This commit is contained in:
@@ -256,13 +256,13 @@ class RegisterUserFromOrgInviteForm(StripWhitespaceForm):
|
||||
auth_type = HiddenField('auth_type', validators=[DataRequired()])
|
||||
|
||||
|
||||
class AbstractPermissionsForm(StripWhitespaceForm):
|
||||
class PermissionsForm(StripWhitespaceForm):
|
||||
|
||||
view_activity = HiddenField("View activity")
|
||||
send_messages = BooleanField("Send messages from existing templates")
|
||||
view_activity = BooleanField("See dashboard and reports")
|
||||
send_messages = BooleanField("Send messages")
|
||||
manage_templates = BooleanField("Add and edit templates")
|
||||
manage_service = BooleanField("Manage this service and its team")
|
||||
manage_api_keys = BooleanField("Create and revoke API keys")
|
||||
manage_api_keys = BooleanField("Manage API keys")
|
||||
|
||||
login_authentication = RadioField(
|
||||
'Sign in using',
|
||||
@@ -277,38 +277,18 @@ class AbstractPermissionsForm(StripWhitespaceForm):
|
||||
def permissions(self):
|
||||
return {role for role in roles.keys() if self[role].data is True}
|
||||
|
||||
|
||||
class AdminPermissionsForm(AbstractPermissionsForm):
|
||||
|
||||
def process(self, *args, **kwargs):
|
||||
super().process(*args, **kwargs)
|
||||
# view_activity is a default role to be added to all users.
|
||||
self.view_activity.data = True
|
||||
@classmethod
|
||||
def from_user(cls, user, service_id):
|
||||
return cls(
|
||||
**{
|
||||
role: user.has_permission_for_service(service_id, role)
|
||||
for role in roles.keys()
|
||||
},
|
||||
login_authentication=user.auth_type
|
||||
)
|
||||
|
||||
|
||||
class CaseworkingPermissionsForm(AbstractPermissionsForm):
|
||||
|
||||
def process(self, *args, **kwargs):
|
||||
super().process(*args, **kwargs)
|
||||
if self.user_type.data == 'admin':
|
||||
self.view_activity.data = True
|
||||
elif self.user_type.data == 'caseworker':
|
||||
self.view_activity.data = False
|
||||
self.manage_templates.data = False
|
||||
self.manage_service.data = False
|
||||
self.manage_api_keys.data = False
|
||||
self.send_messages.data = True
|
||||
|
||||
user_type = RadioField(
|
||||
'User type',
|
||||
choices=[
|
||||
('caseworker', 'Basic view'),
|
||||
('admin', 'Admin view'),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class AbstractInviteUserForm(StripWhitespaceForm):
|
||||
class InviteUserForm(PermissionsForm):
|
||||
email_address = email_address(gov_user=False)
|
||||
|
||||
def __init__(self, invalid_email_address, *args, **kwargs):
|
||||
@@ -320,14 +300,6 @@ class AbstractInviteUserForm(StripWhitespaceForm):
|
||||
raise ValidationError("You can’t send an invitation to yourself")
|
||||
|
||||
|
||||
class AdminInviteUserForm(AbstractInviteUserForm, AdminPermissionsForm):
|
||||
pass
|
||||
|
||||
|
||||
class CaseworkingInviteUserForm(AbstractInviteUserForm, CaseworkingPermissionsForm):
|
||||
pass
|
||||
|
||||
|
||||
class InviteOrgUserForm(StripWhitespaceForm):
|
||||
email_address = email_address(gov_user=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user