mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-13 09:50:08 -04:00
Don’t show cancelled jobs anywhere
The information about a job doesn’t make sense if a job is cancelled. We could change the information to reflect that the job won’t be sent/ wasn’t sent/was cancelled, but there’s nothing you can really do with this info. So instead let’s: - hide cancelled jobs from the dashboard - hide cancelled jobs from the jobs page - 404 the page if the user tries to click back enough times to hit the job page
This commit is contained in:
@@ -120,7 +120,7 @@ def get_dashboard_partials(service_id):
|
||||
job for job in jobs if job['job_status'] == 'scheduled'
|
||||
], key=lambda job: job['scheduled_for'])
|
||||
immediate_jobs = [
|
||||
job for job in jobs if job['job_status'] != 'scheduled'
|
||||
job for job in jobs if job['job_status'] not in ['scheduled', 'cancelled']
|
||||
]
|
||||
service = service_api_client.get_detailed_service(service_id)
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ def view_jobs(service_id):
|
||||
'views/jobs/jobs.html',
|
||||
jobs=add_rate_to_jobs([
|
||||
job for job in job_api_client.get_job(service_id)['data']
|
||||
if job['job_status'] != 'scheduled'
|
||||
if job['job_status'] not in ['scheduled', 'cancelled']
|
||||
])
|
||||
)
|
||||
|
||||
@@ -78,6 +78,10 @@ def view_jobs(service_id):
|
||||
def view_job(service_id, job_id):
|
||||
|
||||
job = job_api_client.get_job(service_id, job_id)['data']
|
||||
|
||||
if job['job_status'] == 'cancelled':
|
||||
abort(404)
|
||||
|
||||
filter_args = _parse_filter_args(request.args)
|
||||
filter_args['status'] = _set_status_filters(filter_args)
|
||||
|
||||
|
||||
@@ -149,6 +149,25 @@ def test_should_show_scheduled_job(
|
||||
assert page.find('main').find_all('p')[2].text.strip() == 'Sending will start at midnight'
|
||||
|
||||
|
||||
def test_should_not_show_cancelled_job(
|
||||
app_,
|
||||
service_one,
|
||||
active_user_with_permissions,
|
||||
mock_get_cancelled_job,
|
||||
mocker,
|
||||
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 == 404
|
||||
|
||||
|
||||
def test_should_show_not_show_csv_download_in_tour(
|
||||
app_,
|
||||
service_one,
|
||||
|
||||
@@ -872,6 +872,20 @@ def mock_get_scheduled_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_cancelled_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='cancelled',
|
||||
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):
|
||||
@@ -903,7 +917,8 @@ def mock_get_jobs(mocker, api_user_active):
|
||||
("applicants.ods", '', ''),
|
||||
("thisisatest.csv", '', ''),
|
||||
("send_me_later.csv", '2016-01-01 11:09:00.061258', 'scheduled'),
|
||||
("even_later.csv", '2016-01-01 23:09:00.061258', 'scheduled')
|
||||
("even_later.csv", '2016-01-01 23:09:00.061258', 'scheduled'),
|
||||
("full_of_regret.csv", '2016-01-01 23:09:00.061258', 'cancelled')
|
||||
)
|
||||
]}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user