From a551326ec05f761f58a0ba68b4ca8af95d9e652d Mon Sep 17 00:00:00 2001 From: luxagraf Date: Thu, 12 Nov 2020 10:39:33 -0500 Subject: rearranged email templates, added footer to plain text email. --- .gitignore | 2 + TODO | 12 + app/lttr/mailer.py | 7 +- app/lttr/models.py | 1 - .../templates/lttr/emails/friends_base_left.html | 176 ++++++++++++++ .../templates/lttr/emails/friends_html_email.html | 252 +++++++++++++++++++++ .../lttr/emails/friends_plain_text_email.txt | 16 ++ app/lttr/templates/lttr/friends_base.html | 252 --------------------- app/lttr/templates/lttr/friends_base_left.html | 176 -------------- config/requirements.txt | 75 ++++-- 10 files changed, 517 insertions(+), 452 deletions(-) create mode 100644 TODO create mode 100644 app/lttr/templates/lttr/emails/friends_base_left.html create mode 100644 app/lttr/templates/lttr/emails/friends_html_email.html create mode 100644 app/lttr/templates/lttr/emails/friends_plain_text_email.txt delete mode 100644 app/lttr/templates/lttr/friends_base.html delete mode 100644 app/lttr/templates/lttr/friends_base_left.html diff --git a/.gitignore b/.gitignore index 2ffd244..6c22812 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ siteold/ /*.json .vagrant/ *.log +current.sql +mammals.txt diff --git a/TODO b/TODO new file mode 100644 index 0000000..9eeff6c --- /dev/null +++ b/TODO @@ -0,0 +1,12 @@ +* add footer to plain text emails + + + + +Notes: + +Fix out of sequence postgres tables: + + +ALTER TABLE lttr_subscriber ALTER COLUMN id SET DEFAULT nextval('lttr_subscriber_id_seq'::regclass); +SELECT setval('lttr_subscriber_id_seq', (SELECT MAX(id) FROM lttr_subscriber)+1) diff --git a/app/lttr/mailer.py b/app/lttr/mailer.py index b5b875e..9972ea2 100644 --- a/app/lttr/mailer.py +++ b/app/lttr/mailer.py @@ -72,11 +72,12 @@ 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 = self.mailing.email_encode() - html_content = render_to_string('lttr/friends_base.html', {'object': self.mailing, 'subscriber':subscriber}) + 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}) + print(text_content) msg = EmailMultiAlternatives(subject, text_content, from_email, [to]) msg.attach_alternative(html_content, "text/html") - msg.send() + #msg.send() ''' for header, value in self.newsletter.server.custom_headers.items(): diff --git a/app/lttr/models.py b/app/lttr/models.py index 51f620c..f702478 100644 --- a/app/lttr/models.py +++ b/app/lttr/models.py @@ -157,7 +157,6 @@ class NewsletterMailing(models.Model): return issue def email_encode(self): - return self.body_markdown @property diff --git a/app/lttr/templates/lttr/emails/friends_base_left.html b/app/lttr/templates/lttr/emails/friends_base_left.html new file mode 100644 index 0000000..f2b91e6 --- /dev/null +++ b/app/lttr/templates/lttr/emails/friends_base_left.html @@ -0,0 +1,176 @@ +{% 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/friends_html_email.html b/app/lttr/templates/lttr/emails/friends_html_email.html new file mode 100644 index 0000000..42e7795 --- /dev/null +++ b/app/lttr/templates/lttr/emails/friends_html_email.html @@ -0,0 +1,252 @@ +{% load typogrify_tags %} + + + + + + + {{object.title}} + + + + + + + + + + + +
+
+ + + + +
+


+ Friends of a Long Year — {{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/friends_plain_text_email.txt b/app/lttr/templates/lttr/emails/friends_plain_text_email.txt new file mode 100644 index 0000000..729d83a --- /dev/null +++ b/app/lttr/templates/lttr/emails/friends_plain_text_email.txt @@ -0,0 +1,16 @@ + +{{ object.email_encode }} + +----- + +You're getting this email because you signed up for + +Scott Gilbertson's (luxagraf)[https://luxagraf.net/] newsletter, + +*Friends of a Long Year* [https://luxagraf.net/newsletter/friends/] + +If you're new, you can explore past letters here: [https://luxagraf.net/newsletter/friends/] + +You can always: Unsubscribe [https://luxagraf.net{{subscriber.unsubscribe_activate_url}}] instantly. + +[https://luxagraf.net/] ✪ [https://luxagraf.net/newsletter/friends/] diff --git a/app/lttr/templates/lttr/friends_base.html b/app/lttr/templates/lttr/friends_base.html deleted file mode 100644 index 42e7795..0000000 --- a/app/lttr/templates/lttr/friends_base.html +++ /dev/null @@ -1,252 +0,0 @@ -{% load typogrify_tags %} - - - - - - - {{object.title}} - - - - - - - - - - - -
-
- - - - -
-


- Friends of a Long Year — {{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/friends_base_left.html b/app/lttr/templates/lttr/friends_base_left.html deleted file mode 100644 index f2b91e6..0000000 --- a/app/lttr/templates/lttr/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/config/requirements.txt b/config/requirements.txt index 2bbeb1e..c9c8afb 100644 --- a/config/requirements.txt +++ b/config/requirements.txt @@ -1,33 +1,68 @@ -beautifulsoup4==4.7.1 -bleach==3.1.0 -certifi==2018.11.29 +asgiref==3.2.10 +backcall==0.1.0 +beautifulsoup4==4.6.3 +bleach==3.0.0 +boto==2.49.0 +cairocffi==0.9.0 +CairoSVG==2.2.1 +certifi==2018.8.24 +cffi==1.11.5 chardet==3.0.4 -Django==2.1.7 -django-bleach==0.5.1 -django-debug-toolbar==1.11 -django-extensions==2.1.6 +click==7.1.2 +cssselect==1.1.0 +cssselect2==0.2.1 +decorator==4.3.0 +defusedxml==0.5.0 +Django==3.1 +django-autocomplete-light==3.3.2 +django-bleach==0.3.0 +django-debug-toolbar==2.2 +django-extensions==3.0.4 django-gravatar2==1.4.2 -django-taggit==0.24.0 +django-ses==0.8.14 +django-taggit==1.3.0 django-typogrify==1.3.3 -EbookLib==0.17.1 -idna==2.8 +EbookLib==0.17 +future==0.18.2 +gpxpy==1.3.5 +html5lib==1.0.1 +idna==2.7 +ipython==7.1.1 +ipython-genutils==0.2.0 +jedi==0.13.1 Jinja2==2.10 jsmin==2.2.2 -lxml==4.3.1 +lxml==4.2.5 Markdown==3.0.1 -MarkupSafe==1.1.1 -Pillow==5.4.1 +MarkupSafe==1.0 +parsel==1.6.0 +parso==0.3.1 +pdfrw==0.4 +pexpect==4.6.0 +pickleshare==0.7.5 +Pillow==5.3.0 pkg-resources==0.0.0 -psycopg2==2.7.7 +prompt-toolkit==2.0.6 +psycopg2==2.7.5 psycopg2-binary==2.7.7 +ptyprocess==0.6.0 +pycparser==2.19 PyExifTool==0.1 -python-resize-image==1.1.18 -pytz==2018.9 -requests==2.21.0 -six==1.12.0 +Pygments==2.2.0 +Pyphen==0.9.5 +python-resize-image==1.1.17 +pytz==2018.5 +PyYAML==5.3.1 +requests==2.19.1 +selectorlib==0.16.0 +six==1.11.0 smartypants==2.0.1 -soupsieve==1.8 sqlparse==0.2.4 +tinycss2==0.6.1 +traitlets==4.3.2 typogrify==2.0.7 -urllib3==1.24.1 +urllib3==1.23 +w3lib==1.22.0 +wcwidth==0.1.7 +WeasyPrint==0.42.3 webencodings==0.5.1 -- cgit v1.2.3-70-g09d2