Purge things for legacy (jquery) mobile, and unused template themes

gosh it feels good to get rid of this stuff...  fingers crossed that nothing
was broken, but am thinking it's safe
This commit is contained in:
Lance Edgar 2021-01-30 15:52:47 -06:00
parent fac00e6ecd
commit 708641a8f1
70 changed files with 196 additions and 4886 deletions

View file

@ -150,34 +150,6 @@ class PurchasingBatchView(BatchMasterView):
'credits',
]
mobile_row_form_fields = [
'upc',
'item_id',
'product',
'brand_name',
'description',
'size',
'case_quantity',
'cases_ordered',
'units_ordered',
'cases_received',
'units_received',
'cases_damaged',
'units_damaged',
'cases_expired',
'units_expired',
'cases_mispick',
'units_mispick',
# 'po_line_number',
'po_unit_cost',
'po_total',
# 'invoice_line_number',
'invoice_unit_cost',
'invoice_total',
'status_code',
# 'credits',
]
@property
def batch_mode(self):
raise NotImplementedError("Please define `batch_mode` for your purchasing batch view")
@ -518,8 +490,8 @@ class PurchasingBatchView(BatchMasterView):
total = purchase.invoice_total
return '{} for ${:0,.2f} ({})'.format(date, total or 0, purchase.department or purchase.buyer)
def get_batch_kwargs(self, batch, mobile=False):
kwargs = super(PurchasingBatchView, self).get_batch_kwargs(batch, mobile=mobile)
def get_batch_kwargs(self, batch, **kwargs):
kwargs = super(PurchasingBatchView, self).get_batch_kwargs(batch, **kwargs)
kwargs['mode'] = self.batch_mode
kwargs['truck_dump'] = batch.truck_dump
kwargs['invoice_parser_key'] = batch.invoice_parser_key
@ -596,9 +568,6 @@ class PurchasingBatchView(BatchMasterView):
# query = super(PurchasingBatchView, self).get_row_data(batch)
# return query.options(orm.joinedload(model.PurchaseBatchRow.credits))
def sort_mobile_row_data(self, query):
return query.order_by(model.PurchaseBatchRow.modified.desc())
def configure_row_grid(self, g):
super(PurchasingBatchView, self).configure_row_grid(g)
@ -760,104 +729,6 @@ class PurchasingBatchView(BatchMasterView):
g.set_type('credit_total', 'currency')
return HTML.literal(g.render_grid())
def configure_mobile_row_form(self, f):
super(PurchasingBatchView, self).configure_mobile_row_form(f)
# row = f.model_instance
# if self.creating:
# batch = self.get_instance()
# else:
# batch = self.get_parent(row)
# # readonly fields
# f.set_readonly('case_quantity')
# f.set_readonly('credits')
# quantity fields
f.set_type('case_quantity', 'quantity')
f.set_type('cases_ordered', 'quantity')
f.set_type('units_ordered', 'quantity')
f.set_type('cases_received', 'quantity')
f.set_type('units_received', 'quantity')
f.set_type('cases_damaged', 'quantity')
f.set_type('units_damaged', 'quantity')
f.set_type('cases_expired', 'quantity')
f.set_type('units_expired', 'quantity')
f.set_type('cases_mispick', 'quantity')
f.set_type('units_mispick', 'quantity')
# currency fields
f.set_type('po_unit_cost', 'currency')
f.set_type('po_total', 'currency')
f.set_type('po_total_calculated', 'currency')
f.set_type('invoice_unit_cost', 'currency')
f.set_type('invoice_total', 'currency')
f.set_type('invoice_total_calculated', 'currency')
# if self.creating:
# f.remove_fields(
# 'upc',
# 'product',
# 'po_total',
# 'invoice_total',
# )
# if self.batch_mode == self.enum.PURCHASE_BATCH_MODE_ORDERING:
# f.remove_fields('cases_received',
# 'units_received')
# elif self.batch_mode == self.enum.PURCHASE_BATCH_MODE_RECEIVING:
# f.remove_fields('cases_ordered',
# 'units_ordered')
# elif self.editing:
# f.set_readonly('upc')
# f.set_readonly('product')
# f.remove_fields('po_total',
# 'invoice_total',
# 'status_code')
# elif self.viewing:
# if row.product:
# f.remove_fields('brand_name',
# 'description',
# 'size')
# else:
# f.remove_field('product')
def mobile_new_product(self):
"""
View which allows user to create a new Product and add a row for it to
the Purchasing Batch.
"""
batch = self.get_instance()
batch_url = self.get_action_url('view', batch, mobile=True)
form = forms.Form(schema=self.make_new_product_schema(),
request=self.request,
mobile=True,
cancel_url=batch_url)
if form.validate(newstyle=True):
product = model.Product()
product.item_id = form.validated['item_id']
product.description = form.validated['description']
row = self.model_row_class()
row.product = product
self.handler.add_row(batch, row)
self.Session.flush()
return self.redirect(self.get_row_action_url('edit', row, mobile=True))
return self.render_to_response('new_product', {
'form': form,
'dform': form.make_deform_form(),
'instance_title': self.get_instance_title(batch),
'instance_url': batch_url,
}, mobile=True)
def make_new_product_schema(self):
"""
Must return a ``colander.Schema`` instance for use with the form in the
:meth:`mobile_new_product()` view.
"""
return NewProduct()
# def item_lookup(self, value, field=None):
# """
# Try to locate a single product using ``value`` as a lookup code.
@ -956,9 +827,9 @@ class PurchasingBatchView(BatchMasterView):
# return self.redirect(self.request.current_route_url())
# TODO: seems like this should be master behavior, controlled by setting?
def redirect_after_edit_row(self, row, mobile=False):
def redirect_after_edit_row(self, row, **kwargs):
parent = self.get_parent(row)
return self.redirect(self.get_action_url('view', parent, mobile=mobile))
return self.redirect(self.get_action_url('view', parent))
# def get_execute_success_url(self, batch, result, **kwargs):
# # if batch execution yielded a Purchase, redirect to it
@ -977,21 +848,12 @@ class PurchasingBatchView(BatchMasterView):
permission_prefix = cls.get_permission_prefix()
model_key = cls.get_model_key()
model_title = cls.get_model_title()
legacy_mobile = cls.legacy_mobile_enabled(rattail_config)
# eligible purchases (AJAX)
config.add_route('{}.eligible_purchases'.format(route_prefix), '{}/eligible-purchases'.format(url_prefix))
config.add_view(cls, attr='eligible_purchases', route_name='{}.eligible_purchases'.format(route_prefix),
renderer='json', permission='{}.view'.format(permission_prefix))
# add new product
if legacy_mobile and cls.supports_new_product:
config.add_tailbone_permission(permission_prefix, '{}.new_product'.format(permission_prefix),
"Create new Product when adding row to {}".format(model_title))
config.add_route('mobile.{}.new_product'.format(route_prefix), '{}/{{{}}}/new-product'.format(url_prefix, model_key))
config.add_view(cls, attr='mobile_new_product', route_name='mobile.{}.new_product'.format(route_prefix),
permission='{}.new_product'.format(permission_prefix))
@classmethod
def defaults(cls, config):