Skip to content

Commit

Permalink
feat(api): Add a Common Model serializer to be inherited by all model…
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-nfc committed Nov 11, 2024
1 parent 1f9ac5f commit 53ce9ca
Show file tree
Hide file tree
Showing 28 changed files with 172 additions and 29 deletions.
7 changes: 6 additions & 1 deletion app/access/serializers/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from access.models import Organization

from api.serializers import common

from app.serializers.user import UserBaseSerializer


Expand Down Expand Up @@ -40,7 +42,10 @@ class Meta:



class OrganizationModelSerializer(OrganizationBaseSerializer):
class OrganizationModelSerializer(
common.CommonModelSerializer,
OrganizationBaseSerializer
):

_urls = serializers.SerializerMethodField('get_url')

Expand Down
8 changes: 7 additions & 1 deletion app/access/serializers/team_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from rest_framework import serializers

from access.models import TeamUsers

from api.serializers import common

from app.serializers.user import UserBaseSerializer


Expand Down Expand Up @@ -49,7 +52,10 @@ class Meta:



class TeamUserModelSerializer(TeamUserBaseSerializer):
class TeamUserModelSerializer(
common.CommonModelSerializer,
TeamUserBaseSerializer
):

_urls = serializers.SerializerMethodField('get_url')

Expand Down
8 changes: 7 additions & 1 deletion app/access/serializers/teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from rest_framework import serializers

from access.models import Team

from api.serializers import common

from access.serializers.organization import OrganizationBaseSerializer

from app.serializers.permission import PermissionBaseSerializer
Expand Down Expand Up @@ -52,7 +55,10 @@ class Meta:



