mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-26 09:13:58 -04:00
Remove letter jobs page
When we first built letters you could only send them via a CSV upload, initially we needed a way to send those files to dvla per job. We since stopped using this page. So let's delete it!
This commit is contained in:
@@ -28,7 +28,6 @@ from app.main.views import ( # noqa
|
|||||||
providers,
|
providers,
|
||||||
find_users,
|
find_users,
|
||||||
platform_admin,
|
platform_admin,
|
||||||
letter_jobs,
|
|
||||||
email_branding,
|
email_branding,
|
||||||
conversation,
|
conversation,
|
||||||
organisations,
|
organisations,
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
from flask import redirect, render_template, request, session, url_for
|
|
||||||
from flask_login import login_required
|
|
||||||
|
|
||||||
from app import letter_jobs_client
|
|
||||||
from app.main import main
|
|
||||||
from app.utils import user_is_platform_admin
|
|
||||||
|
|
||||||
|
|
||||||
@main.route("/letter-jobs", methods=['GET', 'POST'])
|
|
||||||
@login_required
|
|
||||||
@user_is_platform_admin
|
|
||||||
def letter_jobs():
|
|
||||||
letter_jobs_list = letter_jobs_client.get_letter_jobs()
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
if len(request.form.getlist('job_id')) > 0:
|
|
||||||
job_ids = request.form.getlist('job_id')
|
|
||||||
session['job_ids'] = job_ids
|
|
||||||
|
|
||||||
response = letter_jobs_client.send_letter_jobs(job_ids)
|
|
||||||
msg = response['response']
|
|
||||||
else:
|
|
||||||
msg = 'No jobs selected'
|
|
||||||
|
|
||||||
session['msg'] = msg
|
|
||||||
|
|
||||||
return redirect(url_for('main.letter_jobs'))
|
|
||||||
|
|
||||||
msg = session.pop('msg', None)
|
|
||||||
job_ids = session.pop('job_ids', None)
|
|
||||||
if job_ids:
|
|
||||||
for job_id in job_ids:
|
|
||||||
job = [j for j in letter_jobs_list if job_id == j['id']][0]
|
|
||||||
job['sending'] = 'sending'
|
|
||||||
|
|
||||||
return render_template('views/letter-jobs.html', letter_jobs_list=letter_jobs_list, message=msg)
|
|
||||||
@@ -170,7 +170,6 @@ class HeaderNavigation(Navigation):
|
|||||||
'information_security',
|
'information_security',
|
||||||
'invite_org_user',
|
'invite_org_user',
|
||||||
'invite_user',
|
'invite_user',
|
||||||
'letter_jobs',
|
|
||||||
'link_service_to_organisation',
|
'link_service_to_organisation',
|
||||||
'manage_org_users',
|
'manage_org_users',
|
||||||
'manage_template_folder',
|
'manage_template_folder',
|
||||||
@@ -439,7 +438,6 @@ class MainNavigation(Navigation):
|
|||||||
'information_security',
|
'information_security',
|
||||||
'integration_testing',
|
'integration_testing',
|
||||||
'invite_org_user',
|
'invite_org_user',
|
||||||
'letter_jobs',
|
|
||||||
'live_services',
|
'live_services',
|
||||||
'manage_org_users',
|
'manage_org_users',
|
||||||
'new_password',
|
'new_password',
|
||||||
@@ -626,7 +624,6 @@ class CaseworkNavigation(Navigation):
|
|||||||
'integration_testing',
|
'integration_testing',
|
||||||
'invite_org_user',
|
'invite_org_user',
|
||||||
'invite_user',
|
'invite_user',
|
||||||
'letter_jobs',
|
|
||||||
'link_service_to_organisation',
|
'link_service_to_organisation',
|
||||||
'live_services',
|
'live_services',
|
||||||
'manage_org_users',
|
'manage_org_users',
|
||||||
@@ -861,7 +858,6 @@ class OrgNavigation(Navigation):
|
|||||||
'information_security',
|
'information_security',
|
||||||
'integration_testing',
|
'integration_testing',
|
||||||
'invite_user',
|
'invite_user',
|
||||||
'letter_jobs',
|
|
||||||
'link_service_to_organisation',
|
'link_service_to_organisation',
|
||||||
'live_services',
|
'live_services',
|
||||||
'manage_template_folder',
|
'manage_template_folder',
|
||||||
|
|||||||
@@ -6,15 +6,6 @@ class LetterJobsClient(NotifyAdminAPIClient):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("a" * 73, "b")
|
super().__init__("a" * 73, "b")
|
||||||
|
|
||||||
def get_letter_jobs(self):
|
|
||||||
return self.get(url='/letter-jobs')['data']
|
|
||||||
|
|
||||||
def send_letter_jobs(self, job_ids):
|
|
||||||
return self.post(
|
|
||||||
url='/send-letter-jobs',
|
|
||||||
data={"job_ids": job_ids}
|
|
||||||
)['data']
|
|
||||||
|
|
||||||
def submit_returned_letters(self, references):
|
def submit_returned_letters(self, references):
|
||||||
return self.post(
|
return self.post(
|
||||||
url='/letters/returned',
|
url='/letters/returned',
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
{% extends "views/platform-admin/_base_template.html" %}
|
|
||||||
{% from "components/page-footer.html" import page_footer %}
|
|
||||||
{% from "components/form.html" import form_wrapper %}
|
|
||||||
|
|
||||||
{% block per_page_title %}
|
|
||||||
Letter jobs
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block platform_admin_content %}
|
|
||||||
|
|
||||||
<h1 class="heading-large">Letter jobs</h1>
|
|
||||||
|
|
||||||
{% call form_wrapper() %}
|
|
||||||
<p>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Service name</th>
|
|
||||||
<th>Job ID</th>
|
|
||||||
<th>Count</th>
|
|
||||||
<th>Status</th>
|
|
||||||
<th colspan="3">Created at</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for job in letter_jobs_list %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ job.service_name.name }}</td>
|
|
||||||
<td>{{ job.id }}</td>
|
|
||||||
<td>{{ job.notification_count }}</td>
|
|
||||||
<td>{{ job.job_status }}</td>
|
|
||||||
<td>{{ job.created_at|format_datetime_short }}</td>
|
|
||||||
<td><input name="job_id" value='{{ job.id }}' type="checkbox"{% if not (job.job_status == 'ready to send' or job.job_status == 'sent to dvla') %} disabled{% endif %}></td>
|
|
||||||
<td>{{ job.sending }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</p>
|
|
||||||
{{ page_footer('Send') }}
|
|
||||||
|
|
||||||
{% if message %}
|
|
||||||
<p id='message'>
|
|
||||||
{{ message }}
|
|
||||||
{% if message != 'No jobs selected' %}
|
|
||||||
<div>Refresh page to see status updates</div>
|
|
||||||
{% endif %}
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
{% endcall %}
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
('Organisations', url_for('main.organisations')),
|
('Organisations', url_for('main.organisations')),
|
||||||
('Providers', url_for('main.view_providers')),
|
('Providers', url_for('main.view_providers')),
|
||||||
('Email branding', url_for('main.email_branding')),
|
('Email branding', url_for('main.email_branding')),
|
||||||
('Letter jobs', url_for('main.letter_jobs')),
|
|
||||||
('Inbound SMS numbers', url_for('main.inbound_sms_admin')),
|
('Inbound SMS numbers', url_for('main.inbound_sms_admin')),
|
||||||
('Find users by email', url_for('main.find_users_by_email')),
|
('Find users by email', url_for('main.find_users_by_email')),
|
||||||
('Email Complaints', url_for('main.platform_admin_list_complaints')),
|
('Email Complaints', url_for('main.platform_admin_list_complaints')),
|
||||||
|
|||||||
@@ -1,117 +0,0 @@
|
|||||||
from enum import IntEnum
|
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
from flask import url_for
|
|
||||||
|
|
||||||
from app import format_datetime_short
|
|
||||||
|
|
||||||
valid_letter_jobs = [
|
|
||||||
{
|
|
||||||
'service_name': {'name': 'test_name'},
|
|
||||||
'id': 'test_id',
|
|
||||||
'notification_count': 2,
|
|
||||||
'job_status': 'ready to send',
|
|
||||||
'created_at': '2017-04-01T12:00:00'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'service_name': {'name': 'test_name 2'},
|
|
||||||
'id': 'test_id 2',
|
|
||||||
'notification_count': 1,
|
|
||||||
'job_status': 'sent to dvla',
|
|
||||||
'created_at': '2017-04-02T13:00:00'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'service_name': {'name': 'test_name 3'},
|
|
||||||
'id': 'test_id 3',
|
|
||||||
'notification_count': 1,
|
|
||||||
'job_status': 'in progress',
|
|
||||||
'created_at': '2017-04-03T14:00:00'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
send_letter_jobs_response = {"response": "Task created to send files to DVLA"}
|
|
||||||
|
|
||||||
|
|
||||||
class LetterJobsHeader(IntEnum):
|
|
||||||
SERVICE_NAME = 0
|
|
||||||
JOB_ID = 1
|
|
||||||
NOTIFICATION_COUNT = 2
|
|
||||||
JOB_STATUS = 3
|
|
||||||
CREATED_AT = 4
|
|
||||||
CHECKBOX = 5
|
|
||||||
TEMP_STATUS = 6
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_letter_jobs_returns_list_of_all_letter_jobs(logged_in_platform_admin_client, mocker):
|
|
||||||
mock_get_letters = mocker.patch('app.letter_jobs_client.get_letter_jobs', return_value=valid_letter_jobs)
|
|
||||||
|
|
||||||
response = logged_in_platform_admin_client.get(url_for('main.letter_jobs'))
|
|
||||||
|
|
||||||
assert mock_get_letters.called
|
|
||||||
assert response.status_code == 200
|
|
||||||
|
|
||||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
|
||||||
assert page.h1.string == 'Letter jobs'
|
|
||||||
|
|
||||||
rows = page.select('table tbody tr')
|
|
||||||
|
|
||||||
assert len(rows) == len(valid_letter_jobs)
|
|
||||||
|
|
||||||
for row_pos in range(len(rows)):
|
|
||||||
cols = rows[row_pos].find_all('td')
|
|
||||||
assert valid_letter_jobs[row_pos]['service_name']['name'] == cols[LetterJobsHeader.SERVICE_NAME].text
|
|
||||||
assert valid_letter_jobs[row_pos]['id'] == cols[LetterJobsHeader.JOB_ID].text
|
|
||||||
assert valid_letter_jobs[row_pos]['notification_count'] == int(cols[LetterJobsHeader.NOTIFICATION_COUNT].text)
|
|
||||||
assert valid_letter_jobs[row_pos]['job_status'] == cols[LetterJobsHeader.JOB_STATUS].text
|
|
||||||
assert format_datetime_short(
|
|
||||||
valid_letter_jobs[row_pos]['created_at']) == cols[LetterJobsHeader.CREATED_AT].text
|
|
||||||
if not (valid_letter_jobs[row_pos]['job_status'] == 'ready to send' or
|
|
||||||
valid_letter_jobs[row_pos]['job_status'] == 'sent to dvla'):
|
|
||||||
assert 'disabled' in str(cols[LetterJobsHeader.CHECKBOX])
|
|
||||||
|
|
||||||
|
|
||||||
def test_post_letter_jobs_select_1_letter_job_submits_1_job(logged_in_platform_admin_client, mocker):
|
|
||||||
letter_jobs_first_selected = {'job_id': ['test_id']}
|
|
||||||
|
|
||||||
mock_get_letters = mocker.patch('app.letter_jobs_client.get_letter_jobs', return_value=valid_letter_jobs)
|
|
||||||
mock_send_letters = mocker.patch('app.letter_jobs_client.send_letter_jobs', return_value=send_letter_jobs_response)
|
|
||||||
|
|
||||||
response = logged_in_platform_admin_client.post(url_for('main.letter_jobs'), data=letter_jobs_first_selected,
|
|
||||||
follow_redirects=True)
|
|
||||||
|
|
||||||
assert mock_get_letters.called
|
|
||||||
assert mock_send_letters.called
|
|
||||||
assert response.status_code == 200
|
|
||||||
|
|
||||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
|
||||||
|
|
||||||
rows = page.select('table tbody tr')
|
|
||||||
|
|
||||||
assert len(rows) == len(valid_letter_jobs)
|
|
||||||
|
|
||||||
colr0 = rows[0].find_all('td')
|
|
||||||
colr1 = rows[1].find_all('td')
|
|
||||||
colr2 = rows[2].find_all('td')
|
|
||||||
|
|
||||||
assert colr0[LetterJobsHeader.TEMP_STATUS].text == "sending"
|
|
||||||
assert colr1[LetterJobsHeader.TEMP_STATUS].text == ""
|
|
||||||
assert colr2[LetterJobsHeader.TEMP_STATUS].text == ""
|
|
||||||
|
|
||||||
message = page.find('p', attrs={'id': 'message'}).text
|
|
||||||
assert "Task created to send files to DVLA" in message
|
|
||||||
|
|
||||||
|
|
||||||
def test_post_letter_jobs_none_selected_shows_message(logged_in_platform_admin_client, mocker):
|
|
||||||
mock_get_letters = mocker.patch('app.letter_jobs_client.get_letter_jobs', return_value=valid_letter_jobs)
|
|
||||||
mock_send_letters = mocker.patch('app.letter_jobs_client.send_letter_jobs', return_value=send_letter_jobs_response)
|
|
||||||
|
|
||||||
response = logged_in_platform_admin_client.post(url_for('main.letter_jobs'), data={}, follow_redirects=True)
|
|
||||||
|
|
||||||
assert mock_get_letters.called
|
|
||||||
assert not mock_send_letters.called
|
|
||||||
assert response.status_code == 200
|
|
||||||
|
|
||||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
|
||||||
message = page.find('p', attrs={'id': 'message'}).text
|
|
||||||
|
|
||||||
assert "No jobs selected" in message
|
|
||||||
Reference in New Issue
Block a user