Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Change email fix #6761

Merged
merged 4 commits into from
Jul 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions app/marketing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,8 @@ def get_or_save_email_subscriber(email, source, send_slack_invite=True, profile=

created = False
try:
already_exists = EmailSubscriber.objects.filter(email__iexact=email)
if already_exists.exists():
es = already_exists.first()
else:
es = EmailSubscriber.objects.create(**defaults)
created = True
#print("EmailSubscriber:", es, "- created" if created else "- updated")
es, created = EmailSubscriber.objects.update_or_create(email__iexact=email, defaults=defaults)
# print("EmailSubscriber:", es, "- created" if created else "- updated")
except EmailSubscriber.MultipleObjectsReturned:
email_subscriber_ids = EmailSubscriber.objects.filter(email__iexact=email) \
.values_list('id', flat=True) \
Expand All @@ -241,14 +236,12 @@ def get_or_save_email_subscriber(email, source, send_slack_invite=True, profile=
es = EmailSubscriber.objects.create(**defaults)
created = True
except Exception as e:
#print(f'Failed to update or create email subscriber: ({email}) - {e}')
# print(f'Failed to update or create email subscriber: ({email}) - {e}')
return ''

if created or not es.priv:
es.set_priv()
es.save()
if send_slack_invite:
invite_to_slack(email)

return es

Expand Down