save-acts-after-eventswithact.patch
calebasse/agenda/models.py | ||
---|---|---|
547 | 547 |
'{act_type} ({act_type.id})'.format(**kwargs) |
548 | 548 | |
549 | 549 | |
550 |
from django.db.models.signals import m2m_changed |
|
550 |
from django.db.models.signals import m2m_changed, post_save
|
|
551 | 551 |
from django.dispatch import receiver |
552 | 552 | |
553 | 553 | |
... | ... | |
557 | 557 |
workers = [ p.worker for p in instance.participants.prefetch_related('worker') ] |
558 | 558 |
for act in instance.act_set.all(): |
559 | 559 |
act.doctors = workers |
560 | ||
561 |
@receiver(post_save, sender = EventWithAct) |
|
562 |
def create_act(sender, instance, **kwargs): |
|
563 |
instance.act.parent_event_id = instance.id |
|
564 |
instance.act.save() |