feat(access): Save changes to history for organization and teams
!9 closes #5
This commit is contained in:
@ -4,8 +4,10 @@ from django.contrib.auth.models import Group, Permission
|
||||
|
||||
from .fields import *
|
||||
|
||||
from core.mixin.history_save import SaveHistory
|
||||
|
||||
class Organization(models.Model):
|
||||
|
||||
class Organization(SaveHistory):
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "Organizations"
|
||||
@ -56,7 +58,7 @@ class TenancyObject(models.Model):
|
||||
)
|
||||
|
||||
|
||||
class Team(Group, TenancyObject):
|
||||
class Team(Group, TenancyObject, SaveHistory):
|
||||
class Meta:
|
||||
# proxy = True
|
||||
verbose_name_plural = "Teams"
|
||||
@ -86,7 +88,7 @@ class Team(Group, TenancyObject):
|
||||
modified = AutoLastModifiedField()
|
||||
|
||||
|
||||
class TeamUsers(models.Model):
|
||||
class TeamUsers(SaveHistory):
|
||||
|
||||
class Meta:
|
||||
# proxy = True
|
||||
|
@ -46,6 +46,9 @@ class View(LoginRequiredMixin, OrganizationPermission, generic.UpdateView):
|
||||
|
||||
context['teams'] = Team.objects.filter(organization=self.kwargs['pk'])
|
||||
|
||||
context['model_pk'] = self.kwargs['pk']
|
||||
context['model_name'] = self.model._meta.verbose_name.replace(' ', '')
|
||||
|
||||
return context
|
||||
|
||||
|
||||
|
@ -37,6 +37,9 @@ class View(OrganizationPermission, generic.UpdateView):
|
||||
context['teamusers'] = teamusers
|
||||
context['permissions'] = Permission.objects.filter()
|
||||
|
||||
context['model_pk'] = self.kwargs['pk']
|
||||
context['model_name'] = self.model._meta.verbose_name.replace(' ', '')
|
||||
|
||||
return context
|
||||
|
||||
def get_success_url(self, **kwargs):
|
||||
@ -66,6 +69,9 @@ class Add(PermissionRequiredMixin, OrganizationPermission, generic.CreateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
context['model_pk'] = self.kwargs['pk']
|
||||
context['model_name'] = self.model._meta.verbose_name.replace(' ', '')
|
||||
|
||||
context['content_title'] = 'Add Team'
|
||||
|
||||
return context
|
||||
@ -89,6 +95,9 @@ class Change(PermissionRequiredMixin, OrganizationPermission, generic.UpdateView
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
context['model_pk'] = self.kwargs['pk']
|
||||
context['model_name'] = self.model._meta.verbose_name.replace(' ', '')
|
||||
|
||||
context['content_title'] = 'Edit Team'
|
||||
|
||||
return context
|
||||
@ -115,6 +124,9 @@ class Delete(PermissionRequiredMixin, OrganizationPermission, generic.DeleteView
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
context['model_pk'] = self.kwargs['pk']
|
||||
context['model_name'] = self.model._meta.verbose_name.replace(' ', '')
|
||||
|
||||
context['content_title'] = 'Delete Team'
|
||||
|
||||
return context
|
||||
|
Reference in New Issue
Block a user