feat(access): Add AuditHistory Serializer for Role model
ref: #862 #844
This commit is contained in:
@ -1,4 +1,3 @@
|
|||||||
from .organization_history import OrganizationHistory # pylint: disable=W0611:unused-import
|
from .organization_history import OrganizationHistory # pylint: disable=W0611:unused-import
|
||||||
from .role_history import RoleHistory # pylint: disable=W0611:unused-import
|
|
||||||
|
|
||||||
from .organization_notes import OrganizationNotes # pylint: disable=W0611:unused-import
|
from .organization_notes import OrganizationNotes # pylint: disable=W0611:unused-import
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
from core.models.model_history import ModelHistory
|
|
||||||
|
|
||||||
from access.models.role import Role
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RoleHistory(
|
|
||||||
ModelHistory
|
|
||||||
):
|
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
|
|
||||||
db_table = 'access_role_history'
|
|
||||||
|
|
||||||
ordering = ModelHistory._meta.ordering
|
|
||||||
|
|
||||||
verbose_name = 'Role History'
|
|
||||||
|
|
||||||
verbose_name_plural = 'Role History'
|
|
||||||
|
|
||||||
|
|
||||||
model = models.ForeignKey(
|
|
||||||
Role,
|
|
||||||
blank = False,
|
|
||||||
help_text = 'Model this note belongs to',
|
|
||||||
null = False,
|
|
||||||
on_delete = models.CASCADE,
|
|
||||||
related_name = 'history',
|
|
||||||
verbose_name = 'Model',
|
|
||||||
)
|
|
||||||
|
|
||||||
table_fields: list = []
|
|
||||||
|
|
||||||
page_layout: dict = []
|
|
||||||
|
|
||||||
|
|
||||||
def get_object(self):
|
|
||||||
|
|
||||||
return self
|
|
||||||
|
|
||||||
|
|
||||||
def get_serialized_model(self, serializer_context):
|
|
||||||
|
|
||||||
model = None
|
|
||||||
|
|
||||||
from access.serializers.role import BaseSerializer
|
|
||||||
|
|
||||||
model = BaseSerializer(self.model, context = serializer_context)
|
|
||||||
|
|
||||||
return model
|
|
56
app/access/serializers/centurionaudit_role.py
Normal file
56
app/access/serializers/centurionaudit_role.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from drf_spectacular.utils import extend_schema_serializer
|
||||||
|
|
||||||
|
from api.serializers import common
|
||||||
|
|
||||||
|
from centurion.models.meta import RoleAuditHistory # pylint: disable=E0401:import-error disable=E0611:no-name-in-module
|
||||||
|
|
||||||
|
from core.serializers.centurionaudit import (
|
||||||
|
BaseSerializer,
|
||||||
|
ViewSerializer as AuditHistoryViewSerializer
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema_serializer(component_name = 'RoleAuditHistoryModelSerializer')
|
||||||
|
class ModelSerializer(
|
||||||
|
common.CommonModelSerializer,
|
||||||
|
BaseSerializer
|
||||||
|
):
|
||||||
|
"""Git Group Audit History Base Model"""
|
||||||
|
|
||||||
|
|
||||||
|
_urls = serializers.SerializerMethodField('get_url')
|
||||||
|
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
|
||||||
|
model = RoleAuditHistory
|
||||||
|
|
||||||
|
fields = [
|
||||||
|
'id',
|
||||||
|
'organization',
|
||||||
|
'display_name',
|
||||||
|
'content_type',
|
||||||
|
'model',
|
||||||
|
'before',
|
||||||
|
'after',
|
||||||
|
'action',
|
||||||
|
'user',
|
||||||
|
'created',
|
||||||
|
'_urls',
|
||||||
|
]
|
||||||
|
|
||||||
|
read_only_fields = fields
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@extend_schema_serializer(component_name = 'RoleAuditHistoryViewSerializer')
|
||||||
|
class ViewSerializer(
|
||||||
|
ModelSerializer,
|
||||||
|
AuditHistoryViewSerializer,
|
||||||
|
):
|
||||||
|
"""Git Group Audit History Base View Model"""
|
||||||
|
pass
|
Reference in New Issue
Block a user