Add button to raise bogus error, for testing email alerts

This commit is contained in:
Lance Edgar 2022-08-07 12:58:49 -05:00
parent 172dbba8aa
commit 6352a6dc9a

View file

@ -16,6 +16,57 @@
</b-field>
</div>
% if request.has_perm('errors.bogus'):
<h3 class="block is-size-3">Testing</h3>
<div class="block" style="padding-left: 2rem;">
<b-field grouped>
<p class="control">
You can raise a "bogus" error to test if/how it generates email:
</p>
<b-button type="is-primary"
@click="raiseBogusError()"
:disabled="raisingBogusError">
{{ raisingBogusError ? "Working, please wait..." : "Raise Bogus Error" }}
</b-button>
</b-field>
</div>
</h3>
% endif
</%def>
<%def name="modify_this_page_vars()">
${parent.modify_this_page_vars()}
% if request.has_perm('errors.bogus'):
<script type="text/javascript">
ThisPageData.raisingBogusError = false
ThisPage.methods.raiseBogusError = function() {
this.raisingBogusError = true
let url = '${url('bogus_error')}'
this.$http.get(url).then(response => {
this.$buefy.toast.open({
message: "Ironically, response was 200 which means we failed to raise an error!\n\nPlease investigate!",
type: 'is-danger',
duration: 5000, // 5 seconds
})
this.raisingBogusError = false
}, response => {
this.$buefy.toast.open({
message: "Error was raised; please check your email and/or logs.",
type: 'is-success',
duration: 4000, // 4 seconds
})
this.raisingBogusError = false
})
}
</script>
% endif
</%def>