mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-04 13:41:38 -04:00
Only show inbound stuff if service has permission
Only services that have inbound SMS turned on should be able to see the dashboard and ‘Received messages’ page. There’s probably a cleaner way (decorator) of doing this permissions stuff, but I think it can wait until we ship this.
This commit is contained in:
@@ -12,6 +12,7 @@ from flask_login import login_required
|
||||
|
||||
from app.main import main
|
||||
from app import (
|
||||
current_service,
|
||||
job_api_client,
|
||||
service_api_client,
|
||||
template_statistics_client
|
||||
@@ -139,6 +140,10 @@ def monthly(service_id):
|
||||
@login_required
|
||||
@user_has_permissions('manage_settings', admin_override=True)
|
||||
def inbox(service_id):
|
||||
|
||||
if 'inbound_sms' not in current_service['permissions']:
|
||||
abort(403)
|
||||
|
||||
return render_template(
|
||||
'views/dashboard/inbox.html',
|
||||
messages=service_api_client.get_inbound_sms(service_id),
|
||||
@@ -178,7 +183,10 @@ def get_dashboard_partials(service_id):
|
||||
),
|
||||
'inbox': render_template(
|
||||
'views/dashboard/_inbox.html',
|
||||
inbound_sms_summary=service_api_client.get_inbound_sms_summary(service_id),
|
||||
inbound_sms_summary=(
|
||||
service_api_client.get_inbound_sms_summary(service_id)
|
||||
if 'inbound_sms' in current_service['permissions'] else None
|
||||
),
|
||||
),
|
||||
'totals': render_template(
|
||||
'views/dashboard/_totals.html',
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
{% from "components/big-number.html" import big_number, big_number_with_status %}
|
||||
|
||||
<div class="ajax-block">
|
||||
<div class="big-number-meta-wrapper">
|
||||
{{
|
||||
big_number_with_status(
|
||||
inbound_sms_summary.count,
|
||||
'text messages received',
|
||||
link=url_for('.inbox', service_id=current_service.id),
|
||||
show_failures=False
|
||||
)
|
||||
}}
|
||||
<div class="big-number-meta">
|
||||
{% if inbound_sms_summary.latest_message %}
|
||||
latest message {{ inbound_sms_summary.latest_message | format_delta }}
|
||||
{% endif %}
|
||||
{% if inbound_sms_summary != None %}
|
||||
<div class="big-number-meta-wrapper">
|
||||
{{
|
||||
big_number_with_status(
|
||||
inbound_sms_summary.count,
|
||||
'text messages received',
|
||||
link=url_for('.inbox', service_id=current_service.id),
|
||||
show_failures=False
|
||||
)
|
||||
}}
|
||||
<div class="big-number-meta">
|
||||
{% if inbound_sms_summary.latest_message %}
|
||||
latest message {{ inbound_sms_summary.latest_message | format_delta }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user