From 8c610e214205c041d9032700d7e1384c0a937c7c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 5 Jul 2019 16:44:46 -0500 Subject: [PATCH] Add `render_customer()` method for MasterView surely will be commonly useful? --- tailbone/views/master.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tailbone/views/master.py b/tailbone/views/master.py index 5764684e..0164333d 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -890,6 +890,14 @@ class MasterView(View): url = self.request.route_url('users.view', uuid=user.uuid) return tags.link_to(text, url) + def render_customer(self, obj, field): + customer = getattr(obj, field) + if not customer: + return "" + text = six.text_type(customer) + url = self.request.route_url('customers.view', uuid=customer.uuid) + return tags.link_to(text, url) + def before_create_flush(self, obj, form): pass