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 %} +