New template button takes user to new template page

for all services that only allow sending one type of notifications
This commit is contained in:
Pea Tyczynska
2020-08-11 15:44:17 +01:00
parent bdfc0adcc0
commit 36c1ffa7be
5 changed files with 51 additions and 10 deletions

View File

@@ -31,6 +31,7 @@ from app.models.service import Service
from app.models.template_list import TemplateList, TemplateLists
from app.template_previews import TemplatePreview, get_page_count_for_letter
from app.utils import (
NOTIFICATION_TYPES,
get_template,
should_skip_template_page,
user_has_permissions,
@@ -130,6 +131,11 @@ def choose_template(service_id, template_type='all', template_folder_id=None):
)
option_hints = {template_folder_id: 'current folder'}
single_notification_channel = None
notification_channels = list(set(current_service.permissions).intersection(NOTIFICATION_TYPES))
if len(notification_channels) == 1:
single_notification_channel = notification_channels[0]
if request.method == 'POST' and templates_and_folders_form.validate_on_submit():
if not current_user.has_permissions('manage_templates'):
abort(403)
@@ -168,6 +174,7 @@ def choose_template(service_id, template_type='all', template_folder_id=None):
templates_and_folders_form=templates_and_folders_form,
move_to_children=templates_and_folders_form.move_to.children(),
user_has_template_folder_permission=user_has_template_folder_permission,
single_notification_channel=single_notification_channel,
option_hints=option_hints
)