mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 11:59:23 +00:00
remove external calendar
This commit is contained in:
21
com/api.py
21
com/api.py
@ -1,8 +1,6 @@
|
||||
from pathlib import Path
|
||||
from typing import Literal
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import Http404, HttpResponse
|
||||
from django.http import HttpResponse
|
||||
from ninja import Query
|
||||
from ninja_extra import ControllerBase, api_controller, paginate, route
|
||||
from ninja_extra.pagination import PageNumberPaginationExtra
|
||||
@ -18,23 +16,6 @@ from core.views.files import send_raw_file
|
||||
|
||||
@api_controller("/calendar")
|
||||
class CalendarController(ControllerBase):
|
||||
CACHE_FOLDER: Path = settings.MEDIA_ROOT / "com" / "calendars"
|
||||
|
||||
@route.get("/external.ics", url_name="calendar_external")
|
||||
def calendar_external(self):
|
||||
"""Return the ICS file of the AE Google Calendar
|
||||
|
||||
Because of Google's cors rules, we can't just do a request to google ics
|
||||
from the frontend. Google is blocking CORS request in its responses headers.
|
||||
The only way to do it from the frontend is to use Google Calendar API with an API key
|
||||
This is not especially desirable as your API key is going to be provided to the frontend.
|
||||
|
||||
This is why we have this backend based solution.
|
||||
"""
|
||||
if (calendar := IcsCalendar.get_external()) is not None:
|
||||
return send_raw_file(calendar)
|
||||
raise Http404
|
||||
|
||||
@route.get("/internal.ics", url_name="calendar_internal")
|
||||
def calendar_internal(self):
|
||||
return send_raw_file(IcsCalendar.get_internal())
|
||||
|
Reference in New Issue
Block a user