Skip to content

Commit

Permalink
fix: flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
saemideluxe committed Aug 17, 2022
1 parent 430c53f commit e6253a5
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions basxconnect/mailer_integration/synchronize.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,22 @@ def synchronize_batch(count, offset, mailer, sync_result):
else:
created_person = _save_person(datasource_tag, mailer_person)
_save_subscription(
created_person.primary_email_address, mailer_person, sync_result, new_person=True
created_person.primary_email_address,
mailer_person,
sync_result,
new_person=True,
)
_save_sync_person(
mailer_person, sync_result, SynchronizationPerson.NEW
)
_save_sync_person(mailer_person, sync_result, SynchronizationPerson.NEW)
else:
# if the downloaded email address already exists in our system,
# update the mailing preference for this email address, without
# creating a new person in the database
for email in matching_email_addresses:
_save_subscription(email, mailer_person, sync_result, new_person=False)
_save_subscription(
email, mailer_person, sync_result, new_person=False
)
except ApiClientError:
# todo: "skipped" is not really the right term, since the person might already
# have been added to BasxConnect before the exception happens
Expand Down Expand Up @@ -141,7 +148,10 @@ def _save_postal_address(person: models.Person, mailer_person: MailerPerson):


def _save_subscription(
email: models.Email, mailer_person: MailerPerson, sync_result: SynchronizationResult, new_person: bool
email: models.Email,
mailer_person: MailerPerson,
sync_result: SynchronizationResult,
new_person: bool,
):
subscription, _ = Subscription.objects.get_or_create(email=email)
old_subscription_status = subscription.status or ""
Expand All @@ -160,7 +170,10 @@ def _save_subscription(
SynchronizationPerson.SUBSCRIPTION_STATUS_CHANGED,
old_subscription_status=old_subscription_status,
)
if new_person and global_preferences_registry.manager()["mailchimp__synchronize_language"]:
if (
new_person
and global_preferences_registry.manager()["mailchimp__synchronize_language"]
):
person = email.person
person.preferred_language = mailer_person.language
person.save()

0 comments on commit e6253a5

Please sign in to comment.