From acc13feddbbcc946bd375be863ccd58aeabd53d5 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 2 Feb 2016 09:38:58 +0000 Subject: [PATCH] Add prompt to add first template to dashboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.pivotaltracker.com/story/show/112814667 > As you need to have templates to send any notifications, we should be nudging > people to do that when they sign in. > > This should be in the dashboard, with a link to manage templates. > > Should be bright and shiny and only show if the service has no templates. This commit adds the above. It also rationalises the language (some places used ‘create template’, others used ‘add template’, this changes everything to the latter). --- app/main/views/dashboard.py | 9 +++++++++ app/templates/views/manage-templates.html | 2 +- app/templates/views/service_dashboard.html | 9 +++++++++ tests/app/main/views/test_dashboard.py | 1 + tests/app/main/views/test_sign_out.py | 1 + 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 9776bb071..fab51f284 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -2,6 +2,7 @@ from flask import (abort, render_template, session) from flask_login import login_required from app.main import main from app.main.dao.services_dao import get_service_by_id +from app.main.dao import templates_dao from client.errors import HTTPError from ._jobs import jobs @@ -9,6 +10,13 @@ from ._jobs import jobs @main.route("/services//dashboard") @login_required def service_dashboard(service_id): + try: + templates = templates_dao.get_service_templates(service_id)['data'] + except HTTPError as e: + if e.status_code == 404: + abort(404) + else: + raise e try: service = get_service_by_id(service_id) session['service_name'] = service['data']['name'] @@ -22,4 +30,5 @@ def service_dashboard(service_id): jobs=jobs, free_text_messages_remaining='25,000', spent_this_month='0.00', + has_templates=bool(len(templates)), service_id=service_id) diff --git a/app/templates/views/manage-templates.html b/app/templates/views/manage-templates.html index 1ccc2d762..494ec6b9e 100644 --- a/app/templates/views/manage-templates.html +++ b/app/templates/views/manage-templates.html @@ -15,7 +15,7 @@ GOV.UK Notify | Manage templates

Templates

- Create new template + Add new template {% for template in templates %} {% if template.get_field('template_type') == 'sms' %} diff --git a/app/templates/views/service_dashboard.html b/app/templates/views/service_dashboard.html index 638e6d322..3b53246ac 100644 --- a/app/templates/views/service_dashboard.html +++ b/app/templates/views/service_dashboard.html @@ -8,6 +8,15 @@ {% block maincolumn_content %} + {% if not has_templates %} + {{ banner( + 'Add a template to start sending notifications'.format( + url_for(".add_service_template", service_id=service_id) + )|safe, + type="tip" + )}} + {% endif %} +