From 5151e2dd960cc4cb244224e0e108096cab1e428f Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 18 Dec 2018 19:26:11 -0600 Subject: [PATCH] Expose label profile selection when editing label batch --- tailbone/views/labels/batch.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tailbone/views/labels/batch.py b/tailbone/views/labels/batch.py index 414811f4..d4f8d3dd 100644 --- a/tailbone/views/labels/batch.py +++ b/tailbone/views/labels/batch.py @@ -30,6 +30,7 @@ import six from rattail.db import model +from deform import widget as dfwidget from webhelpers2.html import HTML, tags from tailbone import forms @@ -70,6 +71,7 @@ class LabelBatchView(BatchMasterView): 'id', 'description', 'static_prices', + 'label_profile', 'notes', 'created', 'created_by', @@ -116,12 +118,25 @@ class LabelBatchView(BatchMasterView): # handheld_batches f.set_readonly('handheld_batches') f.set_renderer('handheld_batches', self.render_handheld_batches) - if self.viewing or self.deleting: batch = self.get_instance() if not batch._handhelds: 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): items = '' for handheld in label_batch._handhelds: