Skip to content
Snippets Groups Projects
Commit 7cfa1b87 authored by Martin Mareš's avatar Martin Mareš
Browse files

DSN: Na účty s nedosažitelnou adresou neposíláme notifikace

parent 636af5ef
No related branches found
No related tags found
1 merge request!138Zpracování nedoručenek
...@@ -467,6 +467,10 @@ class User(Base): ...@@ -467,6 +467,10 @@ class User(Base):
def is_system(self) -> bool: def is_system(self) -> bool:
return self.user_id == 0 return self.user_id == 0
@property
def wants_notify(self) -> bool:
return self.email_notify and self.dsn_id is None
def get_system_user() -> User: def get_system_user() -> User:
"""Uživatel s user_id=0 je systémový (viz db.ddl)""" """Uživatel s user_id=0 je systémový (viz db.ddl)"""
......
...@@ -70,7 +70,7 @@ def handle_send_grading_info(the_job: TheJob): ...@@ -70,7 +70,7 @@ def handle_send_grading_info(the_job: TheJob):
for user, sent in todo: for user, sent in todo:
num_total += 1 num_total += 1
if not user.email_notify: if not user.wants_notify:
num_dont_want += 1 num_dont_want += 1
elif sent: elif sent:
num_before += 1 num_before += 1
......
...@@ -266,8 +266,8 @@ def join_notify(c: db.Contest) -> None: ...@@ -266,8 +266,8 @@ def join_notify(c: db.Contest) -> None:
notify = {ur.user for ur in uroles if ur.applies_to(at=place, year=r.year, cat=r.category, seq=r.seq)} notify = {ur.user for ur in uroles if ur.applies_to(at=place, year=r.year, cat=r.category, seq=r.seq)}
if notify: if notify:
for org in notify: for org in notify:
logger.info(f'Join: {"Notifikuji" if org.email_notify else "Nenotifikuji"} orga <{org.email}> pro místo {place.get_code()}') logger.info(f'Join: {"Notifikuji" if org.wants_notify else "Nenotifikuji"} orga <{org.email}> pro místo {place.get_code()}')
if org.email_notify: if org.wants_notify:
mo.email.send_join_notify_email(org, g.user, c) mo.email.send_join_notify_email(org, g.user, c)
return return
place = place.parent_place place = place.parent_place
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment