Add hyperlinks to product UPC and description, within main grid
These won't honor the indexing scheme yet, still need to think about that.
This commit is contained in:
parent
b718336ac2
commit
aaa1d17507
2 changed files with 35 additions and 8 deletions
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2015 Lance Edgar
|
||||
# Copyright © 2010-2016 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -24,13 +24,14 @@
|
|||
Product Field Renderers
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
from rattail.gpc import GPC
|
||||
|
||||
from formalchemy import TextFieldRenderer
|
||||
from rattail.gpc import GPC
|
||||
from .common import AutocompleteFieldRenderer
|
||||
from webhelpers.html import literal
|
||||
from webhelpers.html import tags, literal
|
||||
|
||||
from tailbone.forms.renderers.common import AutocompleteFieldRenderer
|
||||
from tailbone.util import pretty_datetime
|
||||
|
||||
|
||||
|
@ -57,14 +58,18 @@ class GPCFieldRenderer(TextFieldRenderer):
|
|||
@property
|
||||
def length(self):
|
||||
# Hm, should maybe consider hard-coding this...?
|
||||
return len(str(GPC(0)))
|
||||
return len(unicode(GPC(0)))
|
||||
|
||||
def render_readonly(self, **kwargs):
|
||||
gpc = self.raw_value
|
||||
if gpc is None:
|
||||
return ''
|
||||
gpc = unicode(gpc)
|
||||
return '{0}-{1}'.format(gpc[:-1], gpc[-1])
|
||||
gpc = '{}-{}'.format(gpc[:-1], gpc[-1])
|
||||
if kwargs.get('link'):
|
||||
product = self.field.parent.model
|
||||
gpc = tags.link_to(gpc, kwargs['link'](product))
|
||||
return gpc
|
||||
|
||||
|
||||
class DepartmentFieldRenderer(TextFieldRenderer):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue