mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-14 02:09:44 -04:00
Show message on job page if job is scheduled
If a job is scheduled then we can’t show the notifications yet, and the progress report will stay at 0%. In their place we should show what time a job will start. Later on (when the API is ready) this area of the page should also show a cancel button.
This commit is contained in:
@@ -277,7 +277,7 @@ def get_status_filters(service, message_type, statistics):
|
||||
|
||||
|
||||
def _get_job_counts(job, help_argument):
|
||||
sending = 0 if job['job_status'] == 'pending' else (
|
||||
sending = 0 if job['job_status'] == 'scheduled' else (
|
||||
job.get('notification_count', 0) -
|
||||
job.get('notifications_delivered', 0) -
|
||||
job.get('notifications_failed', 0)
|
||||
@@ -324,7 +324,6 @@ def get_job_partials(job):
|
||||
return {
|
||||
'counts': render_template(
|
||||
'partials/jobs/count.html',
|
||||
job=job,
|
||||
counts=_get_job_counts(job, request.args.get('help', 0)),
|
||||
status=filter_args['status']
|
||||
),
|
||||
@@ -340,7 +339,8 @@ def get_job_partials(job):
|
||||
status=request.args.get('status')
|
||||
),
|
||||
help=get_help_argument(),
|
||||
time_left=get_time_left(job['created_at'])
|
||||
time_left=get_time_left(job['created_at']),
|
||||
job=job
|
||||
),
|
||||
'status': render_template(
|
||||
'partials/jobs/status.html',
|
||||
|
||||
@@ -1,61 +1,71 @@
|
||||
{% from "components/table.html" import list_table, field, right_aligned_field_heading, date_field, row_heading %}
|
||||
|
||||
{% if notifications %}
|
||||
<div class="dashboard-table">
|
||||
{% endif %}
|
||||
{% if job.job_status == 'scheduled' %}
|
||||
|
||||
{% if not help %}
|
||||
{% if percentage_complete < 100 %}
|
||||
<p class="bottom-gutter-1-2 hint">
|
||||
Report is {{ "{:.0f}%".format(percentage_complete) }} complete…
|
||||
</p>
|
||||
{% elif notifications %}
|
||||
<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>
|
||||
Sending will start at {{ job.scheduled_for|format_time }}
|
||||
</p>
|
||||
|
||||
{% else %}
|
||||
|
||||
{% if notifications %}
|
||||
<div class="dashboard-table">
|
||||
{% endif %}
|
||||
|
||||
{% if not help %}
|
||||
{% if percentage_complete < 100 %}
|
||||
<p class="bottom-gutter-1-2 hint">
|
||||
Report is {{ "{:.0f}%".format(percentage_complete) }} complete…
|
||||
</p>
|
||||
{% elif notifications %}
|
||||
<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 %}
|
||||
{% endif %}
|
||||
|
||||
{% call(item, row_number) list_table(
|
||||
notifications,
|
||||
caption=uploaded_file_name,
|
||||
caption_visible=False,
|
||||
empty_message="No messages to show",
|
||||
field_headings=[
|
||||
'Recipient',
|
||||
'Time',
|
||||
'Status'
|
||||
],
|
||||
field_headings_visible=False
|
||||
) %}
|
||||
{% call row_heading() %}
|
||||
{{ item.to }}
|
||||
{% endcall %}
|
||||
{{ date_field(
|
||||
(item.updated_at or item.created_at)|format_datetime_short
|
||||
) }}
|
||||
{% call field(
|
||||
align='right',
|
||||
status=item.status|format_notification_status_as_field_status
|
||||
) %}
|
||||
{% if item.status|format_notification_status_as_url %}
|
||||
<a href="{{ item.status|format_notification_status_as_url }}">
|
||||
{% endif %}
|
||||
{{ item.status|format_notification_status(item.template.template_type) }}
|
||||
{% if item.status|format_notification_status_as_url %}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% endcall %}
|
||||
|
||||
{% if more_than_one_page %}
|
||||
<p class="table-show-more-link">
|
||||
Only showing the first 50 rows
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if notifications %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% call(item, row_number) list_table(
|
||||
notifications,
|
||||
caption=uploaded_file_name,
|
||||
caption_visible=False,
|
||||
empty_message="No messages to show",
|
||||
field_headings=[
|
||||
'Recipient',
|
||||
'Time',
|
||||
'Status'
|
||||
],
|
||||
field_headings_visible=False
|
||||
) %}
|
||||
{% call row_heading() %}
|
||||
{{ item.to }}
|
||||
{% endcall %}
|
||||
{{ date_field(
|
||||
(item.updated_at or item.created_at)|format_datetime_short
|
||||
) }}
|
||||
{% call field(
|
||||
align='right',
|
||||
status=item.status|format_notification_status_as_field_status
|
||||
) %}
|
||||
{% if item.status|format_notification_status_as_url %}
|
||||
<a href="{{ item.status|format_notification_status_as_url }}">
|
||||
{% endif %}
|
||||
{{ item.status|format_notification_status(item.template.template_type) }}
|
||||
{% if item.status|format_notification_status_as_url %}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% endcall %}
|
||||
|
||||
{% if more_than_one_page %}
|
||||
<p class="table-show-more-link">
|
||||
Only showing the first 50 rows
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if notifications %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -126,6 +126,29 @@ def test_should_show_job_in_progress(
|
||||
assert page.find('p', {'class': 'hint'}).text.strip() == 'Report is 50% complete…'
|
||||
|
||||
|
||||
def test_should_show_scheduled_job(
|
||||
app_,
|
||||
service_one,
|
||||
active_user_with_permissions,
|
||||
mock_get_service_template,
|
||||
mock_get_scheduled_job,
|
||||
mocker,
|
||||
mock_get_notifications,
|
||||
fake_uuid
|
||||
):
|
||||
with app_.test_request_context(), app_.test_client() as client:
|
||||
client.login(active_user_with_permissions, mocker, service_one)
|
||||
response = client.get(url_for(
|
||||
'main.view_job',
|
||||
service_id=service_one['id'],
|
||||
job_id=fake_uuid
|
||||
))
|
||||
|
||||
assert response.status_code == 200
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
assert page.find('main').find_all('p')[2].text.strip() == 'Sending will start at midnight'
|
||||
|
||||
|
||||
def test_should_show_not_show_csv_download_in_tour(
|
||||
app_,
|
||||
service_one,
|
||||
|
||||
@@ -858,6 +858,20 @@ def mock_get_job(mocker, api_user_active):
|
||||
return mocker.patch('app.job_api_client.get_job', side_effect=_get_job)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_scheduled_job(mocker, api_user_active):
|
||||
def _get_job(service_id, job_id):
|
||||
return {"data": job_json(
|
||||
service_id,
|
||||
api_user_active,
|
||||
job_id=job_id,
|
||||
job_status='scheduled',
|
||||
scheduled_for='2016-01-01T00:00:00.061258'
|
||||
)}
|
||||
|
||||
return mocker.patch('app.job_api_client.get_job', side_effect=_get_job)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_job_in_progress(mocker, api_user_active):
|
||||
def _get_job(service_id, job_id):
|
||||
|
||||
Reference in New Issue
Block a user