diff --git a/tailbone/templates/products/view.mako b/tailbone/templates/products/view.mako index cac17f1a..0d0b2650 100644 --- a/tailbone/templates/products/view.mako +++ b/tailbone/templates/products/view.mako @@ -93,21 +93,9 @@ <%def name="render_main_fields(form)"> - ${form.render_field_readonly(product_key_field)} - ${form.render_field_readonly('brand')} - ${form.render_field_readonly('description')} - ${form.render_field_readonly('size')} - ${form.render_field_readonly('unit_size')} - ${form.render_field_readonly('unit_of_measure')} - ${form.render_field_readonly('average_weight')} - ${form.render_field_readonly('case_size')} - % if instance.is_pack_item(): - ${form.render_field_readonly('pack_size')} - ${form.render_field_readonly('unit')} - ${form.render_field_readonly('default_pack')} - % elif instance.packs: - ${form.render_field_readonly('packs')} - % endif + % for field in panel_fields['main']: + ${form.render_field_readonly(field)} + % endfor ${self.extra_main_fields(form)} @@ -201,13 +189,9 @@ <%def name="render_flag_fields(form)"> - ${form.render_field_readonly('weighed')} - ${form.render_field_readonly('discountable')} - ${form.render_field_readonly('special_order')} - ${form.render_field_readonly('organic')} - ${form.render_field_readonly('not_for_sale')} - ${form.render_field_readonly('discontinued')} - ${form.render_field_readonly('deleted')} + % for field in panel_fields['flag']: + ${form.render_field_readonly(field)} + % endfor <%def name="movement_panel()"> diff --git a/tailbone/views/products.py b/tailbone/views/products.py index 8357c895..0e6321fd 100644 --- a/tailbone/views/products.py +++ b/tailbone/views/products.py @@ -1269,8 +1269,55 @@ class ProductView(MasterView): kwargs['vendor_sources'] = self.get_context_vendor_sources(product) kwargs['lookup_codes'] = self.get_context_lookup_codes(product) + kwargs['panel_fields'] = self.get_panel_fields(product) + return kwargs + def get_panel_fields(self, product): + return { + 'main': self.get_panel_fields_main(product), + 'flag': self.get_panel_fields_flag(product), + } + + def get_panel_fields_main(self, product): + key = self.rattail_config.product_key() + product_key_field = self.product_key_fields.get(key, key) + fields = [ + product_key_field, + 'brand', + 'description', + 'size', + 'unit_size', + 'unit_of_measure', + 'average_weight', + 'case_size', + ] + if product.is_pack_item(): + fields.extend([ + 'pack_size', + 'unit', + 'default_pack', + ]) + elif product.packs: + fields.append('packs') + + for supp in self.iter_view_supplements(): + if hasattr(supp, 'get_panel_fields_main'): + fields.extend(supp.get_panel_fields_main(product)) + + return fields + + def get_panel_fields_flag(self, product): + return [ + 'weighed', + 'discountable', + 'special_order', + 'organic', + 'not_for_sale', + 'discontinued', + 'deleted', + ] + def get_context_vendor_sources(self, product): app = self.get_rattail_app() route_prefix = self.get_route_prefix()