-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add functionality to send test emails from subscription model a…
…nd Wagtail admin
- Loading branch information
1 parent
c1e520e
commit 9c24b13
Showing
5 changed files
with
104 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{% extends "wagtailadmin/admin_base.html" %} | ||
{% load wagtailadmin_tags wagtailcore_tags i18n %} | ||
|
||
{% block furniture %} | ||
<template data-wagtail-sidebar-branding-logo>{% block branding_logo %}{% endblock %}</template> | ||
{% sidebar_props %} | ||
<aside id="wagtail-sidebar" class="sidebar-loading" data-wagtail-sidebar aria-label="{% trans 'Sidebar' %}"></aside> | ||
{% keyboard_shortcuts_dialog %} | ||
<main class="content-wrapper w-overflow-x-hidden" id="main"> | ||
<div class="content"> | ||
{# Always show messages div so it can be appended to by JS #} | ||
<div class="messages" role="status" data-controller="w-messages" data-action="w-messages:add@document->w-messages#add" data-w-messages-added-class="new" data-w-messages-show-class="appear" data-w-messages-show-delay-value="100"> | ||
<ul data-w-messages-target="container"> | ||
{% if messages %} | ||
{% for message in messages %} | ||
{% message_level_tag message as level_tag %} | ||
<li class="{% message_tags message %}"> | ||
{% if level_tag == "error" %} | ||
{# There is no error icon, use warning icon instead #} | ||
{% icon name="warning" classname="messages-icon" %} | ||
{% elif message.extra_tags == "lock" %} | ||
{% icon name="lock" classname="messages-icon" %} | ||
{% elif message.extra_tags == "unlock" %} | ||
{% icon name="lock-open" classname="messages-icon" %} | ||
{% else %} | ||
{% icon name=level_tag classname="messages-icon" %} | ||
{% endif %} | ||
{{ message|safe }} | ||
</li> | ||
{% endfor %} | ||
{% endif %} | ||
</ul> | ||
<template data-w-messages-target="template" data-type="success"> | ||
<li class="success">{% icon name="success" classname="messages-icon" %}<span></span></li> | ||
</template> | ||
<template data-w-messages-target="template" data-type="error"> | ||
<li class="error">{% icon name="warning" classname="messages-icon" %}<span></span></li> | ||
</template> | ||
<template data-w-messages-target="template" data-type="warning"> | ||
<li class="warning">{% icon name="warning" classname="messages-icon" %}<span></span></li> | ||
</template> | ||
</div> | ||
|
||
{% block content %}{% endblock %} | ||
</div> | ||
</main> | ||
<script> | ||
function sendTestEmail(subscriptionId) { | ||
fetch(`/blog/api/send-test-email/${subscriptionId}/`) | ||
.then(response => response.json()) | ||
.then(data => { | ||
alert(data.message); | ||
}) | ||
.catch((error) => { | ||
console.error('Error:', error); | ||
alert('An error occurred while sending the test email.'); | ||
}); | ||
} | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters