Expose label profile selection when editing label batch
This commit is contained in:
parent
a637ba1e6b
commit
5151e2dd96
|
@ -30,6 +30,7 @@ import six
|
||||||
|
|
||||||
from rattail.db import model
|
from rattail.db import model
|
||||||
|
|
||||||
|
from deform import widget as dfwidget
|
||||||
from webhelpers2.html import HTML, tags
|
from webhelpers2.html import HTML, tags
|
||||||
|
|
||||||
from tailbone import forms
|
from tailbone import forms
|
||||||
|
@ -70,6 +71,7 @@ class LabelBatchView(BatchMasterView):
|
||||||
'id',
|
'id',
|
||||||
'description',
|
'description',
|
||||||
'static_prices',
|
'static_prices',
|
||||||
|
'label_profile',
|
||||||
'notes',
|
'notes',
|
||||||
'created',
|
'created',
|
||||||
'created_by',
|
'created_by',
|
||||||
|
@ -116,12 +118,25 @@ class LabelBatchView(BatchMasterView):
|
||||||
# handheld_batches
|
# handheld_batches
|
||||||
f.set_readonly('handheld_batches')
|
f.set_readonly('handheld_batches')
|
||||||
f.set_renderer('handheld_batches', self.render_handheld_batches)
|
f.set_renderer('handheld_batches', self.render_handheld_batches)
|
||||||
|
|
||||||
if self.viewing or self.deleting:
|
if self.viewing or self.deleting:
|
||||||
batch = self.get_instance()
|
batch = self.get_instance()
|
||||||
if not batch._handhelds:
|
if not batch._handhelds:
|
||||||
f.remove_field('handheld_batches')
|
f.remove_field('handheld_batches')
|
||||||
|
|
||||||
|
# label profile
|
||||||
|
if self.creating or self.editing:
|
||||||
|
if 'label_profile' in f.fields:
|
||||||
|
f.replace('label_profile', 'label_profile_uuid')
|
||||||
|
# TODO: should restrict somehow? just allow override?
|
||||||
|
profiles = self.Session.query(model.LabelProfile)
|
||||||
|
values = [(p.uuid, six.text_type(p))
|
||||||
|
for p in profiles]
|
||||||
|
require_profile = False
|
||||||
|
if not require_profile:
|
||||||
|
values.insert(0, ('', "(none)"))
|
||||||
|
f.set_widget('label_profile_uuid', dfwidget.SelectWidget(values=values))
|
||||||
|
f.set_label('label_profile_uuid', "Label Profile")
|
||||||
|
|
||||||
def render_handheld_batches(self, label_batch, field):
|
def render_handheld_batches(self, label_batch, field):
|
||||||
items = ''
|
items = ''
|
||||||
for handheld in label_batch._handhelds:
|
for handheld in label_batch._handhelds:
|
||||||
|
|
Loading…
Reference in a new issue