Make hyperlink optional for employee field renderer
This commit is contained in:
parent
e2b22221c4
commit
24a2c15850
|
@ -1,4 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8; -*-
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
|
@ -26,6 +26,7 @@ Employee Field Renderers
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import
|
from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
|
import six
|
||||||
from webhelpers.html import tags
|
from webhelpers.html import tags
|
||||||
|
|
||||||
from tailbone.forms.renderers import AutocompleteFieldRenderer
|
from tailbone.forms.renderers import AutocompleteFieldRenderer
|
||||||
|
@ -41,7 +42,8 @@ class EmployeeFieldRenderer(AutocompleteFieldRenderer):
|
||||||
employee = self.raw_value
|
employee = self.raw_value
|
||||||
if not employee:
|
if not employee:
|
||||||
return ''
|
return ''
|
||||||
title = unicode(employee.person)
|
render_name = kwargs.get('render_name', six.text_type)
|
||||||
if self.request.has_perm('employees.view'):
|
title = render_name(employee)
|
||||||
|
if kwargs.get('hyperlink') and self.request.has_perm('employees.view'):
|
||||||
return tags.link_to(title, self.request.route_url('employees.view', uuid=employee.uuid))
|
return tags.link_to(title, self.request.route_url('employees.view', uuid=employee.uuid))
|
||||||
return title
|
return title
|
||||||
|
|
Loading…
Reference in a new issue