2020-04-26 19:46:58 +02:00
|
|
|
from django.dispatch import receiver
|
|
|
|
from .models import Task
|
2024-04-01 16:27:31 +02:00
|
|
|
from config.signals_shared import stream_inactive
|
2024-02-27 20:44:35 +01:00
|
|
|
from config.models import Stream
|
2020-04-26 19:46:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
@receiver(stream_inactive)
|
2024-04-01 16:27:31 +02:00
|
|
|
def delete_tasks_when_stream_inactive(sender, **kwargs):
|
|
|
|
# when a stream has become inactive, all related tasks which are created for the stream need to be deleted.
|
|
|
|
# we need to exclude the pull tasks, as they are not created for the stream.
|
2020-04-26 19:46:58 +02:00
|
|
|
stream = Stream.objects.get(stream=kwargs['stream'])
|
2024-04-01 16:27:31 +02:00
|
|
|
Task.objects.filter(stream=stream).exclude(type="pull").delete()
|