don't remove club reps if email failed
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
c7d7e021fd
commit
2a145cd83a
|
@ -204,6 +204,8 @@ class ClubWebHostingService:
|
|||
for club in all_clubs
|
||||
if not any(map(lambda member: member in active_club_reps, club.members))
|
||||
]
|
||||
|
||||
# STEP 1: update the Apache configs
|
||||
with self.begin_transaction():
|
||||
clubs_to_disable = [
|
||||
club.cn
|
||||
|
@ -218,17 +220,26 @@ class ClubWebHostingService:
|
|||
self.commit()
|
||||
# self.clubs is set to None once the transaction closes, so make a copy now
|
||||
clubs_info = self.clubs.copy()
|
||||
|
||||
# STEP 2: send emails to clubs whose websites were disabled
|
||||
clubs_who_were_not_notified = set()
|
||||
for club_name in clubs_to_disable:
|
||||
address = clubs_info['email']
|
||||
if address is None:
|
||||
clubs_who_were_not_notified.add(club_name)
|
||||
continue
|
||||
try:
|
||||
mail_srv.send_club_website_has_been_disabled_message(club_name, address)
|
||||
except Exception:
|
||||
trace = traceback.format_exc()
|
||||
logger.error(f'Failed to send email to {address}:\n{trace}')
|
||||
clubs_who_were_not_notified.add(club_name)
|
||||
|
||||
# STEP 3: remove inactive club reps from Unix groups
|
||||
if remove_inactive_club_reps:
|
||||
for club in all_clubs:
|
||||
if club.cn in clubs_who_were_not_notified:
|
||||
continue
|
||||
# club.members gets modified after calling club.remove_member(),
|
||||
# so we need to make a copy
|
||||
members = club.members.copy()
|
||||
|
|
Loading…
Reference in New Issue