diff --git a/catalog/api.py b/catalog/api.py index cba5d5ec..a5ebfc29 100644 --- a/catalog/api.py +++ b/catalog/api.py @@ -140,6 +140,24 @@ def get_game(request, uuid: str, response: HttpResponse): return _get_item(Game, uuid, response) +@api.get( + "/performance/{uuid}", + response={200: PerformanceSchema, 302: RedirectedResult, 404: Result}, + auth=None, +) +def get_performance(request, uuid: str, response: HttpResponse): + return _get_item(Performance, uuid, response) + + +@api.get( + "/performance/production/{uuid}", + response={200: PerformanceProductionSchema, 302: RedirectedResult, 404: Result}, + auth=None, +) +def get_performance_production(request, uuid: str, response: HttpResponse): + return _get_item(PerformanceProduction, uuid, response) + + # Legacy API will be removed soon diff --git a/catalog/models.py b/catalog/models.py index 323d5ab4..ff535449 100644 --- a/catalog/models.py +++ b/catalog/models.py @@ -13,7 +13,12 @@ from .tv.models import ( from .music.models import Album, AlbumSchema, AlbumInSchema from .game.models import Game, GameSchema, GameInSchema from .podcast.models import Podcast, PodcastSchema, PodcastInSchema, PodcastEpisode -from .performance.models import Performance, PerformanceProduction +from .performance.models import ( + Performance, + PerformanceProduction, + PerformanceSchema, + PerformanceProductionSchema, +) from .collection.models import Collection as CatalogCollection from .search.models import Indexer from django.contrib.contenttypes.models import ContentType diff --git a/catalog/performance/models.py b/catalog/performance/models.py index 92c1861b..78c47ea4 100644 --- a/catalog/performance/models.py +++ b/catalog/performance/models.py @@ -2,7 +2,49 @@ from functools import cached_property from django.utils.translation import gettext_lazy as _ from django.db import models from catalog.common import * +from catalog.common.models import ItemSchema from catalog.common.utils import DEFAULT_ITEM_COVER +from ninja import Schema + + +class CrewMemberSchema(Schema): + name: str + role: str | None + + +class PerformanceSchema(ItemSchema): + orig_title: str | None = None + other_title: list[str] + genre: list[str] + language: list[str] + opening_date: str | None = None + closing_date: str | None = None + director: list[str] + playwright: list[str] + orig_creator: list[str] + composer: list[str] + choreographer: list[str] + performer: list[str] + actor: list[CrewMemberSchema] + crew: list[CrewMemberSchema] + official_site: str | None = None + + +class PerformanceProductionSchema(ItemSchema): + orig_title: str | None = None + other_title: list[str] + language: list[str] + opening_date: str | None = None + closing_date: str | None = None + director: list[str] + playwright: list[str] + orig_creator: list[str] + composer: list[str] + choreographer: list[str] + performer: list[str] + actor: list[CrewMemberSchema] + crew: list[CrewMemberSchema] + official_site: str | None = None _CREW_SCHEMA = {