Commit b56b732b authored by jocelyn's avatar jocelyn
Browse files

Silently ignore subscriptions that already exist

Instead of IntegrityError
parent 76fbd52e
......@@ -60,6 +60,8 @@ class Command(BaseCommand):
def _iter_emails(filename):
with open(filename) as f:
for l in f.readlines():
email = l.strip()
if len(email) > 0:
yield l.strip()
@staticmethod
......@@ -86,6 +88,14 @@ class Command(BaseCommand):
except Member.DoesNotExist:
unknown_emails.append(email)
else:
mls_exists = MaillingListSubscription.objects.filter(
member=member,
maillinglist=ml,
).exists()
# Not using get_or_create because we want to set skip_sync
# before saving
if not mls_exists:
mls = MaillingListSubscription(
member=member,
maillinglist=ml,
......@@ -93,6 +103,7 @@ class Command(BaseCommand):
mls.skip_sync = True
mls.save()
# Do it once… (db will be rollback if it fails)
sys.stdout.write('Pousse la liste sur le serveur… ',)
ml.sync_to_list_server()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment