Add separate perm for making new custorder for unknown product

This commit is contained in:
Lance Edgar 2023-10-25 14:06:40 -05:00
parent b5c68831b5
commit 441a6e5e0c

View file

@ -373,7 +373,8 @@ class CustomerOrderView(MasterView):
'allow_contact_info_create': self.batch_handler.allow_contact_info_creation(),
'order_items': items,
'product_key_label': app.get_product_key_label(),
'allow_unknown_product': self.batch_handler.allow_unknown_product(),
'allow_unknown_product': (self.batch_handler.allow_unknown_product()
and self.has_perm('create_unknown_product')),
'pending_product_required_fields': self.get_pending_product_required_fields(),
'unknown_product_confirm_price': self.rattail_config.getbool(
'rattail.custorders', 'unknown_product.always_confirm_price'),
@ -1143,8 +1144,15 @@ class CustomerOrderView(MasterView):
route_prefix = cls.get_route_prefix()
url_prefix = cls.get_url_prefix()
model_title = cls.get_model_title()
model_title_plural = cls.get_model_title_plural()
permission_prefix = cls.get_permission_prefix()
config.add_tailbone_permission_group(permission_prefix, model_title_plural, overwrite=False)
config.add_tailbone_permission(permission_prefix,
f'{permission_prefix}.create_unknown_product',
f"Create new {model_title} for unknown product")
# add pseudo-index page for creating new custorder
# (makes it available when building menus etc.)
config.add_tailbone_index_page('{}.create'.format(route_prefix),