From 6749604210da4606269fba8f6b23d15ebd763645 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 5 Jun 2019 16:04:14 -0500 Subject: [PATCH] Add a generic "user" field renderer to master view and use it for PersonNote view --- tailbone/views/master.py | 8 ++++++++ tailbone/views/people.py | 1 + 2 files changed, 9 insertions(+) diff --git a/tailbone/views/master.py b/tailbone/views/master.py index a1f531f1..c8264a12 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -881,6 +881,14 @@ class MasterView(View): url = self.request.route_url('people.view', uuid=person.uuid) return tags.link_to(text, url) + def render_user(self, obj, field): + user = getattr(obj, field) + if not user: + return "" + text = six.text_type(user) + url = self.request.route_url('users.view', uuid=user.uuid) + return tags.link_to(text, url) + def before_create_flush(self, obj, form): pass diff --git a/tailbone/views/people.py b/tailbone/views/people.py index caf8d03e..748cf0a6 100644 --- a/tailbone/views/people.py +++ b/tailbone/views/people.py @@ -424,6 +424,7 @@ class PersonNoteView(MasterView): super(PersonNoteView, self).configure_form(f) f.set_renderer('person', self.render_person) + f.set_renderer('created_by', self.render_user) @colander.deferred