dont let people get into one-off flow for deleted templates

previously we'd skip the template page entirely if someone didnt have
manage templates/api keys permission. however, if the template is
deleted you'd then go through the flow entering placeholders and stuff
before it would then crash when trying to send.

instead, just bounce the user to the template page. It has the content
and says when the template was deleted.
This commit is contained in:
Leo Hemsted
2021-07-21 16:06:23 +01:00
parent d414e6d345
commit 5da69dd495
4 changed files with 31 additions and 5 deletions

View File

@@ -77,11 +77,12 @@ def unicode_truncate(s, length):
return encoded.decode('utf-8', 'ignore')
def should_skip_template_page(template_type):
def should_skip_template_page(db_template):
return (
current_user.has_permissions('send_messages')
and not current_user.has_permissions('manage_templates', 'manage_api_keys')
and template_type != 'letter'
and db_template['template_type'] != 'letter'
and not db_template['archived']
)