class TeamModelSerializer(TeamBaseSerializer):
class TeamModelSerializer(
common.CommonModelSerializer,
TeamBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
9 changes: 9 additions & 0 deletions app/api/serializers/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from rest_framework import serializers

from core import fields as centurion_field



class CommonModelSerializer(CommonBaseSerializer):

model_notes = centurion_field.MarkdownField( required = False )
7 changes: 6 additions & 1 deletion app/assistance/serializers/knowledge_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from app.serializers.user import UserBaseSerializer

from api.serializers import common

from assistance.models.knowledge_base import KnowledgeBase
from assistance.serializers.knowledge_base_category import KnowledgeBaseCategoryBaseSerializer

Expand Down Expand Up @@ -54,7 +56,10 @@ class Meta:



class KnowledgeBaseModelSerializer(KnowledgeBaseBaseSerializer):
class KnowledgeBaseModelSerializer(
common.CommonModelSerializer,
KnowledgeBaseBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
7 changes: 6 additions & 1 deletion app/assistance/serializers/knowledge_base_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

from app.serializers.user import UserBaseSerializer

from api.serializers import common

from assistance.models.knowledge_base import KnowledgeBaseCategory


Expand Down Expand Up @@ -55,7 +57,10 @@ class Meta:



class KnowledgeBaseCategoryModelSerializer(KnowledgeBaseCategoryBaseSerializer):
class KnowledgeBaseCategoryModelSerializer(
common.CommonModelSerializer,
KnowledgeBaseCategoryBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
7 changes: 6 additions & 1 deletion app/config_management/serializers/config_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from access.serializers.organization import OrganizationBaseSerializer

from api.serializers import common

from config_management.models.groups import ConfigGroups

from itam.serializers.device import DeviceBaseSerializer
Expand Down Expand Up @@ -52,7 +54,10 @@ class Meta:



class ConfigGroupModelSerializer(ConfigGroupBaseSerializer):
class ConfigGroupModelSerializer(
common.CommonModelSerializer,
ConfigGroupBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
7 changes: 6 additions & 1 deletion app/config_management/serializers/config_group_software.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from access.serializers.organization import OrganizationBaseSerializer

from api.serializers import common

from config_management.models.groups import ConfigGroupSoftware
from config_management.serializers.config_group import ConfigGroups, ConfigGroupBaseSerializer

Expand Down Expand Up @@ -55,7 +57,10 @@ class Meta:



class ConfigGroupSoftwareModelSerializer(ConfigGroupSoftwareBaseSerializer):
class ConfigGroupSoftwareModelSerializer(
common.CommonModelSerializer,
ConfigGroupSoftwareBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
7 changes: 6 additions & 1 deletion app/core/serializers/manufacturer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from app.serializers.user import UserBaseSerializer

from api.serializers import common

from core.models.manufacturer import Manufacturer


Expand Down Expand Up @@ -39,7 +41,10 @@ class Meta:
]


class ManufacturerModelSerializer(ManufacturerBaseSerializer):
class ManufacturerModelSerializer(
common.CommonModelSerializer,
ManufacturerBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
7 changes: 6 additions & 1 deletion app/core/serializers/ticket_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from access.serializers.organization import OrganizationBaseSerializer

from api.serializers import common

from core.models.ticket.ticket_category import TicketCategory


Expand Down Expand Up @@ -39,7 +41,10 @@ class Meta:
]


class TicketCategoryModelSerializer(TicketCategoryBaseSerializer):
class TicketCategoryModelSerializer(
common.CommonModelSerializer,
TicketCategoryBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
7 changes: 6 additions & 1 deletion app/core/serializers/ticket_comment_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from app.serializers.user import UserBaseSerializer

from api.serializers import common

from core.models.ticket.ticket_comment_category import TicketCommentCategory


Expand Down Expand Up @@ -39,7 +41,10 @@ class Meta:
]


class TicketCommentCategoryModelSerializer(TicketCommentCategoryBaseSerializer):
class TicketCommentCategoryModelSerializer(
common.CommonModelSerializer,
TicketCommentCategoryBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
6 changes: 5 additions & 1 deletion app/itam/serializers/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from access.serializers.organization import OrganizationBaseSerializer

from api.serializers import common
from api.viewsets.common import ModelViewSet

from core.fields.icon import Icon, IconField
Expand Down Expand Up @@ -48,7 +49,10 @@ class Meta:
'url',
]

class DeviceModelSerializer(DeviceBaseSerializer):
class DeviceModelSerializer(
common.CommonModelSerializer,
DeviceBaseSerializer
):

_urls = serializers.SerializerMethodField('get_url')

Expand Down
7 changes: 6 additions & 1 deletion app/itam/serializers/device_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from access.serializers.organization import OrganizationBaseSerializer

from api.serializers import common

from core.serializers.manufacturer import ManufacturerBaseSerializer

from itam.models.device_models import DeviceModel
Expand Down Expand Up @@ -42,7 +44,10 @@ class Meta:
]


class DeviceModelModelSerializer(DeviceModelBaseSerializer):
class DeviceModelModelSerializer(
common.CommonModelSerializer,
DeviceModelBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
9 changes: 6 additions & 3 deletions app/itam/serializers/device_software.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from rest_framework.fields import empty
from rest_framework.reverse import reverse



from access.serializers.organization import OrganizationBaseSerializer

from api.serializers import common

from core.fields.badge import Badge, BadgeField

from itam.models.device import Device, DeviceSoftware
Expand Down Expand Up @@ -49,7 +49,10 @@ class Meta:
]


class DeviceSoftwareModelSerializer(DeviceSoftwareBaseSerializer):
class DeviceSoftwareModelSerializer(
common.CommonModelSerializer,
DeviceSoftwareBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
7 changes: 6 additions & 1 deletion app/itam/serializers/device_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from access.serializers.organization import OrganizationBaseSerializer

from api.serializers import common

from itam.models.device import DeviceType


Expand Down Expand Up @@ -38,7 +40,10 @@ class Meta:
]


class DeviceTypeModelSerializer(DeviceTypeBaseSerializer):
class DeviceTypeModelSerializer(
common.CommonModelSerializer,
DeviceTypeBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
7 changes: 6 additions & 1 deletion app/itam/serializers/operating_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from access.serializers.organization import OrganizationBaseSerializer

from api.serializers import common

from core.serializers.manufacturer import ManufacturerBaseSerializer

from itam.models.operating_system import OperatingSystem
Expand Down Expand Up @@ -42,7 +44,10 @@ class Meta:
]


class OperatingSystemModelSerializer(OperatingSystemBaseSerializer):
class OperatingSystemModelSerializer(
common.CommonModelSerializer,
OperatingSystemBaseSerializer
):



Expand Down
7 changes: 6 additions & 1 deletion app/itam/serializers/operating_system_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from access.serializers.organization import OrganizationBaseSerializer

from api.serializers import common

from core.serializers.manufacturer import ManufacturerBaseSerializer

from itam.models.operating_system import OperatingSystem, OperatingSystemVersion
Expand Down Expand Up @@ -54,7 +56,10 @@ class Meta:
]


class OperatingSystemVersionModelSerializer(OperatingSystemVersionBaseSerializer):
class OperatingSystemVersionModelSerializer(
common.CommonModelSerializer,
OperatingSystemVersionBaseSerializer
):



Expand Down
7 changes: 6 additions & 1 deletion app/itam/serializers/software.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from access.serializers.organization import OrganizationBaseSerializer

from api.serializers import common

from core.serializers.manufacturer import ManufacturerBaseSerializer

from itam.models.software import Software
Expand Down Expand Up @@ -41,7 +43,10 @@ class Meta:
]


class SoftwareModelSerializer(SoftwareBaseSerializer):
class SoftwareModelSerializer(
common.CommonModelSerializer,
SoftwareBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
7 changes: 6 additions & 1 deletion app/itam/serializers/software_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from access.serializers.organization import OrganizationBaseSerializer

from api.serializers import common

from core.serializers.manufacturer import ManufacturerBaseSerializer

from itam.models.software import SoftwareCategory
Expand Down Expand Up @@ -40,7 +42,10 @@ class Meta:
]


class SoftwareCategoryModelSerializer(SoftwareCategoryBaseSerializer):
class SoftwareCategoryModelSerializer(
common.CommonModelSerializer,
SoftwareCategoryBaseSerializer
):


_urls = serializers.SerializerMethodField('get_url')
Expand Down
Loading

0 comments on commit 53ce9ca

Please sign in to comment.