From 27919d0a4276cd5ae1f9d2d4cac2d79114c74464 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Mon, 22 Feb 2021 13:45:54 -0500 Subject: lttr: updated code to use custom templates per newsletter for mailings --- app/lttr/mailer.py | 4 +- app/lttr/models.py | 6 + .../templates/lttr/emails/friends_base_left.html | 176 --------------- .../templates/lttr/emails/range_html_email.html | 246 +++++++++++++++++++++ .../lttr/emails/range_plain_text_email.txt | 16 ++ app/lttr/templates/lttr/range_list.html | 2 +- 6 files changed, 271 insertions(+), 179 deletions(-) delete mode 100644 app/lttr/templates/lttr/emails/friends_base_left.html create mode 100644 app/lttr/templates/lttr/emails/range_html_email.html create mode 100644 app/lttr/templates/lttr/emails/range_plain_text_email.txt (limited to 'app') diff --git a/app/lttr/mailer.py b/app/lttr/mailer.py index 143fbf2..7a3ce3f 100644 --- a/app/lttr/mailer.py +++ b/app/lttr/mailer.py @@ -72,8 +72,8 @@ class SendShit(): """ subject = smart_str("%s: %s — %s" %(self.mailing.newsletter.title, self.mailing.get_issue_str(), self.mailing.title)) from_email, to = 'Scott Gilbertson ', subscriber.get_email() - text_content = render_to_string('lttr/emails/friends_plain_text_email.txt', {'object': self.mailing, 'subscriber':subscriber}) - html_content = render_to_string('lttr/emails/friends_html_email.html', {'object': self.mailing, 'subscriber':subscriber}) + text_content = render_to_string(self.newsletter.get_template_plain(), {'object': self.mailing, 'subscriber':subscriber}) + html_content = render_to_string(self.newsletter.get_template_html(), {'object': self.mailing, 'subscriber':subscriber}) #print(text_content) msg = EmailMultiAlternatives(subject, text_content, from_email, [to]) msg.attach_alternative(html_content, "text/html") diff --git a/app/lttr/models.py b/app/lttr/models.py index b3a18a3..93d66b6 100644 --- a/app/lttr/models.py +++ b/app/lttr/models.py @@ -72,6 +72,12 @@ class Newsletter(models.Model): def get_subscriptions(self): return Subscriber.objects.filter(newsletter=self, subscribed=True) + def get_template_plain(self): + return 'lttr/emails/%s_plain_text_email.txt' % self.slug + + def get_template_html(self): + return 'lttr/emails/%s_html_email.txt' % self.slug + def get_templates(self, action): """ Return a subject, text, HTML tuple with e-mail templates for diff --git a/app/lttr/templates/lttr/emails/friends_base_left.html b/app/lttr/templates/lttr/emails/friends_base_left.html deleted file mode 100644 index f2b91e6..0000000 --- a/app/lttr/templates/lttr/emails/friends_base_left.html +++ /dev/null @@ -1,176 +0,0 @@ -{% load typogrify_tags %} - - - - - - - Friends of a Long Year - - - - - - - - - -
-
- - - - -
-

-

- -

- {{object.pub_date|date:"F"}} {{object.pub_date|date:"j, Y"}}

- {{object.body_email_html|safe|smartypants}} -
-
-
- - - - - - - - - diff --git a/app/lttr/templates/lttr/emails/range_html_email.html b/app/lttr/templates/lttr/emails/range_html_email.html new file mode 100644 index 0000000..139ff33 --- /dev/null +++ b/app/lttr/templates/lttr/emails/range_html_email.html @@ -0,0 +1,246 @@ +{% load typogrify_tags %} + + + + + + + {{object.title}} + + + + + + + + + + + +
+
+ + + + +
+


+ ✪ Range — {{object.get_issue_str}} — {{object.pub_date|date:"F"}} {{object.pub_date|date:"j, Y"}}

+

{{object.title|safe|smartypants}}

+ +
+ + {% include "lib/friends_featured_img.html" with image=object.featured_image %} + +
+
+ + {{object.body_email_html|safe|smartypants}} + +
+
+
+
+ + + + + + + + + + diff --git a/app/lttr/templates/lttr/emails/range_plain_text_email.txt b/app/lttr/templates/lttr/emails/range_plain_text_email.txt new file mode 100644 index 0000000..28e9b2b --- /dev/null +++ b/app/lttr/templates/lttr/emails/range_plain_text_email.txt @@ -0,0 +1,16 @@ + +{{ object.email_encode|safe }} + +----- + +You're getting this email because you signed up for + +Scott Gilbertson's (luxagraf)[https://luxagraf.net/] photo newsletter, + +*Range* [https://luxagraf.net/newsletter/range/] + +If you're new, you can explore past letters here: [https://luxagraf.net/newsletter/range/] + +You can always: Unsubscribe [https://luxagraf.net{{subscriber.unsubscribe_activate_url}}] instantly. + +[https://luxagraf.net/] ✪ [https://luxagraf.net/newsletter/range/] diff --git a/app/lttr/templates/lttr/range_list.html b/app/lttr/templates/lttr/range_list.html index 6c29fb5..a2b16fc 100644 --- a/app/lttr/templates/lttr/range_list.html +++ b/app/lttr/templates/lttr/range_list.html @@ -17,7 +17,7 @@

Range

A weekly photo, developed.

Please join us by dropping your email in the form below:

- +

Range is a weekly mailing of a single photograph.

If you're interested there is also a link to a video of the RAW image processing in darktable, and sometimes a few words about the process. But the primary purpose is to deliver a single photo to your inbox. Simple and fun.

Yes, I know about Instagram. This is an attempt to reclaim that space, sharing photos with friends, but without all the distractions of the corporate social web, without the endless scroll of photos, likes, stories, comments, whatever. This is just an image delivered once a week to your inbox. I've been trying to think of a way to make it reciprocal, so you can send a picture to my inbox. If you have ideas, email me.

-- cgit v1.2.3-70-g09d2