mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
Clean up code to remove unnecessary paths.
Status code was overcomplex, given how we control the inputs. Now, it expects a single value, rather than a comma separated list, and if you give something it doesn't expect it just returns all. Note, it won't select the correct box - but if you've been manually editing the URL that's your own problem ¯\_(ツ)_/¯ Also, as this page will only ever be shown from the tour (tutorial), it doesn't need some non-help things - such as the download csv button and associated endpoint.
This commit is contained in:
@@ -4,14 +4,6 @@
|
|||||||
<div class="ajax-block-container" aria-labelledby='pill-selected-item'>
|
<div class="ajax-block-container" aria-labelledby='pill-selected-item'>
|
||||||
<div class="dashboard-table bottom-gutter-3-2">
|
<div class="dashboard-table bottom-gutter-3-2">
|
||||||
|
|
||||||
{% if not help %}
|
|
||||||
<p class="bottom-gutter">
|
|
||||||
<a href="{{ download_link }}" download="download" class="heading-small">Download this report</a>
|
|
||||||
 
|
|
||||||
<span id="time-left">{{ time_left }}</span>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% call(item, row_number) list_table(
|
{% call(item, row_number) list_table(
|
||||||
[notification],
|
[notification],
|
||||||
caption=None,
|
caption=None,
|
||||||
|
|||||||
17
app/utils.py
17
app/utils.py
@@ -155,23 +155,6 @@ def generate_notifications_csv(**kwargs):
|
|||||||
raise Exception("Should never reach here")
|
raise Exception("Should never reach here")
|
||||||
|
|
||||||
|
|
||||||
def generate_single_notification_csv(notification):
|
|
||||||
fieldnames = ['Recipient', 'Template', 'Type', 'Status', 'Time']
|
|
||||||
yield ','.join(fieldnames) + '\n'
|
|
||||||
|
|
||||||
values = [
|
|
||||||
notification['to'],
|
|
||||||
notification['template']['name'],
|
|
||||||
notification['template']['template_type'],
|
|
||||||
notification['status'],
|
|
||||||
notification['created_at']
|
|
||||||
]
|
|
||||||
line = ','.join(str(i) for i in values) + '\n'
|
|
||||||
yield line
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def get_page_from_request():
|
def get_page_from_request():
|
||||||
if 'page' in request.args:
|
if 'page' in request.args:
|
||||||
try:
|
try:
|
||||||
|
|||||||
28
tests/app/main/views/test_notifications.py
Normal file
28
tests/app/main/views/test_notifications.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
from freezegun import freeze_time
|
||||||
|
import pytest
|
||||||
|
from werkzeug.datastructures import MultiDict
|
||||||
|
|
||||||
|
from app.main.views.notifications import get_status_arg
|
||||||
|
from app.utils import (
|
||||||
|
REQUESTED_STATUSES,
|
||||||
|
FAILURE_STATUSES,
|
||||||
|
SENDING_STATUSES,
|
||||||
|
DELIVERED_STATUSES,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('multidict_args, expected_statuses', [
|
||||||
|
([], REQUESTED_STATUSES),
|
||||||
|
([('status', '')], REQUESTED_STATUSES),
|
||||||
|
([('status', 'garbage')], REQUESTED_STATUSES),
|
||||||
|
([('status', 'sending')], SENDING_STATUSES),
|
||||||
|
([('status', 'delivered')], DELIVERED_STATUSES),
|
||||||
|
([('status', 'failed')], FAILURE_STATUSES),
|
||||||
|
])
|
||||||
|
def test_status_filters(mocker, multidict_args, expected_statuses):
|
||||||
|
mocker.patch('app.main.views.notifications.current_app')
|
||||||
|
|
||||||
|
args = MultiDict(multidict_args)
|
||||||
|
args['status'] = get_status_arg(args)
|
||||||
|
|
||||||
|
assert sorted(args['status']) == sorted(expected_statuses)
|
||||||
Reference in New Issue
Block a user