mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-16 20:49:00 -04:00
Let caseworkers send one off messages
The main task that we think ‘caseworker’ users do is send one off messages. So this commit: - makes sure users who don’t have the `view_activity` permission (ie not ‘admin’ users) can still send messages - adds navigation so that these users have a place to go from which to start the process of sending a one off message
This commit is contained in:
@@ -42,7 +42,7 @@ from app.utils import (
|
||||
|
||||
@main.route("/services/<service_id>/notification/<uuid:notification_id>")
|
||||
@login_required
|
||||
@user_has_permissions('view_activity')
|
||||
@user_has_permissions('view_activity', 'send_messages')
|
||||
def view_notification(service_id, notification_id):
|
||||
notification = notification_api_client.get_notification(service_id, str(notification_id))
|
||||
notification['template'].update({'reply_to_text': notification['reply_to_text']})
|
||||
@@ -126,7 +126,7 @@ def view_letter_notification_as_preview(service_id, notification_id, filetype):
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/notification/<notification_id>.json")
|
||||
@user_has_permissions('view_activity')
|
||||
@user_has_permissions('view_activity', 'send_messages')
|
||||
def view_notification_updates(service_id, notification_id):
|
||||
return jsonify(**get_single_notification_partials(
|
||||
notification_api_client.get_notification(service_id, notification_id)
|
||||
|
||||
@@ -41,8 +41,12 @@ page_headings = {
|
||||
|
||||
@main.route("/services/<service_id>/templates/<uuid:template_id>")
|
||||
@login_required
|
||||
@user_has_permissions('view_activity')
|
||||
@user_has_permissions('view_activity', 'send_messages')
|
||||
def view_template(service_id, template_id):
|
||||
if not current_user.has_permissions('view_activity'):
|
||||
return redirect(url_for(
|
||||
'.send_one_off', service_id=service_id, template_id=template_id
|
||||
))
|
||||
template = service_api_client.get_service_template(service_id, str(template_id))['data']
|
||||
if template["template_type"] == "letter":
|
||||
letter_contact_details = service_api_client.get_letter_contacts(service_id)
|
||||
@@ -94,7 +98,7 @@ def start_tour(service_id, template_id):
|
||||
@main.route("/services/<service_id>/templates")
|
||||
@main.route("/services/<service_id>/templates/<template_type>")
|
||||
@login_required
|
||||
@user_has_permissions('view_activity')
|
||||
@user_has_permissions('view_activity', 'send_messages')
|
||||
def choose_template(service_id, template_type='all'):
|
||||
templates = service_api_client.get_service_templates(service_id)['data']
|
||||
|
||||
@@ -117,8 +121,14 @@ def choose_template(service_id, template_type='all'):
|
||||
if template_type in ['all', template['template_type']]
|
||||
]
|
||||
|
||||
if current_user.has_permissions('view_activity'):
|
||||
page_title = 'Templates'
|
||||
else:
|
||||
page_title = 'Choose a template'
|
||||
|
||||
return render_template(
|
||||
'views/templates/choose.html',
|
||||
page_title=page_title,
|
||||
templates=templates_on_page,
|
||||
show_search_box=(len(templates_on_page) > 7),
|
||||
show_template_nav=has_multiple_template_types and (len(templates) > 2),
|
||||
@@ -130,7 +140,7 @@ def choose_template(service_id, template_type='all'):
|
||||
|
||||
@main.route("/services/<service_id>/templates/<template_id>.<filetype>")
|
||||
@login_required
|
||||
@user_has_permissions('view_activity')
|
||||
@user_has_permissions('view_activity', 'send_messages')
|
||||
def view_letter_template_preview(service_id, template_id, filetype):
|
||||
if filetype not in ('pdf', 'png'):
|
||||
abort(404)
|
||||
|
||||
Reference in New Issue
Block a user