37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import structlog
|
|
from django.db.models.signals import pre_delete
|
|
from django.dispatch import receiver
|
|
|
|
from vbv_lernwelt.learning_mentor.models import (
|
|
OrganisationSupervisor,
|
|
OrganisationSupervisortRoleType,
|
|
)
|
|
|
|
logger = structlog.get_logger(__name__)
|
|
|
|
|
|
# CourseSessionGroup
|
|
@receiver(
|
|
pre_delete,
|
|
sender=OrganisationSupervisor,
|
|
dispatch_uid="remove_org_supervisor_relations",
|
|
)
|
|
def remove_org_supervisor_relations(sender, instance: OrganisationSupervisor, **kwargs):
|
|
if (
|
|
instance.role
|
|
== OrganisationSupervisortRoleType.AUSBILDUNGSVERANTWORTLICHER.value
|
|
):
|
|
from vbv_lernwelt.learning_mentor.services import (
|
|
delete_ausbildungsverantwortlicher_relation,
|
|
)
|
|
|
|
delete_ausbildungsverantwortlicher_relation(
|
|
instance.supervisor, instance.organisation
|
|
)
|
|
elif instance.role == OrganisationSupervisortRoleType.BERUFSBILDNER.value:
|
|
from vbv_lernwelt.learning_mentor.services import (
|
|
delete_berufsbildner_relation,
|
|
)
|
|
|
|
delete_berufsbildner_relation(instance.supervisor, instance.organisation)
|