mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Merge pull request #2151 from alphagov/add-basic-preview
Add a preview of basic view
This commit is contained in:
@@ -14,6 +14,29 @@
|
||||
margin: 0 0 0 0;
|
||||
}
|
||||
|
||||
&-basic-view {
|
||||
|
||||
&-preview {
|
||||
@include bold-16;
|
||||
display: inline-block;
|
||||
background: $yellow;
|
||||
padding: 4px 10px 3px 10px;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
margin-left: 8px;
|
||||
margin-top: -1px;
|
||||
margin-bottom: -7px;
|
||||
}
|
||||
|
||||
&-back-link {
|
||||
@include core-16;
|
||||
display: inline-block;
|
||||
font-weight: normal;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
&-switch {
|
||||
|
||||
@include core-16;
|
||||
|
||||
@@ -630,8 +630,15 @@ def service_set_auth_type(service_id):
|
||||
|
||||
@main.route("/services/<service_id>/service-settings/set-basic-view", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions('manage_service')
|
||||
@user_has_permissions('manage_service', 'send_messages')
|
||||
def service_set_basic_view(service_id):
|
||||
|
||||
if current_user.previewing_basic_view:
|
||||
session.pop('basic', None)
|
||||
|
||||
if not current_user.has_permissions('manage_service'):
|
||||
abort(403)
|
||||
|
||||
form = ServiceBasicViewForm(
|
||||
enabled='caseworking' in current_service['permissions']
|
||||
)
|
||||
@@ -650,6 +657,14 @@ def service_set_basic_view(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/preview-basic-view")
|
||||
@login_required
|
||||
@user_has_permissions('manage_service')
|
||||
def preview_basic_view(service_id):
|
||||
session['basic'] = True
|
||||
return redirect(url_for('.service_dashboard', service_id=service_id))
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/service-settings/letter-contacts", methods=['GET'])
|
||||
@login_required
|
||||
@user_has_permissions('manage_service', 'manage_api_keys')
|
||||
|
||||
@@ -172,6 +172,7 @@ class HeaderNavigation(Navigation):
|
||||
'old_using_notify',
|
||||
'organisation_dashboard',
|
||||
'organisation_settings',
|
||||
'preview_basic_view',
|
||||
'privacy',
|
||||
'public_agreement',
|
||||
'public_download_agreement',
|
||||
@@ -426,6 +427,7 @@ class MainNavigation(Navigation):
|
||||
'platform_admin',
|
||||
'platform_admin_new',
|
||||
'platform_admin_list_complaints',
|
||||
'preview_basic_view',
|
||||
'pricing',
|
||||
'privacy',
|
||||
'public_agreement',
|
||||
@@ -599,6 +601,7 @@ class CaseworkNavigation(Navigation):
|
||||
'platform_admin',
|
||||
'platform_admin_new',
|
||||
'platform_admin_list_complaints',
|
||||
'preview_basic_view',
|
||||
'pricing',
|
||||
'privacy',
|
||||
'public_agreement',
|
||||
@@ -817,6 +820,7 @@ class OrgNavigation(Navigation):
|
||||
'platform_admin',
|
||||
'platform_admin_new',
|
||||
'platform_admin_list_complaints',
|
||||
'preview_basic_view',
|
||||
'pricing',
|
||||
'privacy',
|
||||
'public_agreement',
|
||||
|
||||
@@ -76,7 +76,6 @@ class User(UserMixin):
|
||||
between on the front end. So lets collapse them into "send_messages" and "manage_service". If we want to split
|
||||
them out later, we'll need to rework this function.
|
||||
"""
|
||||
|
||||
self._permissions = {
|
||||
service: translate_permissions_from_db_to_admin_roles(permissions)
|
||||
for service, permissions
|
||||
@@ -109,6 +108,10 @@ class User(UserMixin):
|
||||
def permissions(self, permissions):
|
||||
raise AttributeError("Read only property")
|
||||
|
||||
@property
|
||||
def previewing_basic_view(self):
|
||||
return bool(session.get('basic'))
|
||||
|
||||
def has_permissions(self, *permissions, restrict_admin_usage=False):
|
||||
unknown_permissions = set(permissions) - all_permissions
|
||||
|
||||
@@ -119,6 +122,9 @@ class User(UserMixin):
|
||||
service_id = _get_service_id_from_view_args()
|
||||
org_id = _get_org_id_from_view_args()
|
||||
|
||||
if self.previewing_basic_view:
|
||||
return self._permissions.get(service_id) and 'send_messages' in permissions
|
||||
|
||||
if not service_id and not org_id:
|
||||
# we shouldn't have any pages that require permissions, but don't specify a service or organisation.
|
||||
# use @user_is_platform_admin for platform admin only pages
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "withoutnav_template.html" %}
|
||||
{% block per_page_title %}Forbidden{% endblock %}
|
||||
{% block per_page_title %}403{% endblock %}
|
||||
{% block maincolumn_content %}
|
||||
<div class="grid-row">
|
||||
<div class="column-two-thirds">
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
<p>
|
||||
You’ll get to choose which team members have basic view.
|
||||
</p>
|
||||
<p>
|
||||
<a href="{{ url_for('main.preview_basic_view', service_id=current_service.id) }}">See a preview of basic view</a>.
|
||||
</p>
|
||||
{{ radios(form.enabled, hide_legend=True) }}
|
||||
{{ page_footer(
|
||||
'Save',
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
<div class="navigation-service">
|
||||
<div class="navigation-service-name">
|
||||
{{ current_service.name }}
|
||||
{% if current_user.previewing_basic_view %}
|
||||
<span class="navigation-service-basic-view-preview">Preview of basic view</span>
|
||||
<a class="navigation-service-basic-view-back-link" href="{{ url_for('main.service_set_basic_view', service_id=current_service.id)}}">Back to settings</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<a href="{{ url_for('main.choose_account') }}" class="navigation-service-switch">Switch service</a>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user