Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
env:
DEBUG: 'True'
CORS_ALLOWED_ORIGIN: 'http://localhost:5173'
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: |
python manage.py migrate

Expand All @@ -56,6 +57,7 @@ jobs:
env:
DEBUG: 'True'
CORS_ALLOWED_ORIGIN: 'http://localhost:5173'
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: |
pytest --cov=. --cov-report=xml --cov-report=term

Expand Down
2 changes: 2 additions & 0 deletions backend/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,6 @@
"rest_framework.authentication.SessionAuthentication",
"rest_framework.authentication.TokenAuthentication", # Or JWT
],
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
"PAGE_SIZE": 10,
}
4 changes: 2 additions & 2 deletions backend/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

urlpatterns = [
path("admin/", admin.site.urls),
# API Routes - Uncomment when ready to use
# API Routes
path("api/", include("inventory.urls")),
# path('api/', include('users.urls')),
# path('api/inventory/', include('inventory.urls')),
# path('api/', include('requests.urls')),
]

Expand Down
68 changes: 44 additions & 24 deletions backend/inventory/serializers.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@
from rest_framework import serializers
from .models import CollectionItem, Location

# from .models import InventoryItem

# Create your serializers here.

# Example: InventoryItem Serializer
# Uncomment and modify as needed
#
# class InventoryItemSerializer(serializers.ModelSerializer):
# """
# Serializer for the InventoryItem model.
# Handles conversion between model instances and JSON.
# """
# created_by_username = serializers.CharField(source='created_by.username', read_only=True)
#
# class Meta:
# model = InventoryItem
# fields = '__all__' # Or specify: ['id', 'name', 'quantity', ...]
# read_only_fields = ['id', 'created_at', 'updated_at', 'created_by']
#
# def validate_quantity(self, value):
# """Custom validation for quantity field."""
# if value < 0:
# raise serializers.ValidationError("Quantity cannot be negative.")
# return value

class LocationSerializer(serializers.ModelSerializer):
"""
Nested serializer for Location model.
Used to show location details in public API responses.
"""

location_type_display = serializers.CharField(source="get_location_type_display", read_only=True)

class Meta:
model = Location
fields = ["id", "name", "location_type", "location_type_display", "description"]
read_only_fields = ["id", "name", "location_type", "location_type_display", "description"]


class PublicCollectionItemSerializer(serializers.ModelSerializer):
"""
Serializer for public-facing collection items.
Exposes read-only collection data without internal fields.
"""

current_location = LocationSerializer(read_only=True)

class Meta:
model = CollectionItem
fields = [
"id",
"item_code",
"title",
"platform",
"description",
"is_on_floor",
"current_location",
]
read_only_fields = [
"id",
"item_code",
"title",
"platform",
"description",
"is_on_floor",
"current_location",
]
Loading