Add dedicated perm for replacing poser report module
This commit is contained in:
parent
72177aef0a
commit
d99f2541df
|
@ -3,10 +3,12 @@
|
||||||
|
|
||||||
<%def name="render_form_buttons()">
|
<%def name="render_form_buttons()">
|
||||||
<div v-if="!showUploadForm" class="buttons">
|
<div v-if="!showUploadForm" class="buttons">
|
||||||
|
% if master.has_perm('replace'):
|
||||||
<b-button type="is-primary"
|
<b-button type="is-primary"
|
||||||
@click="heckYeah()">
|
@click="showUploadForm = true">
|
||||||
Upload Replacement Module
|
Upload Replacement Module
|
||||||
</b-button>
|
</b-button>
|
||||||
|
% endif
|
||||||
<once-button type="is-primary"
|
<once-button type="is-primary"
|
||||||
tag="a"
|
tag="a"
|
||||||
% if instance.get('error'):
|
% if instance.get('error'):
|
||||||
|
@ -17,6 +19,7 @@
|
||||||
text="Generate this Report">
|
text="Generate this Report">
|
||||||
</once-button>
|
</once-button>
|
||||||
</div>
|
</div>
|
||||||
|
% if master.has_perm('replace'):
|
||||||
<div v-if="showUploadForm">
|
<div v-if="showUploadForm">
|
||||||
${h.form(master.get_action_url('replace', instance), enctype='multipart/form-data', **{'@submit': 'uploadSubmitting = true'})}
|
${h.form(master.get_action_url('replace', instance), enctype='multipart/form-data', **{'@submit': 'uploadSubmitting = true'})}
|
||||||
${h.csrf_token(request)}
|
${h.csrf_token(request)}
|
||||||
|
@ -55,10 +58,12 @@
|
||||||
</b-field>
|
</b-field>
|
||||||
${h.end_form()}
|
${h.end_form()}
|
||||||
</div>
|
</div>
|
||||||
|
% 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('replace'):
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
${form.component_studly}Data.showUploadForm = false
|
${form.component_studly}Data.showUploadForm = false
|
||||||
|
@ -67,11 +72,8 @@
|
||||||
|
|
||||||
${form.component_studly}Data.uploadSubmitting = false
|
${form.component_studly}Data.uploadSubmitting = false
|
||||||
|
|
||||||
${form.component_studly}.methods.heckYeah = function() {
|
|
||||||
this.showUploadForm = true
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
${parent.body()}
|
${parent.body()}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2021 Lance Edgar
|
# Copyright © 2010-2022 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -87,7 +87,7 @@ class AuthenticationView(View):
|
||||||
# Store current URL in session, for smarter redirect after login.
|
# Store current URL in session, for smarter redirect after login.
|
||||||
self.request.session['next_url'] = self.request.current_route_url()
|
self.request.session['next_url'] = self.request.current_route_url()
|
||||||
next_url = self.request.route_url('login')
|
next_url = self.request.route_url('login')
|
||||||
self.request.session.flash(msg, allow_duplicate=False)
|
self.request.session.flash(msg, 'warning', allow_duplicate=False)
|
||||||
return self.redirect(next_url)
|
return self.redirect(next_url)
|
||||||
|
|
||||||
def login(self, **kwargs):
|
def login(self, **kwargs):
|
||||||
|
|
|
@ -252,22 +252,26 @@ class PoserReportView(MasterView):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def defaults(cls, config):
|
def defaults(cls, config):
|
||||||
cls._poser_report_defaults(config)
|
|
||||||
cls._defaults(config)
|
cls._defaults(config)
|
||||||
|
cls._poser_report_defaults(config)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _poser_report_defaults(cls, config):
|
def _poser_report_defaults(cls, config):
|
||||||
route_prefix = cls.get_route_prefix()
|
route_prefix = cls.get_route_prefix()
|
||||||
|
permission_prefix = cls.get_permission_prefix()
|
||||||
instance_url_prefix = cls.get_instance_url_prefix()
|
instance_url_prefix = cls.get_instance_url_prefix()
|
||||||
|
model_title = cls.get_model_title()
|
||||||
|
|
||||||
# replace module
|
# replace module
|
||||||
|
config.add_tailbone_permission(permission_prefix,
|
||||||
|
'{}.replace'.format(permission_prefix),
|
||||||
|
"Upload replacement module for {}".format(model_title))
|
||||||
config.add_route('{}.replace'.format(route_prefix),
|
config.add_route('{}.replace'.format(route_prefix),
|
||||||
'{}/replace'.format(instance_url_prefix),
|
'{}/replace'.format(instance_url_prefix),
|
||||||
request_method='POST')
|
request_method='POST')
|
||||||
config.add_view(cls, attr='replace',
|
config.add_view(cls, attr='replace',
|
||||||
route_name='{}.replace'.format(route_prefix),
|
route_name='{}.replace'.format(route_prefix),
|
||||||
# TODO: requires root, should add custom permission?
|
permission='{}.replace'.format(permission_prefix))
|
||||||
permission='admin')
|
|
||||||
|
|
||||||
|
|
||||||
class PoserReportSchema(colander.MappingSchema):
|
class PoserReportSchema(colander.MappingSchema):
|
||||||
|
|
Loading…
Reference in a new issue