Skip to content

Commit

Permalink
Delete associated Group when a Team is deleted
Browse files Browse the repository at this point in the history
No-Issue
  • Loading branch information
cutwater committed Aug 27, 2024
1 parent c9cc8d5 commit 28d8371
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion galaxy_ng/app/models/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.db import models
from django.db.models import signals
from django.dispatch import receiver
from django_lifecycle import AFTER_UPDATE, BEFORE_CREATE, LifecycleModelMixin, hook
from django_lifecycle import AFTER_UPDATE, AFTER_DELETE, BEFORE_CREATE, LifecycleModelMixin, hook
from pulpcore.plugin.models import Group as PulpGroup

from galaxy_ng.app.models.auth import Group
Expand Down Expand Up @@ -84,6 +84,12 @@ def _rename_related_group(self, **kwargs):
self.group.name = self.group_name()
self.group.save()

@hook(AFTER_DELETE)
def _delete_related_group(self, **kwargs):
group = getattr(self, "group", None)
if group:
group.delete()


@receiver(signal=signals.post_save, sender=Group)
@receiver(signal=signals.post_save, sender=PulpGroup)
Expand Down

0 comments on commit 28d8371

Please sign in to comment.