diff --git a/tournaments/models/player_registration.py b/tournaments/models/player_registration.py index 4dbd9ad..13a7018 100644 --- a/tournaments/models/player_registration.py +++ b/tournaments/models/player_registration.py @@ -230,4 +230,6 @@ class PlayerRegistration(TournamentSubModel): return 0 def player_contact(self): - return self.contact_email or self.email + if self.contact_email: + return self.contact_email + return self.email diff --git a/tournaments/services/email_service.py b/tournaments/services/email_service.py index a94a58d..206285a 100644 --- a/tournaments/services/email_service.py +++ b/tournaments/services/email_service.py @@ -516,8 +516,8 @@ class TournamentEmailService: @staticmethod def notify(captain, other_player, tournament, message_type: TeamEmailType): - print("TournamentEmailService.notify", captain.email, captain.registered_online, tournament, message_type) - if not captain or not captain.registered_online or not captain.email: + print("TournamentEmailService.notify", captain.player_contact(), captain.registered_online, tournament, message_type) + if not captain or not captain.registered_online or not captain.player_contact(): return tournament_details_str = tournament.build_tournament_details_str() @@ -607,7 +607,7 @@ class TournamentEmailService: print("TournamentEmailService.notify_team 2p", team) first_player, second_player = players TournamentEmailService.notify(first_player, second_player, tournament, message_type) - if first_player.email != second_player.email: + if first_player.player_contact() != second_player.player_contact(): TournamentEmailService.notify(second_player, first_player, tournament, message_type) elif len(players) == 1: print("TournamentEmailService.notify_team 1p", team) @@ -814,11 +814,11 @@ class TournamentEmailService: tournament_prefix_that = federal_level_category.localized_prefix_that() processed_emails = set() for player in player_registrations: - if not player.email or not player.registered_online: + if not player.player_contact() or not player.registered_online: continue - if player.email in processed_emails: + if player.player_contact() in processed_emails: continue - processed_emails.add(player.email) + processed_emails.add(player.player_contact()) tournament_details_str = tournament.build_tournament_details_str() other_player = team_registration.get_other_player(player) if len(player_registrations) > 1 else None