|
@@ -60,7 +60,9 @@ class Command(BaseCommand):
|
|
|
def _iter_emails(filename):
|
|
|
with open(filename) as f:
|
|
|
for l in f.readlines():
|
|
|
- yield l.strip()
|
|
|
+ email = l.strip()
|
|
|
+ if len(email) > 0:
|
|
|
+ yield l.strip()
|
|
|
|
|
|
@staticmethod
|
|
|
def _get_unknown_email(emails):
|
|
@@ -86,12 +88,21 @@ class Command(BaseCommand):
|
|
|
except Member.DoesNotExist:
|
|
|
unknown_emails.append(email)
|
|
|
else:
|
|
|
- mls = MaillingListSubscription(
|
|
|
+ mls_exists = MaillingListSubscription.objects.filter(
|
|
|
member=member,
|
|
|
maillinglist=ml,
|
|
|
- )
|
|
|
- mls.skip_sync = True
|
|
|
- mls.save()
|
|
|
+ ).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,
|
|
|
+ )
|
|
|
+ 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… ',)
|