Skip to content
Snippets Groups Projects
Verified Commit 14bd031a authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Allow non-existing mailinglists to be created

parent 64edc048
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ class GSuiteSyncService:
self.name = name
self.description = description
self.aliases = aliases
self.addresses = addresses
self.addresses = sorted(set(addresses))
def __eq__(self, other: object) -> bool:
if isinstance(other, self.__class__):
......@@ -215,7 +215,7 @@ class GSuiteSyncService:
except HttpError as e:
logger.error('Could not obtain list member data', e.content)
return # the list does not exist or something else is wrong
new_members = set(group.addresses)
new_members = group.addresses
remove_list = [x for x in existing_members if x not in new_members]
insert_list = [x for x in new_members if x not in existing_members
......@@ -253,8 +253,10 @@ class GSuiteSyncService:
moderated=mailinglist.moderated,
name=mailinglist.name,
description=mailinglist.description,
aliases=[x.alias for x in mailinglist.aliases.all()],
addresses=list(mailinglist.all_addresses())
aliases=([x.alias for x in mailinglist.aliases.all()]
if mailinglist.pk is not None else []),
addresses=(list(mailinglist.all_addresses())
if mailinglist.pk is not None else [])
)
@staticmethod
......
......@@ -79,7 +79,7 @@ class MailingList(models.Model):
yield member.email
for verbatimaddress in self.addresses.all():
if member.email:
if verbatimaddress.address:
yield verbatimaddress.address
def clean(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment