From 5e27ceedcee5416df98468ad3fcae1db5210bb7f Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 27 Jan 2021 08:56:38 -0600 Subject: [PATCH] Hide "collect from wild" button for UOMs unless user has permission --- tailbone/templates/units-of-measure/index.mako | 4 ++++ tailbone/views/uoms.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tailbone/templates/units-of-measure/index.mako b/tailbone/templates/units-of-measure/index.mako index b29bad66..fb3a3219 100644 --- a/tailbone/templates/units-of-measure/index.mako +++ b/tailbone/templates/units-of-measure/index.mako @@ -4,6 +4,7 @@ <%def name="grid_tools()"> ${parent.grid_tools()} + % if master.has_perm('collect_wild_uoms'): + % endif <%def name="modify_this_page_vars()"> ${parent.modify_this_page_vars()} + % if master.has_perm('collect_wild_uoms'): + % endif diff --git a/tailbone/views/uoms.py b/tailbone/views/uoms.py index 11f80779..964401f1 100644 --- a/tailbone/views/uoms.py +++ b/tailbone/views/uoms.py @@ -112,6 +112,10 @@ class UnitOfMeasureView(MasterView): route_prefix = cls.get_route_prefix() url_prefix = cls.get_url_prefix() permission_prefix = cls.get_permission_prefix() + model_title_plural = cls.get_model_title_plural() + + # fix perm group name + config.add_tailbone_permission_group(permission_prefix, model_title_plural, overwrite=False) # collect wild uoms config.add_tailbone_permission(permission_prefix, '{}.collect_wild_uoms'.format(permission_prefix),