Skip to content

Commit

Permalink
Get rid of django-premailer
Browse files Browse the repository at this point in the history
It prevents us from using new versions of premailer, so we have removed it and built our own solution
  • Loading branch information
KHIT93 committed Nov 28, 2021
1 parent 899d052 commit 677077f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ django-appconf==1.0.5
django-cors-headers==3.7.0
django-cryptography==1.0
django-extensions==3.1.3
django-premailer==0.2.0
django-rest-auth==0.9.5
djangorestframework==3.12.4
geoip2==4.4.0
Expand Down
5 changes: 1 addition & 4 deletions src/core/templates/mailguardian/_layouts/master.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% load static %}
{% load premailer %}
{% load i18n %}
{% premailer "https://mailcleaner.khansen-it.dk" %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
Expand Down Expand Up @@ -52,5 +50,4 @@ <h1 class="font-bold no-underline text-gray-600">
</tr>
</table>
</body>
</html>
{% endpremailer %}
</html>
3 changes: 1 addition & 2 deletions src/mailguardian/settings/core_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
APP_HOSTNAME = platform.node()
APP_VERSION = '2.0.2'
APP_VERSION = '2.0.3'
LOCAL_CONFIG_VERSION = '0.0.0'
ALLOWED_HOSTS = ['*']

Expand All @@ -46,7 +46,6 @@
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
'django_premailer',
'core',
'compliance',
'frontend',
Expand Down
4 changes: 3 additions & 1 deletion src/reports/email_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datetime import datetime, timedelta
from django.conf import settings
from django.db.models import Q
from premailer import Premailer
import os

class QuarantinedEmailReport:
Expand Down Expand Up @@ -48,6 +49,7 @@ def process(self, queryset):
to_email = user.email
plaintext = render_to_string('quarantine_report.txt', context)
html = get_template('quarantine_report.html').render(context)
html_body = Premailer(html, base_url="{}://{}".format(context['protocol'], context['domain'])).transform()
email = EmailMultiAlternatives(self.subject, plaintext, self.from_email, [to_email])
email.attach_alternative(html, "text/html")
email.attach_alternative(html_body, "text/html")
email.send()
2 changes: 0 additions & 2 deletions upgrade-reqs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ django-appconf=>1.0.5
django-cors-headers=>3.10.0
django-cryptography=>1.0
django-extensions=>3.1.3
django-premailer=>0.2.0

django-rest-auth>=0.9.5
djangorestframework=>3.12.4
geoip2=>4.4.0
Expand Down

0 comments on commit 677077f

Please sign in to comment.