From 523ea6e0df6f747860c3ceaeea195e084ef40566 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 20 Jan 2021 20:29:17 -0600 Subject: [PATCH] Add some generic render methods to MasterView --- tailbone/views/master.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tailbone/views/master.py b/tailbone/views/master.py index ea911bd0..79f537e0 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -905,6 +905,19 @@ class MasterView(View): """ return obj.id_str + def render_as_is(self, obj, field): + return getattr(obj, field) + + def render_url(self, obj, field): + url = getattr(obj, field) + if url: + return tags.link_to(url, url, target='_blank') + + def render_html(self, obj, field): + html = getattr(obj, field) + if html: + return HTML.literal(html) + def render_default_phone(self, obj, field): """ Render the "default" (first) phone number for the given contact.