mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -04:00
Download CSV option now available.
App is updated to use the rebased db.
This commit is contained in:
@@ -38,7 +38,7 @@ def add_service():
|
||||
email_from = email_safe(form.name.data)
|
||||
service_id = service_api_client.create_service(service_name=form.name.data,
|
||||
active=False,
|
||||
limit=current_app.config['DEFAULT_SERVICE_LIMIT'],
|
||||
message_limit=current_app.config['DEFAULT_SERVICE_LIMIT'],
|
||||
restricted=True,
|
||||
user_id=session['user_id'],
|
||||
email_from=email_from)
|
||||
|
||||
@@ -39,7 +39,7 @@ def create_api_key(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/api-keys/revoke/<int:key_id>", methods=['GET', 'POST'])
|
||||
@main.route("/services/<service_id>/api-keys/revoke/<key_id>", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions('manage_api_keys')
|
||||
def revoke_api_key(service_id, key_id):
|
||||
|
||||
@@ -77,11 +77,11 @@ def add_rates_to(delivery_statistics):
|
||||
|
||||
latest_stats.update({
|
||||
'emails_failure_rate': (
|
||||
"{0:.1f}".format((float(today['emails_error']) / today['emails_requested'] * 100))
|
||||
"{0:.1f}".format((float(today['emails_failed']) / today['emails_requested'] * 100))
|
||||
if today and today['emails_requested'] else 0
|
||||
),
|
||||
'sms_failure_rate': (
|
||||
"{0:.1f}".format((float(today['sms_error']) / today['sms_requested'] * 100))
|
||||
"{0:.1f}".format((float(today['sms_failed']) / today['sms_requested'] * 100))
|
||||
if today and today['sms_requested'] else 0
|
||||
)
|
||||
})
|
||||
|
||||
@@ -21,7 +21,8 @@ from app.main import main
|
||||
from app.utils import (
|
||||
get_page_from_request,
|
||||
generate_previous_next_dict,
|
||||
user_has_permissions)
|
||||
user_has_permissions,
|
||||
generate_notifications_csv)
|
||||
|
||||
|
||||
def _parse_filter_args(filter_dict):
|
||||
@@ -132,6 +133,12 @@ def view_notifications(service_id):
|
||||
page + 1,
|
||||
'Next page',
|
||||
'page {}'.format(page + 1))
|
||||
if 'download' in request.args and request.args['download'] == 'csv':
|
||||
csv_content = generate_notifications_csv(notifications['notifications'])
|
||||
return csv_content, 200, {
|
||||
'Content-Type': 'text/csv; charset=utf-8',
|
||||
'Content-Disposition': 'inline; filename="notifications.csv"'
|
||||
}
|
||||
return render_template(
|
||||
'views/notifications.html',
|
||||
notifications=notifications['notifications'],
|
||||
|
||||
@@ -92,7 +92,7 @@ def choose_template(service_id, template_type):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/send/<int:template_id>", methods=['GET', 'POST'])
|
||||
@main.route("/services/<service_id>/send/<template_id>/csv", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions('send_texts', 'send_emails', 'send_letters')
|
||||
def send_messages(service_id, template_id):
|
||||
|
||||
@@ -61,7 +61,7 @@ def service_name_change_confirm(service_id):
|
||||
current_service['id'],
|
||||
current_service['name'],
|
||||
current_service['active'],
|
||||
current_service['limit'],
|
||||
current_service['message_limit'],
|
||||
current_service['restricted'],
|
||||
current_service['users'],
|
||||
current_service['email_from'])
|
||||
@@ -123,7 +123,7 @@ def service_status_change_confirm(service_id):
|
||||
current_service['id'],
|
||||
current_service['name'],
|
||||
current_service['active'],
|
||||
current_service['limit'],
|
||||
current_service['message_limit'],
|
||||
current_service['restricted'],
|
||||
current_service['users'],
|
||||
current_service['email_from'])
|
||||
|
||||
@@ -48,7 +48,7 @@ def add_service_template(service_id, template_type):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/templates/<int:template_id>", methods=['GET', 'POST'])
|
||||
@main.route("/services/<service_id>/templates/<template_id>", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions('manage_templates', admin_override=True)
|
||||
def edit_service_template(service_id, template_id):
|
||||
@@ -76,7 +76,7 @@ def edit_service_template(service_id, template_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/templates/<int:template_id>/delete", methods=['GET', 'POST'])
|
||||
@main.route("/services/<service_id>/templates/<template_id>/delete", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions('manage_templates', admin_override=True)
|
||||
def delete_service_template(service_id, template_id):
|
||||
|
||||
Reference in New Issue
Block a user