From d495619cb62aa4e55c4d3cf23ddb3c06459dadf8 Mon Sep 17 00:00:00 2001 From: Patrick Smith Date: Thu, 17 Jan 2019 08:47:23 -0500 Subject: [PATCH] Allow specifying custom actions in flashed messages --- atst/utils/flash.py | 5 ++++- templates/fragments/flash.html | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/atst/utils/flash.py b/atst/utils/flash.py index 4ba9ac42..9adf1499 100644 --- a/atst/utils/flash.py +++ b/atst/utils/flash.py @@ -115,4 +115,7 @@ def formatted_flash(message_name, **message_args): config = MESSAGES[message_name] title = render_template_string(config["title_template"], **message_args) message = render_template_string(config["message_template"], **message_args) - flash({"title": title, "message": message}, config["category"]) + actions = None + if "actions" in config: + actions = render_template_string(config["actions"], **message_args) + flash({"title": title, "message": message, "actions": actions}, config["category"]) diff --git a/templates/fragments/flash.html b/templates/fragments/flash.html index 518f27a5..49057352 100644 --- a/templates/fragments/flash.html +++ b/templates/fragments/flash.html @@ -7,7 +7,7 @@ {% with messages = get_flashed_messages(with_categories=true, category_filter=category_filter) %} {% if messages %} {% for category, message_config in messages %} - {{ Alert(message_config["title"], message=message_config.get("message"), level=category) }} + {{ Alert(message_config["title"], message=message_config.get("message"), actions=message_config.get("actions"), level=category) }} {% endfor %} {% endif %} {% endwith %}