Add view for a single template

> At the moment, we have an all email templates page, and an edit an
> individual page.
>
> This gets messy when we refer to templates like the dashboard and the
> activity views. We solve this currently by using anchor links to the
> list page, but this is clunky.
>
> So lets add it, then update the links on the dash and activity to the
> new view page.
>
> Should be a link from the view a single template page, to the template
> hub page.

https://www.pivotaltracker.com/story/show/117349227
This commit is contained in:
Chris Hill-Scott
2016-04-12 09:55:51 +01:00
parent 9acd344475
commit c81b8c39f6
9 changed files with 138 additions and 81 deletions

View File

@@ -79,7 +79,7 @@ def choose_template(service_id, template_type):
abort(404)
return render_template(
'views/choose-template.html',
'views/templates/choose.html',
templates=[
Template(
template,

View File

@@ -1,10 +1,12 @@
from flask import request, render_template, redirect, url_for, flash, abort
from flask_login import login_required
from utils.template import Template
from app.main import main
from app.utils import user_has_permissions
from app.main.forms import SMSTemplateForm, EmailTemplateForm
from app import service_api_client
from app import service_api_client, current_service
form_objects = {
@@ -18,6 +20,26 @@ page_headings = {
}
@main.route("/services/<service_id>/templates/<template_id>", methods=['GET'])
@login_required
@user_has_permissions(
'view_activity',
'send_texts',
'send_emails',
'manage_templates',
'manage_api_keys',
admin_override=True, any_=True
)
def view_template(service_id, template_id):
return render_template(
'views/templates/template.html',
template=Template(
service_api_client.get_service_template(service_id, template_id)['data'],
prefix=current_service['name']
)
)
@main.route("/services/<service_id>/templates/add-<template_type>", methods=['GET', 'POST'])
@login_required
@user_has_permissions('manage_templates', admin_override=True)
@@ -48,7 +70,7 @@ def add_service_template(service_id, template_type):
)
@main.route("/services/<service_id>/templates/<template_id>", methods=['GET', 'POST'])
@main.route("/services/<service_id>/templates/<template_id>/edit", methods=['GET', 'POST'])
@login_required
@user_has_permissions('manage_templates', admin_override=True)
def edit_service_template(service_id, template_id):