diff --git a/calendarium/api.py b/calendarium/api.py index 721fcd3..82333bc 100644 --- a/calendarium/api.py +++ b/calendarium/api.py @@ -11,13 +11,14 @@ from django.utils import timezone from django.utils.translation import get_language_from_request from ninja import Field, NinjaAPI, Redoc, Schema +from ninja.decorators import decorate_view from ninja.renderers import JSONRenderer from ninja.responses import NinjaJSONEncoder from pydantic import AnyUrl, AnyHttpUrl, conint, constr, validator from . import datetools, liturgics, views from .datetools import Calendar -from orthocal.decorators import instrument_endpoint +from orthocal.decorators import cache, etag, etag_date, instrument_endpoint logger = logging.getLogger(__name__) @@ -162,6 +163,7 @@ def not_implemented_handler(request, exc): @api.get('{cal:cal}/{year:year}/{month:month}/{day:day}/', response=DaySchema) @instrument_endpoint +@decorate_view(etag) async def get_calendar_day(request, cal: Calendar, year: year, month: month, day: day): """Get information about the liturgical day for the given calendar and date. The *cal* path parameter should be `gregorian` or `julian`. The legacy `oca` or `rocor` @@ -182,6 +184,8 @@ async def get_calendar_day(request, cal: Calendar, year: year, month: month, day @api.get('{cal:cal}/{year:year}/{month:month}/', response=list[DaySchemaLite]) @instrument_endpoint +@decorate_view(cache) +@decorate_view(etag) async def get_calendar_month(request, cal: Calendar, year: year, month: month) -> list[DaySchemaLite]: """Get information about all the liturgical days for the given calendar and month. This endpoint excludes the readings and stories in order to avoid returning @@ -200,6 +204,7 @@ async def get_calendar_month(request, cal: Calendar, year: year, month: month) - @api.get('{cal:cal}/', response=DaySchema, summary='Get Today') @instrument_endpoint +@decorate_view(etag_date) async def get_calendar_default(request, cal: Calendar): """Get information about the current liturgical day for the given calendar. The timezone is Pacific Time. The *cal* path parameter should be