diff --git a/backend/clubs/models.py b/backend/clubs/models.py index d75e1ab02..bb95fcedc 100644 --- a/backend/clubs/models.py +++ b/backend/clubs/models.py @@ -782,11 +782,7 @@ def __str__(self): def send_question_mail(self, request=None): domain = get_domain(request) - owner_emails = list( - self.club.membership_set.filter( - role__lte=Membership.ROLE_OFFICER, active=True - ).values_list("person__email", flat=True) - ) + emails = self.club.get_officer_emails() context = { "name": self.club.name, @@ -794,11 +790,11 @@ def send_question_mail(self, request=None): "url": settings.QUESTION_URL.format(domain=domain, club=self.club.code), } - if owner_emails: + if emails: send_mail_helper( name="question", subject="Question for {}".format(self.club.name), - emails=owner_emails, + emails=emails, context=context, ) @@ -1114,20 +1110,17 @@ def send_request(self, request=None): "full_name": self.person.get_full_name(), } - owner_emails = list( - self.club.membership_set.filter( - role__lte=Membership.ROLE_OFFICER, active=True - ).values_list("person__email", flat=True) - ) + emails = self.club.get_officer_emails() - send_mail_helper( - name="request", - subject="Membership Request from {} for {}".format( - self.person.get_full_name(), self.club.name - ), - emails=owner_emails, - context=context, - ) + if emails: + send_mail_helper( + name="request", + subject="Membership Request from {} for {}".format( + self.person.get_full_name(), self.club.name + ), + emails=emails, + context=context, + ) class Meta: unique_together = (("person", "club"),)