Log/archive deleted data #84
@ -4,7 +4,7 @@ from django.contrib.auth import get_user_model
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from common.model_mixins import CreatedModifiedMixin, TrackChangesMixin
|
from common.model_mixins import CreatedModifiedMixin
|
||||||
from constants.base import (
|
from constants.base import (
|
||||||
TEAM_ROLE_CHOICES,
|
TEAM_ROLE_CHOICES,
|
||||||
TEAM_ROLE_MANAGER,
|
TEAM_ROLE_MANAGER,
|
||||||
@ -16,9 +16,7 @@ User = get_user_model()
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Team(CreatedModifiedMixin, TrackChangesMixin, models.Model):
|
class Team(CreatedModifiedMixin, models.Model):
|
||||||
track_changes_to_fields = {'name'}
|
|
||||||
|
|
||||||
slug = models.SlugField(unique=True, null=False, blank=False, editable=True)
|
slug = models.SlugField(unique=True, null=False, blank=False, editable=True)
|
||||||
name = models.CharField(max_length=128, null=False, blank=False)
|
name = models.CharField(max_length=128, null=False, blank=False)
|
||||||
users = models.ManyToManyField(User, through='TeamsUsers', related_name='teams')
|
users = models.ManyToManyField(User, through='TeamsUsers', related_name='teams')
|
||||||
@ -39,9 +37,7 @@ class Team(CreatedModifiedMixin, TrackChangesMixin, models.Model):
|
|||||||
return reverse('extensions:by-team', kwargs={'team_slug': self.slug})
|
return reverse('extensions:by-team', kwargs={'team_slug': self.slug})
|
||||||
|
|
||||||
|
|
||||||
class TeamsUsers(CreatedModifiedMixin, TrackChangesMixin, models.Model):
|
class TeamsUsers(CreatedModifiedMixin, models.Model):
|
||||||
track_changes_to_fields = {'role'}
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = 'Team member'
|
verbose_name = 'Team member'
|
||||||
verbose_name_plural = 'Team members'
|
verbose_name_plural = 'Team members'
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
from typing import Union
|
|
||||||
|
|
||||||
from django.db.models.signals import pre_delete
|
|
||||||
from django.dispatch import receiver
|
|
||||||
|
|
||||||
from teams.models import Team, TeamUser
|
|
||||||
|
|
||||||
|
|
||||||
@receiver(pre_delete, sender=Team)
|
|
||||||
@receiver(pre_delete, sender=TeamUser)
|
|
||||||
def _log_deletion(sender: object, instance: Union[Team, TeamUser], **kwargs: object) -> None:
|
|
||||||
instance.record_deletion()
|
|
Loading…
Reference in New Issue
Block a user