From 45c222c4e46e14af9bb5a153734eaa32c02f8ab5 Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Wed, 11 Jan 2023 15:05:51 +0100 Subject: [PATCH 1/3] Move badge from Travis-CI to GH actions and prepare a GH action to automatically publish new releases upon tagging --- .github/workflows/publish.yml | 36 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 2 +- README.md | 7 ++++--- 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..414eb270 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,36 @@ +name: Publish django-post_office + +on: + push: + tags: + - '*' + +jobs: + publish: + name: "Publish release" + runs-on: "ubuntu-latest" + + environment: + name: deploy + + strategy: + matrix: + python-version: ["3.9"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install build --user + - name: Build 🐍 Python 📦 Package + run: python -m build --sdist --wheel --outdir dist/ + - name: Publish 🐍 Python 📦 Package to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_API_TOKEN_POST_OFFICE }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 015aed08..dc6b9fda 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,4 +35,4 @@ jobs: - name: Run Test run: | - `which django-admin` test post_office --settings=post_office.test_settings --pythonpath=. \ No newline at end of file + `which django-admin` test post_office --settings=post_office.test_settings --pythonpath=. diff --git a/README.md b/README.md index b498f20c..b5aa711e 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,11 @@ will otherwise be stripped for security reasons. ## Installation -[![Build -Status](https://travis-ci.org/ui/django-post_office.png?branch=master)](https://travis-ci.org/ui/django-post_office) [![PyPI version](https://img.shields.io/pypi/v/django-post_office.svg)](https://pypi.org/project/django-post_office/) ![Software license](https://img.shields.io/pypi/l/django-post_office.svg) +[![Build Status](https://github.com/ui/django-post_office/actions/workflows/test.yml/badge.svg)](https://github.com/ui/django-post_office/actions) +[![PyPI](https://img.shields.io/pypi/pyversions/django-post_office.svg)]() +[![PyPI version](https://img.shields.io/pypi/v/django-post_office.svg)](https://pypi.python.org/pypi/django-post_office) +[![PyPI](https://img.shields.io/pypi/l/django-post_office.svg)]() -Install from PyPI (or [manually download from PyPI](http://pypi.python.org/pypi/django-post_office)): ```sh pip install django-post_office From 89db033b1f21a490d58d3f0df0a2f0f932af1135 Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Fri, 13 Jan 2023 17:00:42 +0100 Subject: [PATCH 2/3] attempt to fix failing test_email_change_view --- post_office/tests/test_html_email.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/post_office/tests/test_html_email.py b/post_office/tests/test_html_email.py index 8dbc2186..eeeb86d1 100644 --- a/post_office/tests/test_html_email.py +++ b/post_office/tests/test_html_email.py @@ -148,12 +148,13 @@ def test_email_change_view(self): msg.send() # check that in the Email's detail view, the message is rendered + self.assertEqual(Email.objects.count(), 1) # TODO: remove this email = Email.objects.latest('id') parts = email.email_message().message().walk() part = next(parts) - self.assertEqual(part.get_content_type(), 'multipart/mixed') + self.assertIsInstance(part, SafeMIMEMultipart) part = next(parts) - self.assertEqual(part.get_content_type(), 'text/html') + self.assertIsInstance(part, SafeMIMEText) part = next(parts) self.assertEqual(part.get_content_type(), 'image/png') content_id = part['Content-Id'][1:33] From 90237535c842469aeb1272671b1dd04670d4b944 Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Fri, 13 Jan 2023 17:01:12 +0100 Subject: [PATCH 3/3] add missing import to documentation --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b5aa711e..ac178445 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,7 @@ inlined images, use the following code snippet: ```python from django.core.mail import EmailMultiAlternatives +from django.template.loader import get_template subject, body = "Hello", "Plain text body" from_email, to_email = "no-reply@example.com", "john@example.com" @@ -329,6 +330,7 @@ plain text body, use this code snippet: ```python from django.core.mail import EmailMultiAlternatives +from django.template.loader import get_template subject, from_email, to_email = "Hello", "no-reply@example.com", "john@example.com" template = get_template('email-template-name.html', using='post_office')