Hide "collect from wild" button for UOMs unless user has permission

This commit is contained in:
Lance Edgar 2021-01-27 08:56:38 -06:00
parent a927827e33
commit 5e27ceedce
2 changed files with 8 additions and 0 deletions

View file

@ -4,6 +4,7 @@
<%def name="grid_tools()"> <%def name="grid_tools()">
${parent.grid_tools()} ${parent.grid_tools()}
% if master.has_perm('collect_wild_uoms'):
<b-button type="is-primary" <b-button type="is-primary"
icon-pack="fas" icon-pack="fas"
icon-left="fas fa-shopping-basket" icon-left="fas fa-shopping-basket"
@ -47,10 +48,12 @@
</div> </div>
</b-modal> </b-modal>
% endif
</%def> </%def>
<%def name="modify_this_page_vars()"> <%def name="modify_this_page_vars()">
${parent.modify_this_page_vars()} ${parent.modify_this_page_vars()}
% if master.has_perm('collect_wild_uoms'):
<script type="text/javascript"> <script type="text/javascript">
TailboneGridData.showingCollectWildDialog = false TailboneGridData.showingCollectWildDialog = false
@ -60,6 +63,7 @@
} }
</script> </script>
% endif
</%def> </%def>

View file

@ -112,6 +112,10 @@ class UnitOfMeasureView(MasterView):
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()
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 # collect wild uoms
config.add_tailbone_permission(permission_prefix, '{}.collect_wild_uoms'.format(permission_prefix), config.add_tailbone_permission(permission_prefix, '{}.collect_wild_uoms'.format(permission_prefix),