Add a generic "user" field renderer to master view

and use it for PersonNote view
This commit is contained in:
Lance Edgar 2019-06-05 16:04:14 -05:00
parent e097f526bb
commit 6749604210
2 changed files with 9 additions and 0 deletions

View file

@ -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

View file

@ -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