mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 02:42:26 -05:00
Put real notifications on job page
This commit is contained in:
@@ -14,6 +14,7 @@ from app.notify_client.api_client import NotificationsAdminAPIClient
|
||||
from app.notify_client.api_key_api_client import ApiKeyApiClient
|
||||
from app.notify_client.user_api_client import UserApiClient
|
||||
from app.notify_client.job_api_client import JobApiClient
|
||||
from app.notify_client.notification_api_client import NotificationApiClient
|
||||
from app.notify_client.status_api_client import StatusApiClient
|
||||
from app.notify_client.permission_api_client import PermissionApiClient
|
||||
from app.notify_client.invite_api_client import InviteApiClient
|
||||
@@ -31,6 +32,7 @@ notifications_api_client = NotificationsAdminAPIClient()
|
||||
user_api_client = UserApiClient()
|
||||
api_key_api_client = ApiKeyApiClient()
|
||||
job_api_client = JobApiClient()
|
||||
notification_api_client = NotificationApiClient()
|
||||
status_api_client = StatusApiClient()
|
||||
invite_api_client = InviteApiClient()
|
||||
asset_fingerprinter = AssetFingerprinter()
|
||||
@@ -50,6 +52,7 @@ def create_app(config_name, config_overrides=None):
|
||||
user_api_client.init_app(application)
|
||||
api_key_api_client.init_app(application)
|
||||
job_api_client.init_app(application)
|
||||
notification_api_client.init_app(application)
|
||||
status_api_client.init_app(application)
|
||||
permission_api_client.init_app(application)
|
||||
invite_api_client.init_app(application)
|
||||
|
||||
@@ -10,7 +10,7 @@ from flask_login import login_required
|
||||
from notifications_python_client.errors import HTTPError
|
||||
from utils.template import Template
|
||||
|
||||
from app import job_api_client
|
||||
from app import job_api_client, notification_api_client
|
||||
from app.main import main
|
||||
from app.main.dao import templates_dao
|
||||
from app.main.dao import services_dao
|
||||
@@ -41,18 +41,14 @@ def view_job(service_id, job_id):
|
||||
service = services_dao.get_service_by_id_or_404(service_id)
|
||||
try:
|
||||
job = job_api_client.get_job(service_id, job_id)['data']
|
||||
messages = []
|
||||
notifications = notification_api_client.get_notifications_for_service(service_id, job_id)
|
||||
return render_template(
|
||||
'views/job.html',
|
||||
messages=messages,
|
||||
notifications=notifications['notifications'],
|
||||
counts={
|
||||
'total': len(messages),
|
||||
'delivered': len([
|
||||
message for message in messages if message['status'] == 'Delivered'
|
||||
]),
|
||||
'failed': len([
|
||||
message for message in messages if message['status'] == 'Failed'
|
||||
])
|
||||
'total': len(notifications),
|
||||
'delivered': len(notifications),
|
||||
'failed': 0
|
||||
},
|
||||
cost=u'£0.00',
|
||||
uploaded_file_name=job['original_file_name'],
|
||||
|
||||
@@ -61,24 +61,18 @@
|
||||
</ul>
|
||||
|
||||
{% call(item) list_table(
|
||||
[
|
||||
{'row': 1, 'phone': '+447700 900995', 'template': template['name'], 'status': 'sent'}
|
||||
],
|
||||
notifications,
|
||||
caption=uploaded_file_name,
|
||||
caption_visible=False,
|
||||
empty_message="Messages go here",
|
||||
field_headings=[
|
||||
'Row',
|
||||
'Recipient',
|
||||
'Template',
|
||||
right_aligned_field_heading('Status')
|
||||
]
|
||||
) %}
|
||||
{% call field() %}
|
||||
{{ item.row }}.
|
||||
{% endcall %}
|
||||
{% call field() %}
|
||||
{{item.phone[:3]}} •••• ••••••
|
||||
{{ item.to }}
|
||||
{% endcall %}
|
||||
{% call field() %}
|
||||
{{item.template}}
|
||||
|
||||
@@ -242,6 +242,7 @@ def test_create_job_should_call_api(
|
||||
job_data,
|
||||
mock_create_job,
|
||||
mock_get_job,
|
||||
mock_get_notifications,
|
||||
mock_get_service,
|
||||
mock_get_service_template,
|
||||
mock_has_permissions
|
||||
|
||||
Reference in New Issue
Block a user