mirror of
https://github.com/ae-utbm/sith.git
synced 2025-06-08 04:05:22 +00:00
Disable cache on ics calendar on API response headers
This commit is contained in:
parent
d80f2e73e8
commit
bfea0989fb
@ -1,6 +1,7 @@
|
||||
from typing import Literal
|
||||
|
||||
from django.http import HttpResponse
|
||||
from django.utils.cache import add_never_cache_headers
|
||||
from ninja import Query
|
||||
from ninja_extra import ControllerBase, api_controller, paginate, route
|
||||
from ninja_extra.pagination import PageNumberPaginationExtra
|
||||
@ -18,7 +19,9 @@ from core.views.files import send_raw_file
|
||||
class CalendarController(ControllerBase):
|
||||
@route.get("/internal.ics", url_name="calendar_internal")
|
||||
def calendar_internal(self):
|
||||
return send_raw_file(IcsCalendar.get_internal())
|
||||
response = send_raw_file(IcsCalendar.get_internal())
|
||||
add_never_cache_headers(response)
|
||||
return response
|
||||
|
||||
@route.get(
|
||||
"/unpublished.ics",
|
||||
@ -26,10 +29,12 @@ class CalendarController(ControllerBase):
|
||||
url_name="calendar_unpublished",
|
||||
)
|
||||
def calendar_unpublished(self):
|
||||
return HttpResponse(
|
||||
response = HttpResponse(
|
||||
IcsCalendar.get_unpublished(self.context.request.user),
|
||||
content_type="text/calendar",
|
||||
)
|
||||
add_never_cache_headers(response)
|
||||
return response
|
||||
|
||||
|
||||
@api_controller("/news")
|
||||
|
Loading…
x
Reference in New Issue
Block a user