Improve email bounce view per buefy theme

This commit is contained in:
Lance Edgar 2021-12-23 12:34:57 -06:00
parent 494b1384c4
commit daa5126c21
2 changed files with 66 additions and 7 deletions

View file

@ -5,6 +5,7 @@
<%def name="extra_javascript()"> <%def name="extra_javascript()">
${parent.extra_javascript()} ${parent.extra_javascript()}
% if not use_buefy:
<script type="text/javascript"> <script type="text/javascript">
function autosize_message(scrolldown) { function autosize_message(scrolldown) {
@ -26,10 +27,20 @@
}); });
</script> </script>
% endif
</%def> </%def>
<%def name="extra_styles()"> <%def name="extra_styles()">
${parent.extra_styles()} ${parent.extra_styles()}
% if use_buefy:
<style type="text/css">
.email-message-body {
border: 1px solid #000000;
margin-top: 2rem;
height: 500px;
}
</style>
% else:
<style type="text/css"> <style type="text/css">
#message { #message {
border: 1px solid #000000; border: 1px solid #000000;
@ -38,23 +49,72 @@
padding: 4px; padding: 4px;
} }
</style> </style>
% endif
</%def>
<%def name="object_helpers()">
${parent.object_helpers()}
% if use_buefy:
<nav class="panel">
<p class="panel-heading">Processing</p>
<div class="panel-block">
<div class="display: flex; flex-align: column;">
% if bounce.processed:
<p class="block">
This bounce was processed
${h.pretty_datetime(request.rattail_config, bounce.processed)}
by ${bounce.processed_by}
</p>
% if master.has_perm('unprocess'):
<once-button type="is-warning"
tag="a" href="${url('emailbounces.unprocess', uuid=bounce.uuid)}"
text="Mark this bounce as UN-processed">
</once-button>
% endif
% else:
<p class="block">
This bounce has NOT yet been processed.
</p>
% if master.has_perm('process'):
<once-button type="is-primary"
tag="a" href="${url('emailbounces.process', uuid=bounce.uuid)}"
text="Mark this bounce as Processed">
</once-button>
% endif
% endif
</div>
</div>
</nav>
% endif
</%def> </%def>
<%def name="context_menu_items()"> <%def name="context_menu_items()">
${parent.context_menu_items()} ${parent.context_menu_items()}
% if not use_buefy:
% if not bounce.processed and request.has_perm('emailbounces.process'): % if not bounce.processed and request.has_perm('emailbounces.process'):
<li>${h.link_to("Mark this Email Bounce as Processed", url('emailbounces.process', uuid=bounce.uuid))}</li> <li>${h.link_to("Mark this Email Bounce as Processed", url('emailbounces.process', uuid=bounce.uuid))}</li>
% elif bounce.processed and request.has_perm('emailbounces.unprocess'): % elif bounce.processed and request.has_perm('emailbounces.unprocess'):
<li>${h.link_to("Mark this Email Bounce as UN-processed", url('emailbounces.unprocess', uuid=bounce.uuid))}</li> <li>${h.link_to("Mark this Email Bounce as UN-processed", url('emailbounces.unprocess', uuid=bounce.uuid))}</li>
% endif % endif
% endif
</%def> </%def>
<%def name="page_content()"> <%def name="page_content()">
${parent.page_content()} ${parent.page_content()}
% if not use_buefy:
<pre id="message"> <pre id="message">
${message} ${message}
</pre> </pre>
% endif
</%def> </%def>
<%def name="render_this_page()">
${parent.render_this_page()}
% if use_buefy:
<pre class="email-message-body">
${message}
</pre>
% endif
</%def>
${parent.body()} ${parent.body()}

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2021 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -147,6 +147,7 @@ class EmailBounceView(MasterView):
kwargs['message'] = "(file not found)" kwargs['message'] = "(file not found)"
return kwargs return kwargs
# TODO: should require POST here
def process(self): def process(self):
""" """
View for marking a bounce as processed. View for marking a bounce as processed.
@ -155,8 +156,9 @@ class EmailBounceView(MasterView):
bounce.processed = datetime.datetime.utcnow() bounce.processed = datetime.datetime.utcnow()
bounce.processed_by = self.request.user bounce.processed_by = self.request.user
self.request.session.flash("Email bounce has been marked processed.") self.request.session.flash("Email bounce has been marked processed.")
return self.redirect(self.request.route_url('emailbounces')) return self.redirect(self.get_action_url('view', bounce))
# TODO: should require POST here
def unprocess(self): def unprocess(self):
""" """
View for marking a bounce as *unprocessed*. View for marking a bounce as *unprocessed*.
@ -165,7 +167,7 @@ class EmailBounceView(MasterView):
bounce.processed = None bounce.processed = None
bounce.processed_by = None bounce.processed_by = None
self.request.session.flash("Email bounce has been marked UN-processed.") self.request.session.flash("Email bounce has been marked UN-processed.")
return self.redirect(self.request.route_url('emailbounces')) return self.redirect(self.get_action_url('view', bounce))
def download(self): def download(self):
""" """
@ -207,9 +209,6 @@ class EmailBounceView(MasterView):
cls._defaults(config) cls._defaults(config)
# TODO: deprecate / remove this
EmailBouncesView = EmailBounceView
def includeme(config): def includeme(config):
EmailBounceView.defaults(config) EmailBounceView.defaults(config)