mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-23 15:16:38 +02:00
Don't trigger signals on raw imports
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -6,21 +6,22 @@ from participation.models import Note, Participation, Passage, Pool, Team
|
||||
from tfjm.lists import get_sympa_client
|
||||
|
||||
|
||||
def create_team_participation(instance, created, **_):
|
||||
def create_team_participation(instance, created, raw, **_):
|
||||
"""
|
||||
When a team got created, create an associated participation.
|
||||
"""
|
||||
participation = Participation.objects.get_or_create(team=instance)[0]
|
||||
participation.save()
|
||||
if not created:
|
||||
participation.team.create_mailing_list()
|
||||
if not raw:
|
||||
participation = Participation.objects.get_or_create(team=instance)[0]
|
||||
participation.save()
|
||||
if not created:
|
||||
participation.team.create_mailing_list()
|
||||
|
||||
|
||||
def update_mailing_list(instance: Team, **_):
|
||||
def update_mailing_list(instance: Team, raw, **_):
|
||||
"""
|
||||
When a team name or trigram got updated, update mailing lists and Matrix rooms
|
||||
"""
|
||||
if instance.pk:
|
||||
if instance.pk and not raw:
|
||||
old_team = Team.objects.get(pk=instance.pk)
|
||||
if old_team.trigram != instance.trigram:
|
||||
# TODO Rename Matrix room
|
||||
@ -36,11 +37,12 @@ def update_mailing_list(instance: Team, **_):
|
||||
f"{coach.user.first_name} {coach.user.last_name}")
|
||||
|
||||
|
||||
def create_notes(instance: Union[Passage, Pool], **_):
|
||||
if isinstance(instance, Pool):
|
||||
for passage in instance.passages.all():
|
||||
create_notes(passage)
|
||||
return
|
||||
def create_notes(instance: Union[Passage, Pool], raw, **_):
|
||||
if not raw:
|
||||
if isinstance(instance, Pool):
|
||||
for passage in instance.passages.all():
|
||||
create_notes(passage)
|
||||
return
|
||||
|
||||
for jury in instance.pool.juries.all():
|
||||
Note.objects.get_or_create(jury=jury, passage=instance)
|
||||
for jury in instance.pool.juries.all():
|
||||
Note.objects.get_or_create(jury=jury, passage=instance)
|
||||
|
Reference in New Issue
Block a user