🧑💻(views) render email's template
THis feature is inspired by Joanie. Add two new urls to render Emails HTML and Text templates. Developpers can render the email template they are working on. When necessary, run make mails-build, and reload `_debug__/mail/hello_html`, it will re-render the updated email template. Also, I have copy/pasted one template extra tags from Joanie, which loads bas64 string from static images. This code is necessary to render the dummy template `hello.html`.
This commit is contained in:
committed by
aleb_the_flash
parent
0141aa220f
commit
1919dce3a9
21
src/backend/debug/urls.py
Normal file
21
src/backend/debug/urls.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""Debug Urls to check the layout of emails"""
|
||||
|
||||
from django.urls import path
|
||||
|
||||
from .views import (
|
||||
DebugViewHtml,
|
||||
DebugViewTxt,
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
path(
|
||||
"__debug__/mail/hello_html",
|
||||
DebugViewHtml.as_view(),
|
||||
name="debug.mail.hello_html",
|
||||
),
|
||||
path(
|
||||
"__debug__/mail/hello_txt",
|
||||
DebugViewTxt.as_view(),
|
||||
name="debug.mail.hello_txt",
|
||||
),
|
||||
]
|
||||
29
src/backend/debug/views.py
Normal file
29
src/backend/debug/views.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""Debug Views to check the layout of emails"""
|
||||
|
||||
from django.views.generic.base import TemplateView
|
||||
|
||||
|
||||
class DebugBaseView(TemplateView):
|
||||
"""Debug View to check the layout of emails"""
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Generates sample datas to have a valid debug email"""
|
||||
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["title"] = "Development email preview"
|
||||
context["email"] = "random@gmail.com"
|
||||
context["fullname"] = "robert"
|
||||
|
||||
return context
|
||||
|
||||
|
||||
class DebugViewHtml(DebugBaseView):
|
||||
"""Debug View for HTML Email Layout"""
|
||||
|
||||
template_name = "mail/html/hello.html"
|
||||
|
||||
|
||||
class DebugViewTxt(DebugBaseView):
|
||||
"""Debug View for Text Email Layout"""
|
||||
|
||||
template_name = "mail/text/hello.txt"
|
||||
Reference in New Issue
Block a user