From 786ce0e071e2e3c3079c617792f28c87f46f7a50 Mon Sep 17 00:00:00 2001 From: Adam Shimali Date: Thu, 21 Apr 2016 17:34:01 +0100 Subject: [PATCH] This is intended to be a temporary solution to allow product owner to see history records until proper design is done for viewing histiry. --- app/main/views/dashboard.py | 12 ++++ app/notify_client/api_client.py | 4 ++ app/templates/views/temp-history.html | 82 +++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 app/templates/views/temp-history.html diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index d72158abf..380d54852 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -26,6 +26,18 @@ from app import ( from app.utils import user_has_permissions +# This is a placeholder view method to be replaced +# when product team makes decision about how/what/when +# to view history +@main.route("/services//history") +@login_required +def temp_service_history(service_id): + data = service_api_client.get_service_history(service_id)['data'] + return render_template('views/temp-history.html', + services=data['service_history'], + api_keys=data['api_key_history']) + + @main.route("/services//dashboard") @login_required @user_has_permissions('view_activity', admin_override=True) diff --git a/app/notify_client/api_client.py b/app/notify_client/api_client.py index 4bfaf3dc9..9151a87d5 100644 --- a/app/notify_client/api_client.py +++ b/app/notify_client/api_client.py @@ -155,6 +155,10 @@ class ServiceAPIClient(NotificationsAPIClient): resp = self.get_services(user_id) return [x['email_from'] for x in resp['data']] + # Temp access of service history data. Includes service and api key history + def get_service_history(self, service_id): + return self.get('/service/{0}/history'.format(service_id)) + class ServicesBrowsableItem(BrowsableItem): diff --git a/app/templates/views/temp-history.html b/app/templates/views/temp-history.html new file mode 100644 index 000000000..82eb1a92f --- /dev/null +++ b/app/templates/views/temp-history.html @@ -0,0 +1,82 @@ +{% extends "withoutnav_template.html" %} +{% from "components/page-footer.html" import page_footer %} +{% from "components/table.html" import list_table, field %} + +{% block page_title %} +History – GOV.UK Notify +{% endblock %} + +{% block maincolumn_content %} + +

+ {{ "Service and API key history" }} +

+ +
+ {% call(item, row_number) list_table( + services, + caption="Service history", + field_headings=['ID','Name','Created at','Updated at','Active','Message limit','Restricted','Created by id'] + )%} + {% call field() %} + {{item.id}} + {% endcall %} + {% call field() %} + {{item.name}} + {% endcall %} + {% call field() %} + {{item.created_at}} + {% endcall %} + {% call field() %} + {{item.updated_at}} + {% endcall %} + {% call field() %} + {{item.active}} + {% endcall %} + {% call field() %} + {{item.message_limit}} + {% endcall %} + {% call field() %} + {{item.restricted}} + {% endcall %} + {% call field() %} + {{item.created_by_id}} + {% endcall %} + + {% endcall %} + +
+ + +
+ {% call(item, row_number) list_table( + api_keys, + caption="API key history", + field_headings=['ID','Name','Service ID','Exiry date','Created at','Updated at','Created by id'] + )%} + {% call field() %} + {{item.id}} + {% endcall %} + {% call field() %} + {{item.name}} + {% endcall %} + {% call field() %} + {{item.service_id}} + {% endcall %} + {% call field() %} + {{item.expiry_date}} + {% endcall %} + {% call field() %} + {{item.created_at}} + {% endcall %} + {% call field() %} + {{item.updated_at}} + {% endcall %} + {% call field() %} + {{item.created_by_id}} + {% endcall %} + + {% endcall %} + +