Introduce DRF views for ticket creation, listing, updating, and commenting, integrate admin registrations for new models, and provide a demo data command to seed initial content. This enables full project management workflow within the backend.
27 lines
628 B
Python
27 lines
628 B
Python
from rest_framework import serializers
|
|
|
|
from src.epics.models import Epic
|
|
|
|
|
|
class EpicSerializer(serializers.ModelSerializer):
|
|
ticket_count = serializers.SerializerMethodField()
|
|
|
|
class Meta:
|
|
model = Epic
|
|
fields = (
|
|
"id",
|
|
"project",
|
|
"name",
|
|
"description",
|
|
"start_date",
|
|
"end_date",
|
|
"sort_order",
|
|
"ticket_count",
|
|
"created_at",
|
|
"updated_at",
|
|
)
|
|
read_only_fields = ("id", "created_at", "updated_at")
|
|
|
|
def get_ticket_count(self, obj):
|
|
return obj.tickets.count()
|