-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #1379 as a shop owner I see the subscriber name and email in new …
…subscriber email notifications Fix #1379 New subscriber notifications are only sent upon reaching thankyou page, not before
- Loading branch information
1 parent
47aa543
commit 7942ea7
Showing
6 changed files
with
96 additions
and
24 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
9 changes: 9 additions & 0 deletions
9
subscribie/emails/user-new-subscriber-notification.jinja2.html
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 @@ | ||
You have a new subscriber! <br /> | ||
|
||
{% if subscriber_email %} | ||
Email: {{ subscriber_email }}<br /> | ||
{% endif %} | ||
|
||
{% if subscription %} | ||
Name: {{ subscription.person.given_name }} {{ subscription.person.family_name }}<br /> | ||
{% endif %} |
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 |
---|---|---|
|
@@ -4,7 +4,10 @@ | |
send_donation_thankyou_email, | ||
send_welcome_email, | ||
) | ||
from subscribie.notifications import subscriberPaymentFailedNotification | ||
from subscribie.notifications import ( | ||
subscriberPaymentFailedNotification, | ||
newSubscriberEmailNotification, | ||
) | ||
from subscribie.models import Subscription, Document | ||
from subscribie.database import database | ||
import sqlalchemy | ||
|
@@ -100,8 +103,31 @@ def receiver_send_subscriber_payment_failed_notification_email(*args, **kwargs): | |
|
||
|
||
def receiver_new_subscriber(*args, **kwargs): | ||
to_email = kwargs.get("email") | ||
send_welcome_email(to_email=to_email) | ||
subscription_uuid = kwargs.get("subscription_uuid") | ||
subscription = None | ||
try: | ||
subscription = ( | ||
Subscription.query.where(Subscription.uuid == subscription_uuid) | ||
.execution_options(include_archived=True) | ||
.one() | ||
) | ||
subscriber_email = subscription.person.email | ||
except sqlalchemy.exc.NoResultFound: | ||
if subscription is None and subscription_uuid != "test": | ||
msg = "Got receiver_new_subscriber event but no associated subscription found." # noqa: E501 | ||
log.error(msg) | ||
return | ||
elif subscription_uuid == "test": | ||
log.info("Testing receiver_new_subscriber with dummy subscription") | ||
subscriber_email = "[email protected]" | ||
|
||
kwargs = {} | ||
kwargs["subscription_uuid"] = subscription_uuid | ||
kwargs["subscriber_email"] = subscriber_email | ||
kwargs["subscription"] = subscription | ||
|
||
send_welcome_email(to_email=subscriber_email, subscription=subscription) | ||
newSubscriberEmailNotification(**kwargs) | ||
|
||
|
||
def receiver_new_donation(*args, **kwargs): | ||
|
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