From beb64bb11e108bfd66962c2eec809b807c4c5ed6 Mon Sep 17 00:00:00 2001 From: marco <marco.nuechel@rwth-aachen.de> Date: Sat, 17 Feb 2018 22:59:19 +0100 Subject: [PATCH] Add Table.button for bottons in tables --- views/tables.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/views/tables.py b/views/tables.py index 75592bf..94ca58c 100644 --- a/views/tables.py +++ b/views/tables.py @@ -25,6 +25,18 @@ class Table: confirmation = " onclick=\"return confirm('{}');\"".format(confirm) return Markup("<a href=\"{}\"{}>{}</a>".format(target, confirmation, text)) + @staticmethod + def button(target, icon, style, confirm=None): + confirmation = "" + if confirm: + confirmation = " onclick=\"return confirm('{}');\"".format(confirm) + return Markup( + '''<div class="btn-group btn-group-xs"> + <a href="{target}" class="btn btn-{style}" {confirmation}> + <span class="glyphicon glyphicon-{icon}"></span> + </a> + </div>'''.format(target=target, style=style, confirmation=confirmation, icon=icon)) + @staticmethod def mail(target): return Markup("<a href=\"mailto:{}\">{}</a>".format(target, target)) -- GitLab