Allow batch execution to require options on a per-batch basis
plus some other changes i think..
This commit is contained in:
parent
98ca378302
commit
3477637c74
|
@ -7,7 +7,7 @@
|
||||||
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js'))}
|
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js'))}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var has_execution_options = ${'true' if master.has_execution_options else 'false'};
|
var has_execution_options = ${'true' if master.has_execution_options(batch) else 'false'};
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
<div id="execution-options-dialog" style="display: none;">
|
<div id="execution-options-dialog" style="display: none;">
|
||||||
|
|
||||||
${h.form(url('{}.execute'.format(route_prefix), uuid=batch.uuid), name='batch-execution')}
|
${h.form(url('{}.execute'.format(route_prefix), uuid=batch.uuid), name='batch-execution')}
|
||||||
% if master.has_execution_options:
|
% if master.has_execution_options(batch):
|
||||||
${rendered_execution_options|n}
|
${rendered_execution_options|n}
|
||||||
% endif
|
% endif
|
||||||
${h.end_form()}
|
${h.end_form()}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
${parent.extra_javascript()}
|
${parent.extra_javascript()}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var has_execution_options = ${'true' if master.has_execution_options else 'false'};
|
var has_execution_options = ${'true' if master.has_execution_options(batch) else 'false'};
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ ${parent.body()}
|
||||||
be aggregated and treated as a single data source, during execution.
|
be aggregated and treated as a single data source, during execution.
|
||||||
</p>
|
</p>
|
||||||
<br />
|
<br />
|
||||||
% if master.has_execution_options:
|
% if master.has_execution_options(batch):
|
||||||
${rendered_execution_options|n}
|
${rendered_execution_options|n}
|
||||||
% endif
|
% endif
|
||||||
${h.end_form()}
|
${h.end_form()}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js'))}
|
${h.javascript_link(request.static_url('tailbone:static/js/tailbone.batch.js'))}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var has_execution_options = ${'true' if master.has_execution_options else 'false'};
|
var has_execution_options = ${'true' if master.has_execution_options(batch) else 'false'};
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
% if master.has_worksheet:
|
% if master.has_worksheet:
|
||||||
|
@ -89,7 +89,7 @@ ${rows_grid|n}
|
||||||
|
|
||||||
${h.form(url('{}.execute'.format(route_prefix), uuid=batch.uuid), name='batch-execution')}
|
${h.form(url('{}.execute'.format(route_prefix), uuid=batch.uuid), name='batch-execution')}
|
||||||
${h.csrf_token(request)}
|
${h.csrf_token(request)}
|
||||||
% if master.has_execution_options:
|
% if master.has_execution_options(batch):
|
||||||
${rendered_execution_options|n}
|
${rendered_execution_options|n}
|
||||||
% endif
|
% endif
|
||||||
${h.end_form()}
|
${h.end_form()}
|
||||||
|
|
|
@ -109,7 +109,7 @@ class BatchMasterView(MasterView):
|
||||||
kwargs['handler'] = self.handler
|
kwargs['handler'] = self.handler
|
||||||
kwargs['execute_title'] = self.get_execute_title(batch)
|
kwargs['execute_title'] = self.get_execute_title(batch)
|
||||||
kwargs['execute_enabled'] = self.instance_executable(batch)
|
kwargs['execute_enabled'] = self.instance_executable(batch)
|
||||||
if kwargs['execute_enabled'] and self.has_execution_options:
|
if kwargs['execute_enabled'] and self.has_execution_options(batch):
|
||||||
kwargs['rendered_execution_options'] = self.render_execution_options(batch)
|
kwargs['rendered_execution_options'] = self.render_execution_options(batch)
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ class BatchMasterView(MasterView):
|
||||||
|
|
||||||
def template_kwargs_index(self, **kwargs):
|
def template_kwargs_index(self, **kwargs):
|
||||||
kwargs['execute_enabled'] = self.instance_executable(None)
|
kwargs['execute_enabled'] = self.instance_executable(None)
|
||||||
if kwargs['execute_enabled'] and self.has_execution_options:
|
if kwargs['execute_enabled'] and self.has_execution_options():
|
||||||
kwargs['rendered_execution_options'] = self.render_execution_options()
|
kwargs['rendered_execution_options'] = self.render_execution_options()
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ class BatchMasterView(MasterView):
|
||||||
|
|
||||||
if self.edit_with_rows:
|
if self.edit_with_rows:
|
||||||
context['rows_grid'] = grid
|
context['rows_grid'] = grid
|
||||||
if context['execute_enabled'] and self.has_execution_options:
|
if context['execute_enabled'] and self.has_execution_options(batch):
|
||||||
context['rendered_execution_options'] = self.render_execution_options(batch)
|
context['rendered_execution_options'] = self.render_execution_options(batch)
|
||||||
|
|
||||||
return self.render_to_response('edit', context)
|
return self.render_to_response('edit', context)
|
||||||
|
@ -474,8 +474,7 @@ class BatchMasterView(MasterView):
|
||||||
# TODO: deprecate/remove this
|
# TODO: deprecate/remove this
|
||||||
return self.handler.refreshable and not batch.executed
|
return self.handler.refreshable and not batch.executed
|
||||||
|
|
||||||
@property
|
def has_execution_options(self, batch=None):
|
||||||
def has_execution_options(self):
|
|
||||||
return bool(self.execution_options_schema)
|
return bool(self.execution_options_schema)
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
@ -750,7 +749,7 @@ class BatchMasterView(MasterView):
|
||||||
if self.request.method == 'POST':
|
if self.request.method == 'POST':
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if self.has_execution_options:
|
if self.has_execution_options(batch):
|
||||||
form = self.make_execution_options_form(batch)
|
form = self.make_execution_options_form(batch)
|
||||||
assert form.validate() # TODO
|
assert form.validate() # TODO
|
||||||
kwargs.update(form.data)
|
kwargs.update(form.data)
|
||||||
|
@ -833,7 +832,7 @@ class BatchMasterView(MasterView):
|
||||||
if self.request.method == 'POST':
|
if self.request.method == 'POST':
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if self.has_execution_options:
|
if self.has_execution_options():
|
||||||
form = self.make_execution_options_form()
|
form = self.make_execution_options_form()
|
||||||
if not form.validate():
|
if not form.validate():
|
||||||
raise RuntimeError("Execution options form did not validate")
|
raise RuntimeError("Execution options form did not validate")
|
||||||
|
|
|
@ -52,8 +52,10 @@ class InventoryBatchView(BatchMasterView):
|
||||||
default_handler_spec = 'rattail.batch.inventory:InventoryBatchHandler'
|
default_handler_spec = 'rattail.batch.inventory:InventoryBatchHandler'
|
||||||
route_prefix = 'batch.inventory'
|
route_prefix = 'batch.inventory'
|
||||||
url_prefix = '/batch/inventory'
|
url_prefix = '/batch/inventory'
|
||||||
|
index_title = "Inventory"
|
||||||
creatable = False
|
creatable = False
|
||||||
mobile_creatable = True
|
mobile_creatable = True
|
||||||
|
mobile_rows_creatable = True
|
||||||
|
|
||||||
grid_columns = [
|
grid_columns = [
|
||||||
'id',
|
'id',
|
||||||
|
@ -147,6 +149,7 @@ class InventoryBatchView(BatchMasterView):
|
||||||
])
|
])
|
||||||
if not self.creating:
|
if not self.creating:
|
||||||
fs.mode.set(readonly=True)
|
fs.mode.set(readonly=True)
|
||||||
|
fs.reason_code.set(readonly=True)
|
||||||
|
|
||||||
def row_editable(self, row):
|
def row_editable(self, row):
|
||||||
return self.mutable_batch(row.batch)
|
return self.mutable_batch(row.batch)
|
||||||
|
@ -246,12 +249,15 @@ class InventoryBatchView(BatchMasterView):
|
||||||
"""
|
"""
|
||||||
self.viewing = True
|
self.viewing = True
|
||||||
row = self.get_row_instance()
|
row = self.get_row_instance()
|
||||||
|
parent = self.get_parent(row)
|
||||||
form = self.make_mobile_row_form(row)
|
form = self.make_mobile_row_form(row)
|
||||||
context = {
|
context = {
|
||||||
'row': row,
|
'row': row,
|
||||||
'instance': row,
|
'instance': row,
|
||||||
'instance_title': self.get_row_instance_title(row),
|
'instance_title': self.get_row_instance_title(row),
|
||||||
'parent_model_title': self.get_model_title(),
|
'parent_model_title': self.get_model_title(),
|
||||||
|
'parent_title': self.get_instance_title(parent),
|
||||||
|
'parent_url': self.get_action_url('view', parent, mobile=True),
|
||||||
'product_image_url': pod.get_image_url(self.rattail_config, row.upc),
|
'product_image_url': pod.get_image_url(self.rattail_config, row.upc),
|
||||||
'form': form,
|
'form': form,
|
||||||
}
|
}
|
||||||
|
@ -273,6 +279,13 @@ class InventoryBatchView(BatchMasterView):
|
||||||
|
|
||||||
return self.render_to_response('view_row', context, mobile=True)
|
return self.render_to_response('view_row', context, mobile=True)
|
||||||
|
|
||||||
|
def get_row_instance_title(self, row):
|
||||||
|
if row.upc:
|
||||||
|
return row.upc.pretty()
|
||||||
|
if row.item_id:
|
||||||
|
return row.item_id
|
||||||
|
return "row {}".format(row.sequence)
|
||||||
|
|
||||||
def configure_row_grid(self, g):
|
def configure_row_grid(self, g):
|
||||||
super(InventoryBatchView, self).configure_row_grid(g)
|
super(InventoryBatchView, self).configure_row_grid(g)
|
||||||
|
|
||||||
|
@ -345,12 +358,11 @@ class InventoryBatchView(BatchMasterView):
|
||||||
route_prefix = cls.get_route_prefix()
|
route_prefix = cls.get_route_prefix()
|
||||||
url_prefix = cls.get_url_prefix()
|
url_prefix = cls.get_url_prefix()
|
||||||
permission_prefix = cls.get_permission_prefix()
|
permission_prefix = cls.get_permission_prefix()
|
||||||
row_permission_prefix = cls.get_row_permission_prefix()
|
|
||||||
|
|
||||||
# mobile - make new row from UPC
|
# mobile - make new row from UPC
|
||||||
config.add_route('mobile.{}.row_from_upc'.format(route_prefix), '/mobile{}/{{{}}}/row-from-upc'.format(url_prefix, model_key))
|
config.add_route('mobile.{}.row_from_upc'.format(route_prefix), '/mobile{}/{{{}}}/row-from-upc'.format(url_prefix, model_key))
|
||||||
config.add_view(cls, attr='mobile_row_from_upc', route_name='mobile.{}.row_from_upc'.format(route_prefix),
|
config.add_view(cls, attr='mobile_row_from_upc', route_name='mobile.{}.row_from_upc'.format(route_prefix),
|
||||||
permission='{}.create'.format(row_permission_prefix))
|
permission='{}.create_row'.format(permission_prefix))
|
||||||
|
|
||||||
# extra perms for creating batches per "mode"
|
# extra perms for creating batches per "mode"
|
||||||
config.add_tailbone_permission(permission_prefix, '{}.create.replace'.format(permission_prefix),
|
config.add_tailbone_permission(permission_prefix, '{}.create.replace'.format(permission_prefix),
|
||||||
|
|
Loading…
Reference in a new issue