Skip to content

Commit

Permalink
Use Club.get_officer_emails() to send alerts (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviupadhyayula authored Sep 27, 2024
1 parent fbedec8 commit 308fc0b
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions backend/clubs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,23 +782,19 @@ 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,
"question": self.question,
"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,
)

Expand Down Expand Up @@ -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"),)
Expand Down

0 comments on commit 308fc0b

Please sign in to comment.