-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from OpenLXP/ses_update
Ses update
- Loading branch information
Showing
16 changed files
with
122 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[ | ||
{ | ||
"model": "openlxp_notifications.email", | ||
"pk": 1, | ||
"fields": { | ||
"sender": "[email protected]", | ||
"reference": "Subscribed_list_update", | ||
"subject": 1, | ||
"template_type": 1, | ||
"recipients": [] | ||
} | ||
} | ||
] |
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,9 @@ | ||
[ | ||
{ | ||
"model": "openlxp_notifications.subject", | ||
"pk": 1, | ||
"fields": { | ||
"subject": "ECC New Resource Alert!" | ||
} | ||
} | ||
] |
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,11 @@ | ||
[ | ||
{ | ||
"model": "openlxp_notifications.template", | ||
"pk": 1, | ||
"fields": { | ||
"template_type": "edlm-subscribed-list-update", | ||
"message": "Hi {name:}!!<br></br><br></br>\r\n \r\nA new resource has been added to your list in the Enterprise Course Catalog (ECC): {list_name:} at {date_time:} by {author:}.<br></br>\r\n \r\nDive into the ECC and explore this latest addition to fuel your learning journey. 🌱<br></br>\r\n \r\nTo view your list, hop over to {list_url:}.<br></br><br></br>\r\n \r\nHappy learning!<br></br>\r\n \r\nThe EDLM Team", | ||
"template_inputs": null | ||
} | ||
} | ||
] |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from unittest.mock import patch | ||
|
||
from openlxp_notifications.models import email | ||
from rest_framework.test import APITestCase | ||
|
||
from configurations.models import XDSConfiguration | ||
|
@@ -13,11 +14,14 @@ class TestSetUp(APITestCase): | |
def setUp(self): | ||
"""Function to set up necessary data for testing""" | ||
|
||
self.patcher = patch('users.models.email_verification') | ||
self.mock_email_verification = self.patcher.start() | ||
# self.patcher = patch('users.models.email_verification') | ||
# self.mock_email_verification = self.patcher.start() | ||
|
||
self.patcher_2 = patch('xds_api.serializers.send_log_email_with_msg') | ||
self.mock_send_email = self.patcher_2.start() | ||
self.patcher = patch('core.signals.trigger_update') | ||
self.mock_send_email = self.patcher.start() | ||
|
||
self.email_not = email(reference='Subscribed_list_update') | ||
self.email_not.save() | ||
|
||
# create user, save user, login using client | ||
self.auth_email = "[email protected]" | ||
|
@@ -103,5 +107,4 @@ def setUp(self): | |
|
||
def tearDown(self): | ||
self.patcher.stop() | ||
self.patcher_2.stop() | ||
return super().tearDown() |
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 |
---|---|---|
@@ -1,13 +1,47 @@ | ||
import logging | ||
from django.conf import settings | ||
from django.db.models.signals import m2m_changed | ||
from django.dispatch import receiver | ||
from notifications.signals import notify | ||
from openlxp_notifications.management.commands. \ | ||
trigger_subscribed_list_update import \ | ||
trigger_update | ||
from openlxp_notifications.models import email | ||
|
||
from .models import InterestList | ||
|
||
logger = logging.getLogger('dict_config_logger') | ||
|
||
|
||
@receiver(m2m_changed, sender=InterestList.experiences.through) | ||
def interest_list_notify(sender, instance, action, reverse, pk_set, **kwargs): | ||
if action == 'post_add' and not reverse: | ||
notify.send(instance, recipient=instance.subscribers.all(), | ||
verb='experiences added', added=pk_set, | ||
list_name=instance.name) | ||
# setting variables for email request | ||
|
||
recipient_list = list(instance.subscribers.values_list( | ||
"email", "first_name", 'last_name')) | ||
owner = instance.owner | ||
list_name = instance.name | ||
|
||
if settings.LOGIN_REDIRECT_URL: | ||
list_url = (settings.LOGIN_REDIRECT_URL + "/" | ||
+ str(instance.id)) | ||
else: | ||
list_url = "ECC -> Subscribed Lists: " + instance.name | ||
|
||
try: | ||
email_type = email.objects.get( | ||
reference='Subscribed_list_update') | ||
|
||
# trigger email notification | ||
trigger_update( | ||
email_type, recipient_list, owner, | ||
list_name, list_url) | ||
except email.DoesNotExist: | ||
logger.error('Email configuration for subscribed list ' | ||
'updates does not exist. Please add a ' | ||
'"Subscribed_list_update" email template ' | ||
'for the email alert. ') |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from unittest.mock import patch | ||
|
||
from openlxp_notifications.models import email | ||
from rest_framework.test import APITestCase | ||
|
||
|
||
|
@@ -9,11 +10,11 @@ class TestSetUp(APITestCase): | |
def setUp(self): | ||
"""Function to set up necessary data for testing""" | ||
|
||
self.patcher = patch('users.models.email_verification') | ||
self.mock_email_verification = self.patcher.start() | ||
self.patcher = patch('core.signals.trigger_update') | ||
self.mock_send_email = self.patcher.start() | ||
|
||
self.patcher_2 = patch('xds_api.serializers.send_log_email_with_msg') | ||
self.mock_send_email = self.patcher_2.start() | ||
self.email_not = email(reference='Subscribed_list_update') | ||
self.email_not.save() | ||
|
||
self.email = "[email protected]" | ||
self.password = "test1234" | ||
|
@@ -39,5 +40,4 @@ def setUp(self): | |
|
||
def tearDown(self): | ||
self.patcher.stop() | ||
self.patcher_2.stop() | ||
return super().tearDown() |
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from unittest.mock import patch | ||
|
||
from openlxp_notifications.models import email | ||
from rest_framework.test import APITestCase | ||
|
||
from configurations.models import XDSConfiguration | ||
|
@@ -13,11 +14,14 @@ class TestSetUp(APITestCase): | |
def setUp(self): | ||
"""Function to set up necessary data for testing""" | ||
|
||
self.patcher = patch('users.models.email_verification') | ||
self.mock_email_verification = self.patcher.start() | ||
# self.patcher = patch('users.models.email_verification') | ||
# self.mock_email_verification = self.patcher.start() | ||
|
||
self.patcher_2 = patch('xds_api.serializers.send_log_email_with_msg') | ||
self.mock_send_email = self.patcher_2.start() | ||
self.patcher = patch('core.signals.trigger_update') | ||
self.mock_send_email = self.patcher.start() | ||
|
||
self.email_not = email(reference='Subscribed_list_update') | ||
self.email_not.save() | ||
|
||
# create user, save user, login using client | ||
self.auth_email = "[email protected]" | ||
|
@@ -103,5 +107,4 @@ def setUp(self): | |
|
||
def tearDown(self): | ||
self.patcher.stop() | ||
self.patcher_2.stop() | ||
return super().tearDown() |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from unittest.mock import patch | ||
|
||
from openlxp_notifications.models import email | ||
from rest_framework.test import APITestCase | ||
|
||
from configurations.models import XDSConfiguration | ||
|
@@ -13,11 +14,14 @@ class TestSetUp(APITestCase): | |
def setUp(self): | ||
"""Function to set up necessary data for testing""" | ||
|
||
self.patcher = patch('users.models.email_verification') | ||
self.mock_email_verification = self.patcher.start() | ||
# self.patcher = patch('users.models.email_verification') | ||
# self.mock_email_verification = self.patcher.start() | ||
|
||
self.patcher_2 = patch('xds_api.serializers.send_log_email_with_msg') | ||
self.mock_send_email = self.patcher_2.start() | ||
self.patcher = patch('core.signals.trigger_update') | ||
self.mock_send_email = self.patcher.start() | ||
|
||
self.email_not = email(reference='Subscribed_list_update') | ||
self.email_not.save() | ||
|
||
# create user, save user, login using client | ||
self.auth_email = "[email protected]" | ||
|
@@ -106,5 +110,4 @@ def setUp(self): | |
|
||
def tearDown(self): | ||
self.patcher.stop() | ||
self.patcher_2.stop() | ||
return super().tearDown() |
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
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