Skip to content
Snippets Groups Projects
Commit 6f008b7a authored by Simon Künzel's avatar Simon Künzel
Browse files

Small bug fixes

parent cd8ed62b
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,9 @@ DEBUG = True
# Name of this instance
API_SERVER_NAME = "dev"
# With the api version and WITHOUT a trailing /
API_BASE_URL = "localhost:5000/api/v0"
# Prefix which is prepended to paths (which are saved in the database) before they are provided by the api
# Must include the last /
FILE_PATH_PREFIX = "https://video.fsmpi.rwth-aachen.de/files/"
......
......@@ -13,6 +13,8 @@ from api.miscellaneous import *
from api.database import *
import api
_BASE_URL = api.config["API_BASE_URL"]
def api_moderator_route(require_csrf_token: bool = False):
def decorator(func):
......@@ -87,7 +89,7 @@ def is_lecture_authenticated(lecture_id: int) -> bool:
if is_moderator():
return True
lecture = database.query_one_or_none_and_expunge(
Lecture.select(False, True)
Lecture.select(False, True, load_course=True)
.where(Lecture.id == lecture_id)
)
if lecture is None:
......@@ -285,7 +287,6 @@ if DEBUG_ENABLED:
debug_running_oauth = {}
def __start_oauth(scope: str) -> str:
if scope not in ["rwth", "moodle"]:
raise ValueError("Expected scope to be rwth or moodle")
......@@ -297,7 +298,7 @@ if DEBUG_ENABLED:
}
session["oauthcode"] = oauth_code
session["oauthscope"] = scope
return "/debug/dummy_oauth/auth/" + oauth_code
return _BASE_URL + "/debug/dummy_oauth/auth/" + oauth_code
def try_finish_running_authentication():
......
......@@ -17,14 +17,17 @@ from api.routes.route import (
)
from api.authentication import api_moderator_route, is_moderator, get_user_id, _check_csrf_token
import api.routes.authentication
import api.routes.courses
import api.routes.feedback
import api.routes.job
import api.routes.media_process
import api.routes.site
import api.routes.object_modifications
import api.routes.user
import api.routes.miscellaneous
from . import (
authentication,
courses,
feedback,
job,
media_process,
site,
object_modifications,
resources,
user,
miscellaneous,
)
__register_routes_to_flask()
......@@ -35,7 +35,7 @@ def api_route_courses():
("include_lectures", "?boolean", "If `true`, `lectures` will be present. Default is `false`")
],
response_object_id="course")
def api_route_course(course_id: int = None, course_id_string: str = None):
def api_route_course(course_id: int = None, course_handle: str = None):
is_mod: bool = is_moderator()
include_lectures = "include_lectures" in request.args and request.args["include_lectures"] == "true"
......@@ -46,7 +46,7 @@ def api_route_course(course_id: int = None, course_id_string: str = None):
if course_id:
stmt = stmt.where(Course.id == course_id)
else:
stmt = stmt.where(Course.handle == course_id_string)
stmt = stmt.where(Course.handle == course_handle)
course = database.query_one_or_none_and_expunge(stmt)
if not course:
......
from typing import Sequence
from flask import request, Response, redirect
from flask import redirect
from api.routes import *
@api_route("/resources/lecture_thumbnail/<int:lecture_id>", "GET", allow_while_readonly=True,
no_documentation=True)
def api_route_access_lecture_thumbnail():
def api_route_access_lecture_thumbnail(lecture_id: int):
return redirect("https://video.fsmpi.rwth-aachen.de/files/thumbnail/l_17253.jpg")
@api_route("/resources/target_medium/<int:target_medium_id>", "GET", allow_while_readonly=True,
no_documentation=True)
def api_route_access_target_medium():
def api_route_access_target_medium(target_medium_id: int):
return redirect("https://video.fsmpi.rwth-aachen.de/files/pub/23ws-buk/23ws-buk-231012-1080p.mp4")
backend_common_py @ d70c2e45
Subproject commit 77964028a2db2281de33cdd9f7a8759148aadc9a
Subproject commit d70c2e459b3ebd4ac2c4e7bb4d965cfe13ee54f2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment