Skip to content

Commit 6440f12

Browse files
authored
Merge pull request #139 from vintasoftware/feat/update-to-3.0.1
Bump version: 3.0.0 → 3.0.1
2 parents cba05a7 + 989235d commit 6440f12

19 files changed

+241
-205
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
[bumpversion]
2-
current_version = 2.3.0
2+
current_version = 3.0.1
33
commit = True
44
tag = True
55
tag_name = {new_version}
66

77
[bumpversion:file:setup.py]
88
search = VERSION = '{current_version}'
99
replace = VERSION = '{new_version}'
10-

.travis.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11
language: python
22

33
python:
4-
- "3.5"
5-
6-
env:
7-
- TOX_ENV=py27-flake8
8-
- TOX_ENV=py35-django110
9-
- TOX_ENV=py34-django110
10-
- TOX_ENV=py27-django110
11-
- TOX_ENV=py35-django19
12-
- TOX_ENV=py34-django19
13-
- TOX_ENV=py27-django19
14-
- TOX_ENV=py35-django18
15-
- TOX_ENV=py34-django18
16-
- TOX_ENV=py27-django18
4+
- "3.6"
5+
- "3.7"
6+
- "3.8"
7+
- "3.9"
178

189
install:
19-
- pip install tox
10+
- pip install tox-travis
2011
- pip install -r requirements.txt
2112
- pip install coveralls
2213

2314
script:
24-
- tox -e $TOX_ENV
15+
- tox
2516

2617
after_script:
2718
coveralls

CHANGELOG

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
v3.0.1
2+
-----
3+
Remove all newlines from subject
4+
5+
v3.0
6+
-----
7+
Add escaping to HTML parts in templates
8+
Add tests for django main version
9+
10+
v2.4
11+
-----
12+
Add Python 3.7, 3.8 and 3.9 support
13+
Drop Python <3.4 support
14+
Add Django 3.1 and 3.2 support
15+
Drop Django 3.0 support
16+
Remove six dependency
17+
118
v2.3
219
-----
320
Remove Django as explicit dependency

README.rst

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ develop branch: https://github.com/vintasoftware/django-templated-email/blob/dev
2424

2525
stable pypi/master: https://github.com/vintasoftware/django-templated-email/blob/master/README.rst
2626

27+
28+
Requirements
29+
=================
30+
* Python (3.6, 3.7, 3.8, 3.9)
31+
* Django (2.2, 3.1, 3.2)
32+
33+
We **highly recommend** and only officially support the latest patch release of
34+
each Python and Django series.
35+
36+
2737
Getting going - installation
2838
==============================
2939

@@ -185,8 +195,8 @@ First get the image content from a file or a *ImageField*:
185195
.. code-block:: python
186196
187197
# From a file
188-
with open('lena.png', 'rb') as lena:
189-
image = lena.read()
198+
with open('pikachu.png', 'rb') as pikachu:
199+
image = pikachu.read()
190200
191201
# From an ImageField
192202
# Suppose we have this model
@@ -201,7 +211,7 @@ Then create an instance of *InlineImage*:
201211
202212
from templated_email import InlineImage
203213
204-
inline_image = InlineImage(filename="lena.png", content=image)
214+
inline_image = InlineImage(filename="pikachu.png", content=image)
205215
206216
Now pass the object on the context to the template when you send the email.
207217
@@ -210,13 +220,13 @@ Now pass the object on the context to the template when you send the email.
210220
send_templated_mail(template_name='welcome',
211221
from_email='[email protected]',
212222
recipient_list=['[email protected]'],
213-
context={'lena_image': inline_image})
223+
context={'pikachu_image': inline_image})
214224
215225
Finally in your template add the image on the html template block:
216226
217227
.. code-block:: html
218228
219-
<img src="{{ lena_image }}">
229+
<img src="{{ pikachu_image }}">
220230
221231
Note: All *InlineImage* objects you add to the context will be attached to the e-mail, even if they are not used in the template.
222232
@@ -315,6 +325,7 @@ Methods:
315325
**templated_email_get_recipients(self, form)** (mandatory):
316326
Return the recipient list to whom the email will be sent to.
317327
ie:
328+
318329
.. code-block:: python
319330
320331
def templated_email_get_recipients(self, form):
@@ -324,6 +335,7 @@ Methods:
324335
Use this method to add extra data to the context used for rendering the template. You should get the parent class's context from
325336
calling super.
326337
ie:
338+
327339
.. code-block:: python
328340
329341
def templated_email_get_context_data(self, **kwargs):
@@ -334,6 +346,7 @@ Methods:
334346
**templated_email_get_send_email_kwargs(self, valid, form)** (optional):
335347
Add or change the kwargs that will be used to send the e-mail. You should call super to get the default kwargs.
336348
ie:
349+
337350
.. code-block:: python
338351
339352
def templated_email_get_send_email_kwargs(valid, form):
@@ -356,7 +369,7 @@ Using django_templated_email in 3rd party applications
356369

357370
If you would like to use django_templated_email to handle mail in a reusable application, you should note that:
358371

359-
* Your calls to **send_templated_mail** should set a value for **template_dir**, so you can keep copies of your app-specific templates local to your app (although the loader will find your email templates if you store them in *<your app>/templates/templated_email*, if **TEMPLATED_EMAIL_TEMPLATE_DIR** has not been overidden)
372+
* Your calls to **send_templated_mail** should set a value for **template_dir**, so you can keep copies of your app-specific templates local to your app (although the loader will find your email templates if you store them in *<your app>/templates/templated_email*, if **TEMPLATED_EMAIL_TEMPLATE_DIR** has not been overridden)
360373
* If you do (and you should) set a value for **template_dir**, remember to include a trailing slash, i.e. *'my_app_email/'*
361374
* The deployed app may use a different backend which doesn't use the django templating backend, and as such make a note in your README warning developers that if they are using django_templated_email already, with a different backend, they will need to ensure their email provider can send all your templates (ideally enumerate those somewhere convenient)
362375

@@ -402,21 +415,25 @@ Execute the following commands::
402415

403416
bumpversion [major,minor,patch]
404417
python setup.py publish
405-
git push origin master --tags
418+
git push origin --tags
406419

407420

408421
Commercial Support
409422
==================
410423

411-
This library, as others, is used in projects of Vinta clients. We are always looking for exciting work, so if you need any commercial support, feel free to get in touch: [email protected]
424+
.. image:: https://avatars2.githubusercontent.com/u/5529080?s=80&v=4
425+
:alt: Vinta Logo
426+
:target: https://www.vinta.com.br
427+
428+
This project, as other `Vinta Software <https://www.vinta.com.br/>`_ open-source projects is used in products of Vinta's clients. We are always looking for exciting work, so if you need any commercial support, feel free to get in touch: [email protected]
412429

413430

414431

415432
.. _Django: http://djangoproject.com
416433
.. |GitterBadge| image:: https://badges.gitter.im/vintasoftware/django-templated-email.svg
417434
.. _GitterBadge: https://gitter.im/vintasoftware/django-templated-email?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
418-
.. |TravisBadge| image:: https://travis-ci.org/vintasoftware/django-templated-email.svg?branch=develop
419-
.. _TravisBadge: https://travis-ci.org/vintasoftware/django-templated-email
435+
.. |TravisBadge| image:: https://travis-ci.com/vintasoftware/django-templated-email.svg?branch=develop
436+
.. _TravisBadge: https://travis-ci.com/vintasoftware/django-templated-email
420437
.. |CoverageBadge| image:: https://coveralls.io/repos/github/vintasoftware/django-templated-email/badge.svg?branch=develop
421438
.. _CoverageBadge: https://coveralls.io/github/vintasoftware/django-templated-email?branch=develop
422439
.. |PypiversionBadge| image:: https://img.shields.io/pypi/v/django-templated-email.svg

setup.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
from setuptools import setup, find_packages
44

55
DESCRIPTION = "A Django oriented templated / transaction email abstraction"
6-
VERSION = '2.3.0'
6+
VERSION = '3.0.1'
77
LONG_DESCRIPTION = None
88
try:
99
LONG_DESCRIPTION = open('README.rst').read()
1010
except:
1111
pass
1212

1313
requirements = [
14-
'django-render-block>=0.5',
15-
'six>=1',
14+
'django-render-block>=0.5'
1615
]
1716

1817
# python setup.py publish
@@ -25,12 +24,10 @@
2524
'Intended Audience :: Developers',
2625
'License :: OSI Approved :: MIT License',
2726
'Operating System :: OS Independent',
28-
'Programming Language :: Python :: 2',
29-
'Programming Language :: Python :: 2.7',
30-
'Programming Language :: Python :: 3',
31-
'Programming Language :: Python :: 3.4',
32-
'Programming Language :: Python :: 3.5',
3327
'Programming Language :: Python :: 3.6',
28+
'Programming Language :: Python :: 3.7',
29+
'Programming Language :: Python :: 3.8',
30+
'Programming Language :: Python :: 3.9',
3431
'Topic :: Software Development :: Libraries :: Python Modules',
3532
'Framework :: Django',
3633
]
@@ -46,6 +43,7 @@
4643
license='MIT',
4744
description=DESCRIPTION,
4845
long_description=LONG_DESCRIPTION,
46+
long_description_content_type='text/x-rst',
4947
platforms=['any'],
5048
classifiers=CLASSIFIERS,
5149
install_requires=requirements,

templated_email/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from django.conf import settings
22
from django.utils.module_loading import import_string
33

4-
import six
5-
64
from templated_email.backends.vanilla_django import TemplateBackend
75
from templated_email.utils import InlineImage # noqa
86

@@ -20,7 +18,7 @@ def get_connection(backend=None, template_prefix=None, template_suffix=None,
2018
# django.core.mail.get_connection
2119
klass_path = backend or getattr(settings, 'TEMPLATED_EMAIL_BACKEND',
2220
TemplateBackend)
23-
if isinstance(klass_path, six.string_types):
21+
if isinstance(klass_path, str):
2422
try:
2523
# First check if class name is omitted and we have module in settings
2624
klass = import_string(klass_path + '.' + 'TemplateBackend')

templated_email/backends/vanilla_django.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.conf import settings
66
from django.core.mail import get_connection
77
from django.template import Context
8-
from django.utils.translation import ugettext as _
8+
from django.utils.translation import gettext as _
99
from django.core.files.storage import default_storage
1010

1111
from templated_email.utils import (
@@ -82,7 +82,6 @@ def _render_email(self, template_name, context,
8282
template_dir=None, file_extension=None):
8383
response = {}
8484
errors = {}
85-
render_context = Context(context, autoescape=False)
8685

8786
file_extension = file_extension or self.template_suffix
8887
if file_extension.startswith('.'):
@@ -102,6 +101,7 @@ def _render_email(self, template_name, context,
102101
full_template_names.append(one_full_template_name)
103102

104103
for part in ['subject', 'html', 'plain']:
104+
render_context = Context(context, autoescape=(part == 'html'))
105105
try:
106106
response[part] = render_block_to_string(full_template_names, part, render_context)
107107
except BlockNotFound as error:
@@ -158,7 +158,7 @@ def get_email_message(self, template_name, context, from_email=None, to=None,
158158
subject_template = subject_dict.get(template_name,
159159
_('%s email subject' % template_name))
160160
subject = subject_template % context
161-
subject = subject.strip('\n\r') # strip newlines from subject
161+
subject = subject.strip('\n\r').replace('\n', ' ').replace('\r', ' ') # strip newlines from subject
162162

163163
if not plain_part:
164164
plain_part = self._generate_plain_part(parts)

templated_email/migrations/0001_initial.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22
# Generated by Django 1.10 on 2016-10-05 17:09
3-
from __future__ import unicode_literals
43

54
from django.db import migrations, models
65
import uuid

templated_email/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from django.conf.urls import url
1+
from django.urls import re_path
22

33
from templated_email.views import ShowEmailView
44

55
app_name = 'templated_email'
66
urlpatterns = [
7-
url(r'^email/(?P<uuid>([a-f\d]{32})|([a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12}))/$', ShowEmailView.as_view(), name='show_email'),
7+
re_path(r'^email/(?P<uuid>([a-f\d]{32})|([a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12}))/$', ShowEmailView.as_view(), name='show_email'),
88
]

templated_email/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
from django.utils.module_loading import import_string
77
from django.conf import settings
88

9-
import six
10-
119

1210
def _get_klass_from_config(config_variable, default):
1311
klass_path = getattr(settings, config_variable, default)
14-
if isinstance(klass_path, six.string_types):
12+
if isinstance(klass_path, str):
1513
klass_path = import_string(klass_path)
1614

1715
return klass_path

0 commit comments

Comments
 (0)