mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 02:42:26 -05:00
Merge remote-tracking branch 'origin/master' into api_service_permissions
This commit is contained in:
@@ -5,7 +5,11 @@ import time
|
||||
from flask import (
|
||||
render_template,
|
||||
abort,
|
||||
jsonify
|
||||
jsonify,
|
||||
flash,
|
||||
redirect,
|
||||
request,
|
||||
url_for
|
||||
)
|
||||
from flask_login import login_required
|
||||
from utils.template import Template
|
||||
@@ -14,6 +18,7 @@ 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
|
||||
from app.utils import (get_page_from_request, generate_previous_next_dict)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/jobs")
|
||||
@@ -86,6 +91,34 @@ def view_job_updates(service_id, job_id):
|
||||
})
|
||||
|
||||
|
||||
@main.route('/services/<service_id>/notifications')
|
||||
@login_required
|
||||
def view_notifications(service_id):
|
||||
# TODO get the api to return count of pages as well.
|
||||
page = get_page_from_request()
|
||||
if page is None:
|
||||
abort(404, "Invalid page argument ({}) reverting to page 1.".format(request.args['page'], None))
|
||||
notifications = notification_api_client.get_notifications_for_service(service_id=service_id, page=page)
|
||||
prev_page = None
|
||||
if notifications['links'].get('prev', None):
|
||||
prev_page = generate_previous_next_dict(
|
||||
'main.view_notifications',
|
||||
{'service_id': service_id}, page - 1, 'Previous page', 'page {}'.format(page - 1))
|
||||
next_page = None
|
||||
if notifications['links'].get('next', None):
|
||||
next_page = generate_previous_next_dict(
|
||||
'main.view_notifications',
|
||||
{'service_id': service_id}, page + 1, 'Next page', 'page {}'.format(page + 1))
|
||||
return render_template(
|
||||
'views/notifications.html',
|
||||
service_id=service_id,
|
||||
notifications=notifications['notifications'],
|
||||
page=page,
|
||||
prev_page=prev_page,
|
||||
next_page=next_page
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/jobs/<job_id>/notification/<string:notification_id>")
|
||||
@login_required
|
||||
def view_notification(service_id, job_id, notification_id):
|
||||
|
||||
Reference in New Issue
Block a user