mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 08:16:51 -04:00
Differentiate between different kinds of uploads
Knowing what kind of upload a thing is is useful. And the information that is useful to show about each upload depends on what kind of upload it is.
This commit is contained in:
@@ -49,6 +49,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.big-number-label {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.template-statistics-table {
|
||||
|
||||
@@ -56,6 +56,18 @@
|
||||
margin-top: -10px;
|
||||
}
|
||||
|
||||
&-filename-large {
|
||||
@include bold-24;
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
padding-bottom: 30px;
|
||||
padding-top: 10px;
|
||||
margin-bottom: -30px;
|
||||
margin-top: -10px;
|
||||
}
|
||||
|
||||
&-filename-unlinked {
|
||||
@include core-19;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ class Job(JSONModel):
|
||||
'notification_count',
|
||||
'created_by',
|
||||
'template_type',
|
||||
'recipient',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
@@ -57,6 +58,10 @@ class Job(JSONModel):
|
||||
def upload_type(self):
|
||||
return self._dict.get('upload_type')
|
||||
|
||||
@property
|
||||
def pdf_letter(self):
|
||||
return self.upload_type == 'letter'
|
||||
|
||||
@property
|
||||
def processing_started(self):
|
||||
if not self._dict.get('processing_started'):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{% from "components/table.html" import list_table, field, right_aligned_field_heading, row_heading %}
|
||||
{% from "components/big-number.html" import big_number -%}
|
||||
{% from "components/message-count-label.html" import message_count_label -%}
|
||||
|
||||
<div class='dashboard-table ajax-block-container'>
|
||||
{% call(item, row_number) list_table(
|
||||
@@ -11,37 +12,79 @@
|
||||
),
|
||||
field_headings=[
|
||||
'File',
|
||||
'Sending',
|
||||
'Delivered',
|
||||
'Failed'
|
||||
'Status'
|
||||
],
|
||||
field_headings_visible=True if jobs else False
|
||||
field_headings_visible=False
|
||||
) %}
|
||||
{% call row_heading() %}
|
||||
<div class="file-list">
|
||||
{% if item.upload_type == 'letter' %}
|
||||
<a class="file-list-filename govuk-link govuk-link--no-visited-state" href="{{ url_for('.view_notification', service_id=current_service.id, notification_id=item.id) }}">{{ item.original_file_name }}</a>
|
||||
<a class="file-list-filename-large govuk-link govuk-link--no-visited-state" href="{{ url_for('.view_notification', service_id=current_service.id, notification_id=item.id) }}">{{ item.original_file_name }}</a>
|
||||
{% else %}
|
||||
<a class="file-list-filename govuk-link govuk-link--no-visited-state" href="{{ url_for('.view_job', service_id=current_service.id, job_id=item.id) }}">{{ item.original_file_name }}</a>
|
||||
<a class="file-list-filename-large govuk-link govuk-link--no-visited-state" href="{{ url_for('.view_job', service_id=current_service.id, job_id=item.id) }}">{{ item.original_file_name }}</a>
|
||||
{% endif %}
|
||||
<span class="file-list-hint">
|
||||
Sent {{
|
||||
(item.scheduled_for or item.created_at)|format_datetime_relative
|
||||
}}
|
||||
</span>
|
||||
{% if item.scheduled %}
|
||||
<span class="file-list-hint">
|
||||
Sending {{
|
||||
item.scheduled_for|format_datetime_relative
|
||||
}}
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="file-list-hint">
|
||||
Sent {{
|
||||
(item.scheduled_for or item.created_at)|format_datetime_relative
|
||||
}}
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{% endcall %}
|
||||
{% call field() %}
|
||||
{{ big_number(
|
||||
item.notifications_sending,
|
||||
smallest=True
|
||||
) }}
|
||||
{% endcall %}
|
||||
{% call field() %}
|
||||
{{ big_number(item.notifications_delivered, smallest=True) }}
|
||||
{% endcall %}
|
||||
{% call field(status='error' if item.high_failure_rate else '') %}
|
||||
{{ big_number(item.notifications_failed, smallest=True) }}
|
||||
{% if item.scheduled %}
|
||||
{{ big_number(
|
||||
item.notification_count,
|
||||
smallest=True,
|
||||
label=message_count_label(
|
||||
item.notification_count,
|
||||
item.template_type,
|
||||
suffix='waiting to send'
|
||||
)
|
||||
) }}
|
||||
{% elif item.template_type == 'letter' %}
|
||||
{{ big_number(
|
||||
item.notification_count,
|
||||
smallest=True,
|
||||
label=message_count_label(
|
||||
item.notification_count,
|
||||
item.template_type,
|
||||
suffix=''
|
||||
)
|
||||
) }}
|
||||
{% elif item.pdf_letter %}
|
||||
<p class="govuk-body govuk-!-margin-bottom-1">
|
||||
{% for line in item.recipient.split(',') %}
|
||||
{% if loop.index < 3 %}
|
||||
{{ line }}<br>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% else %}
|
||||
<div class="grid-row">
|
||||
<div class="column-one-third">
|
||||
{{ big_number(
|
||||
item.notifications_sending,
|
||||
smallest=True,
|
||||
label='sending',
|
||||
) }}
|
||||
</div>
|
||||
<div class="column-one-third">
|
||||
{{ big_number(item.notifications_delivered, smallest=True, label='delivered') }}
|
||||
</div>
|
||||
<div class="column-one-third">
|
||||
{{ big_number(item.notifications_failed, smallest=True, label='failed') }}
|
||||
</div></div>
|
||||
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% endcall %}
|
||||
</div>
|
||||
|
||||
@@ -937,8 +937,11 @@ def test_should_show_recent_jobs_on_dashboard(
|
||||
)):
|
||||
assert filename in table_rows[index].find_all('th')[0].text
|
||||
assert 'Sent today at 11:09' in table_rows[index].find_all('th')[0].text
|
||||
for column_index, count in enumerate((1, 0, 0)):
|
||||
assert table_rows[index].find_all('td')[column_index].text.strip() == str(count)
|
||||
assert normalize_spaces(
|
||||
table_rows[index].select_one('td').text
|
||||
) == (
|
||||
'1 sending 0 delivered 0 failed'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('extra_permissions', (
|
||||
|
||||
@@ -21,23 +21,23 @@ from tests.conftest import (
|
||||
@pytest.mark.parametrize('user, expected_rows', [
|
||||
(create_active_user_with_permissions(), (
|
||||
(
|
||||
'File Sending Delivered Failed'
|
||||
'File Status'
|
||||
),
|
||||
(
|
||||
'export 1/1/2016.xls '
|
||||
'Sent today at 12:12pm 1 0 0'
|
||||
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
|
||||
),
|
||||
(
|
||||
'all email addresses.xlsx '
|
||||
'Sent today at 12:12pm 1 0 0'
|
||||
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
|
||||
),
|
||||
(
|
||||
'applicants.ods '
|
||||
'Sent today at 12:12pm 1 0 0'
|
||||
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
|
||||
),
|
||||
(
|
||||
'thisisatest.csv '
|
||||
'Sent today at 12:12pm 1 0 0'
|
||||
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
|
||||
),
|
||||
)),
|
||||
(create_active_caseworking_user(), (
|
||||
@@ -53,23 +53,23 @@ from tests.conftest import (
|
||||
'Sending 1 January 2016 at 11:09pm 1'
|
||||
),
|
||||
(
|
||||
'File Sending Delivered Failed'
|
||||
'File Status'
|
||||
),
|
||||
(
|
||||
'export 1/1/2016.xls '
|
||||
'Sent today at 12:12pm 1 0 0'
|
||||
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
|
||||
),
|
||||
(
|
||||
'all email addresses.xlsx '
|
||||
'Sent today at 12:12pm 1 0 0'
|
||||
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
|
||||
),
|
||||
(
|
||||
'applicants.ods '
|
||||
'Sent today at 12:12pm 1 0 0'
|
||||
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
|
||||
),
|
||||
(
|
||||
'thisisatest.csv '
|
||||
'Sent today at 12:12pm 1 0 0'
|
||||
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
|
||||
),
|
||||
)),
|
||||
])
|
||||
@@ -123,23 +123,23 @@ def test_jobs_page_doesnt_show_scheduled_on_page_2(
|
||||
|
||||
for index, row in enumerate((
|
||||
(
|
||||
'File Sending Delivered Failed'
|
||||
'File Status'
|
||||
),
|
||||
(
|
||||
'export 1/1/2016.xls '
|
||||
'Sent today at 12:12pm 1 0 0'
|
||||
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
|
||||
),
|
||||
(
|
||||
'all email addresses.xlsx '
|
||||
'Sent today at 12:12pm 1 0 0'
|
||||
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
|
||||
),
|
||||
(
|
||||
'applicants.ods '
|
||||
'Sent today at 12:12pm 1 0 0'
|
||||
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
|
||||
),
|
||||
(
|
||||
'thisisatest.csv '
|
||||
'Sent today at 12:12pm 1 0 0'
|
||||
'Sent today at 12:12pm 1 sending 0 delivered 0 failed'
|
||||
),
|
||||
)):
|
||||
assert normalize_spaces(page.select('tr')[index].text) == row
|
||||
|
||||
@@ -77,11 +77,11 @@ def test_get_upload_hub_page(
|
||||
)
|
||||
|
||||
assert page.find_all(
|
||||
'a', {'class': 'file-list-filename'}
|
||||
'a', {'class': 'file-list-filename-large'}
|
||||
)[0].attrs['href'] == '/services/{}/jobs/job_id_1'.format(SERVICE_ONE_ID)
|
||||
|
||||
assert page.find_all(
|
||||
'a', {'class': 'file-list-filename'}
|
||||
'a', {'class': 'file-list-filename-large'}
|
||||
)[1].attrs['href'] == '/services/{}/notification/letter_id_1'.format(SERVICE_ONE_ID)
|
||||
|
||||
|
||||
@@ -643,15 +643,17 @@ def test_uploads_page_shows_scheduled_jobs(
|
||||
normalize_spaces(row.text) for row in page.select('tr')
|
||||
] == [
|
||||
(
|
||||
'File Sending Delivered Failed'
|
||||
'File Status'
|
||||
),
|
||||
(
|
||||
'send_me_later.csv '
|
||||
'Sent 1 January 2016 at 11:09am 0 0 0'
|
||||
'Sending 1 January 2016 at 11:09am '
|
||||
'1 text message waiting to send'
|
||||
),
|
||||
(
|
||||
'even_later.csv '
|
||||
'Sent 1 January 2016 at 11:09pm 0 0 0'
|
||||
'Sending 1 January 2016 at 11:09pm '
|
||||
'1 text message waiting to send'
|
||||
),
|
||||
]
|
||||
assert not page.select('.table-empty-message')
|
||||
|
||||
@@ -1781,13 +1781,22 @@ def mock_get_uploads(mocker, api_user_active):
|
||||
'notification_count': 10,
|
||||
'created_at': '2016-01-01 11:09:00.061258',
|
||||
'statistics': [{'count': 8, 'status': 'delivered'}, {'count': 2, 'status': 'temporary-failure'}],
|
||||
'upload_type': 'job'},
|
||||
'upload_type': 'job',
|
||||
'template_type': 'sms',
|
||||
'recipient': None},
|
||||
{'id': 'letter_id_1',
|
||||
'original_file_name': 'some.pdf',
|
||||
'notification_count': 1,
|
||||
'created_at': '2016-01-01 11:09:00.061258',
|
||||
'statistics': [{'count': 1, 'status': 'delivered'}],
|
||||
'upload_type': 'letter'}
|
||||
'upload_type': 'letter',
|
||||
'template_type': None,
|
||||
'recipient': (
|
||||
'Firstname Lastname\n'
|
||||
'123 Example Street\n'
|
||||
'City of Town\n'
|
||||
'XM4 5QQ'
|
||||
)}
|
||||
]
|
||||
return {
|
||||
'data': uploads,
|
||||
|
||||
Reference in New Issue
Block a user