Add hyperlink to EmployeeFieldRenderer

This commit is contained in:
Lance Edgar 2017-02-04 12:32:12 -06:00
parent 11f91d42d2
commit 8b02fd3d38

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2015 Lance Edgar
# Copyright © 2010-2017 Lance Edgar
#
# This file is part of Rattail.
#
@ -24,9 +24,11 @@
Employee Field Renderers
"""
from __future__ import unicode_literals
from __future__ import unicode_literals, absolute_import
from .common import AutocompleteFieldRenderer
from webhelpers.html import tags
from tailbone.forms.renderers import AutocompleteFieldRenderer
class EmployeeFieldRenderer(AutocompleteFieldRenderer):
@ -39,4 +41,7 @@ class EmployeeFieldRenderer(AutocompleteFieldRenderer):
employee = self.raw_value
if not employee:
return ''
return unicode(employee.person)
title = unicode(employee.person)
if self.request.has_perm('employees.view'):
return tags.link_to(title, self.request.route_url('employees.view', uuid=employee.uuid))
return title