Skip to content

Commit

Permalink
chore: refining items
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-nfc committed Oct 11, 2024
1 parent 18029cf commit 2d86e87
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 14 deletions.
3 changes: 2 additions & 1 deletion app/api/v2/serializers/core/ticket_linked_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class TicketLinkedItemBaseSerializer(serializers.ModelSerializer):

def get_display_name(self, item):

return '#' + str( item.ticket.id )
return str( item )


url = serializers.HyperlinkedIdentityField(
view_name="API:_api_v2_device-detail", format="html"
Expand Down
24 changes: 12 additions & 12 deletions app/api/v2/serializers/itam/device_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ def get_display_name(self, item):

return str( item )

# _urls = serializers.SerializerMethodField('get_url')

# def get_url(self, obj):

# return {
# '_self': reverse("API:_api_v2_device-detail", request=self._context['view'].request, kwargs={'pk': obj.pk})
# }

url = serializers.HyperlinkedIdentityField(
view_name="API:_api_v2_device_model-detail", format="html"
Expand Down Expand Up @@ -49,7 +42,14 @@ class Meta:

class ModelSerializer(BaseSerializer):

pass

_urls = serializers.SerializerMethodField('get_url')

def get_url(self, obj):

return {
'_self': reverse("API:_api_v2_device_model-detail", request=self._context['view'].request, kwargs={'pk': obj.pk})
}

class Meta:

Expand All @@ -73,14 +73,14 @@ class Meta:
# '_urls',
# ]

# read_only_fields = [
# 'id',
read_only_fields = [
'id',
# 'display_name',
# 'inventorydate',
# 'created',
# 'modified',
# '_urls',
# ]
'_urls',
]



Expand Down
17 changes: 17 additions & 0 deletions app/api/v2/tests/functional/abstract/test_view_set_functional.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

from django.test import TestCase



class ViewSetAttributesUnit:
""" Funcntional Tests For View Setd.
These tests ensure that View sets functionality is correct.
"""

@pytest.mark.skip(reason='to be writtem')
def test_data_queryset(self):
"""test data returned is from the users orgs only
"""

pass
47 changes: 47 additions & 0 deletions app/api/v2/tests/unit/abstract/test_view_set_unit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

from django.test import TestCase



class ViewSetAttributesUnit:
""" Unit Tests For View Set attributes.
These tests ensure that View sets contian the required attributesthat are
used by the API .
"""


def test_attribute_exists_page_layout(self):
"""Attrribute Test, Exists
Ensure attribute `page_layout` exists
"""

pass


def test_attribute_type_page_layout(self):
"""Attrribute Test, Type
Ensure attribute `page_layout` is of type `list`
"""

pass


def test_attribute_not_callable_page_layout(self):
"""Attrribute Test, Not Callable
Attribute must be a property
Ensure attribute `page_layout` is not callable.
"""

pass

# other tests required
# - filterset_fields
# - metadata_class
# - search_fields
# - documentation
# - model_documentation or is in `model.documentation`
5 changes: 5 additions & 0 deletions app/api/v2/views/settings/device_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from access.mixin import OrganizationMixin

from api.v2.serializers.itam.device_model import ModelSerializer, ViewSerializer
from api.v2.views.metadata import NavigationMetadata
from api.views.mixin import OrganizationPermissionAPI

from itam.models.device_models import DeviceModel
Expand All @@ -17,12 +18,16 @@

class ViewSet(OrganizationMixin, viewsets.ModelViewSet):

metadata_class = NavigationMetadata

permission_classes = [
OrganizationPermissionAPI
]

queryset = DeviceModel.objects.all()

page_layout = DeviceModel.page_layout

def get_serializer_class(self):

if (
Expand Down
3 changes: 3 additions & 0 deletions app/api/v2/views/settings/external_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from access.mixin import OrganizationMixin

from settings.serializers.external_links import ExternalLink, ExternalLinkModelSerializer, ExternalLinkViewSerializer
from api.v2.views.metadata import NavigationMetadata
from api.views.mixin import OrganizationPermissionAPI

# from settings.models.external_link import ExternalLink
Expand All @@ -22,6 +23,8 @@ class ViewSet(OrganizationMixin, viewsets.ModelViewSet):
'software',
]

metadata_class = NavigationMetadata

permission_classes = [
OrganizationPermissionAPI
]
Expand Down
19 changes: 18 additions & 1 deletion app/api/v2/views/settings/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,24 @@ class Index(viewsets.ViewSet):
permission_classes = []

page_layout: list = [
"sdas"
{
"name": "Core",
"links": [
{
"name": "External Links",
"model": "external_link"
}
]
},
{
"name": "ITAM",
"links": [
{
"name": "Device Model",
"model": "device_model"
}
]
}
]

def get_view_name(self):
Expand Down
36 changes: 36 additions & 0 deletions app/itam/models/device_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,42 @@ class Meta:
blank= True
)

table_fields: list = [
'manufacturer',
'name',
'organization',
'created',
'modified'
]

page_layout: dict = [
{
"name": "Details",
"slug": "details",
"sections": [
{
"layout": "double",
"left": [
'organization',
'manufacturer',
'name',
'created',
'modified',
],
"right": [
'model_notes',
'is_global',
]
}
]
},
# {
# "name": "Notes",
# "slug": "notes",
# "sections": []
# }
]


def clean(self):

Expand Down

0 comments on commit 2d86e87

Please sign in to comment.