forked from qgis/QGIS-Django
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use smtp.gmail.com as EMAIL_HOST (qgis#356)
* Use GMAIL as email provider * Use a local setting for email auth * Update tests for new email * Merge migrations * Use environment variables for email sending
- Loading branch information
Showing
12 changed files
with
76 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ | |
"groups": [], | ||
"user_permissions": [], | ||
"password": "pbkdf2_sha256$150000$GJga5YEinaWz$zJAjCXccvWHNPGmoZEjvBNgm1DGkjZGA3BmTVaNAxP4=", | ||
"email": "", | ||
"email": "[email protected]", | ||
"date_joined": "2010-11-25 07:35:20" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Generated by Django 2.2.25 on 2024-02-04 23:16 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('plugins', '0007_auto_20240109_0428'), | ||
('plugins', '0006_plugin_display_created_by'), | ||
] | ||
|
||
operations = [ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
from django.core.files.uploadedfile import SimpleUploadedFile | ||
from plugins.models import Plugin, PluginVersion | ||
from plugins.forms import PluginVersionForm | ||
from django.core import mail | ||
from django.conf import settings | ||
|
||
def do_nothing(*args, **kwargs): | ||
pass | ||
|
@@ -90,6 +92,17 @@ def test_plugin_new_version(self): | |
self.assertEqual(self.plugin.tracker, "https://github.com/") | ||
self.assertEqual(self.plugin.repository, "https://github.com/") | ||
|
||
self.assertEqual( | ||
mail.outbox[0].recipients(), | ||
['[email protected]', '[email protected]'] | ||
) | ||
|
||
# Should use the new email | ||
self.assertEqual( | ||
mail.outbox[0].from_email, | ||
settings.EMAIL_HOST_USER | ||
) | ||
|
||
@patch("plugins.tasks.generate_plugins_xml.delay", new=do_nothing) | ||
@patch("plugins.validator._check_url_link", new=do_nothing) | ||
def test_plugin_version_update(self): | ||
|
@@ -131,6 +144,17 @@ def test_plugin_version_update(self): | |
self.assertEqual(self.plugin.tracker, "https://github.com/") | ||
self.assertEqual(self.plugin.repository, "https://github.com/") | ||
|
||
self.assertEqual( | ||
mail.outbox[0].recipients(), | ||
['[email protected]', '[email protected]'] | ||
) | ||
|
||
# Should use the new email | ||
self.assertEqual( | ||
mail.outbox[0].from_email, | ||
settings.EMAIL_HOST_USER | ||
) | ||
|
||
|
||
def tearDown(self): | ||
self.client.logout() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
from django.core.files.uploadedfile import SimpleUploadedFile | ||
from plugins.models import Plugin, PluginVersion | ||
from plugins.forms import PackageUploadForm | ||
from django.core import mail | ||
from django.conf import settings | ||
|
||
def do_nothing(*args, **kwargs): | ||
pass | ||
|
@@ -67,5 +69,15 @@ def test_plugin_upload_form(self): | |
3) | ||
self.assertTrue(PluginVersion.objects.filter(plugin__name='Test Plugin', version='0.0.1').exists()) | ||
|
||
self.assertEqual( | ||
mail.outbox[0].recipients(), | ||
['[email protected]', '[email protected]'] | ||
) | ||
|
||
# Should use the new email | ||
self.assertEqual( | ||
mail.outbox[0].from_email, | ||
settings.EMAIL_HOST_USER | ||
) | ||
def tearDown(self): | ||
self.client.logout() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
from plugins.models import Plugin, PluginVersion, PluginVersionFeedback | ||
from plugins.views import version_feedback_notify | ||
|
||
from django.conf import settings | ||
|
||
class SetupMixin: | ||
fixtures = ["fixtures/auth.json", "fixtures/simplemenu.json"] | ||
|
@@ -89,6 +89,12 @@ def test_version_feedback_notify_sent(self): | |
['[email protected]'] | ||
) | ||
|
||
# Should use the new email | ||
self.assertEqual( | ||
mail.outbox[0].from_email, | ||
settings.EMAIL_HOST_USER | ||
) | ||
|
||
def test_add_recipient_in_email_notification(self): | ||
self.creator.email = '[email protected]' | ||
self.creator.save() | ||
|
@@ -108,6 +114,12 @@ def test_add_recipient_in_email_notification(self): | |
['[email protected]', '[email protected]'] | ||
) | ||
|
||
# Should use the new email | ||
self.assertEqual( | ||
mail.outbox[0].from_email, | ||
settings.EMAIL_HOST_USER | ||
) | ||
|
||
|
||
class TestPluginFeedbackReceivedList(SetupMixin, TestCase): | ||
fixtures = ["fixtures/simplemenu.json", "fixtures/auth.json"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,7 +219,7 @@ | |
|
||
INTERNAL_IPS = ("127.0.0.1",) | ||
|
||
DEFAULT_FROM_EMAIL = "[email protected]" | ||
DEFAULT_FROM_EMAIL = os.environ.get("EMAIL_HOST_USER", "automation") | ||
|
||
|
||
# TINYMCE_JS_URL = 'http://debug.example.org/tiny_mce/tiny_mce_src.js' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ HAYSTACK_WHOOSH_PATH = '/home/web/qgis-django/search-index' | |
# Tim Email settings | ||
EMAIL_HOST = 'localhost' | ||
#EMAIL_PORT = | ||
DEFAULT_FROM_EMAIL = '[email protected]' | ||
DEFAULT_FROM_EMAIL = os.environ.get("EMAIL_HOST_USER", "automation") | ||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.auth', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,7 +156,7 @@ | |
# Tim Email settings | ||
EMAIL_HOST = "localhost" | ||
# EMAIL_PORT = | ||
DEFAULT_FROM_EMAIL = "[email protected]" | ||
DEFAULT_FROM_EMAIL = os.environ.get("EMAIL_HOST_USER", "automation") | ||
|
||
INSTALLED_APPS = [ | ||
"django.contrib.auth", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,12 @@ def test_upload_xml_file(self): | |
['[email protected]'] | ||
) | ||
|
||
# Should use the new email | ||
self.assertEqual( | ||
mail.outbox[0].from_email, | ||
settings.EMAIL_HOST_USER | ||
) | ||
|
||
# style should be in Waiting Review | ||
url = reverse("style_unapproved") | ||
self.response = self.client.get(url) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,7 +156,7 @@ | |
# Tim Email settings | ||
EMAIL_HOST = "localhost" | ||
# EMAIL_PORT = | ||
DEFAULT_FROM_EMAIL = "[email protected]" | ||
DEFAULT_FROM_EMAIL = os.environ.get("EMAIL_HOST_USER", "automation") | ||
|
||
INSTALLED_APPS = [ | ||
"django.contrib.auth", | ||
|