mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-12-27 09:08:53 +01:00
added delete mechanism on Queue for auto-clean of permissions
This commit is contained in:
parent
92d8ca3eff
commit
43e5ff7c0e
@ -10,6 +10,7 @@ models.py - Model (and hence database) definitions. This is the core of the
|
||||
from __future__ import unicode_literals
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db import models
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.conf import settings
|
||||
@ -286,6 +287,18 @@ class Queue(models.Model):
|
||||
|
||||
super(Queue, self).save(*args, **kwargs)
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
permission_name = self.permission_name
|
||||
super(Queue, self).delete(*args, **kwargs)
|
||||
|
||||
# once the Queue is safely deleted, remove the permission (if exists)
|
||||
if permission_name:
|
||||
try:
|
||||
p = Permission.objects.get(codename=permission_name[9:])
|
||||
p.delete()
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
|
||||
|
||||
class Ticket(models.Model):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user