authentik.enterprise.lifecycle.signals
1from django.db.models import Q 2from django.db.models.signals import post_save, pre_delete 3from django.dispatch import receiver 4 5from authentik.enterprise.lifecycle.models import LifecycleRule, ReviewState 6from authentik.tasks.schedules.models import Schedule 7 8 9@receiver(post_save, sender=LifecycleRule) 10def post_rule_save(sender, instance: LifecycleRule, created: bool, **_): 11 from authentik.enterprise.lifecycle.tasks import apply_lifecycle_rule 12 13 apply_lifecycle_rule.send_with_options( 14 args=(instance.id,), 15 rel_obj=Schedule.objects.get( 16 actor_name="authentik.enterprise.lifecycle.tasks.apply_lifecycle_rules" 17 ), 18 ) 19 20 21@receiver(pre_delete, sender=LifecycleRule) 22def pre_rule_delete(sender, instance: LifecycleRule, **_): 23 instance.lifecycleiteration_set.filter( 24 Q(state=ReviewState.PENDING) | Q(state=ReviewState.OVERDUE) 25 ).update(state=ReviewState.CANCELED)
@receiver(post_save, sender=LifecycleRule)
def
post_rule_save( sender, instance: authentik.enterprise.lifecycle.models.LifecycleRule, created: bool, **_):
10@receiver(post_save, sender=LifecycleRule) 11def post_rule_save(sender, instance: LifecycleRule, created: bool, **_): 12 from authentik.enterprise.lifecycle.tasks import apply_lifecycle_rule 13 14 apply_lifecycle_rule.send_with_options( 15 args=(instance.id,), 16 rel_obj=Schedule.objects.get( 17 actor_name="authentik.enterprise.lifecycle.tasks.apply_lifecycle_rules" 18 ), 19 )
@receiver(pre_delete, sender=LifecycleRule)
def
pre_rule_delete( sender, instance: authentik.enterprise.lifecycle.models.LifecycleRule, **_):