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

Small bug fixes

parent c6001f60
Branches
No related tags found
No related merge requests found
Pipeline #6660 failed
Pipeline: development

#6661

    ...@@ -4,6 +4,9 @@ DEBUG = True ...@@ -4,6 +4,9 @@ DEBUG = True
    # Name of this instance # Name of this instance
    API_SERVER_NAME = "dev" 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 # Prefix which is prepended to paths (which are saved in the database) before they are provided by the api
    # Must include the last / # Must include the last /
    FILE_PATH_PREFIX = "https://video.fsmpi.rwth-aachen.de/files/" FILE_PATH_PREFIX = "https://video.fsmpi.rwth-aachen.de/files/"
    ......
    ...@@ -13,6 +13,8 @@ from api.miscellaneous import * ...@@ -13,6 +13,8 @@ from api.miscellaneous import *
    from api.database import * from api.database import *
    import api import api
    _BASE_URL = api.config["API_BASE_URL"]
    def api_moderator_route(require_csrf_token: bool = False): def api_moderator_route(require_csrf_token: bool = False):
    def decorator(func): def decorator(func):
    ...@@ -87,7 +89,7 @@ def is_lecture_authenticated(lecture_id: int) -> bool: ...@@ -87,7 +89,7 @@ def is_lecture_authenticated(lecture_id: int) -> bool:
    if is_moderator(): if is_moderator():
    return True return True
    lecture = database.query_one_or_none_and_expunge( lecture = database.query_one_or_none_and_expunge(
    Lecture.select(False, True) Lecture.select(False, True, load_course=True)
    .where(Lecture.id == lecture_id) .where(Lecture.id == lecture_id)
    ) )
    if lecture is None: if lecture is None:
    ...@@ -285,7 +287,6 @@ if DEBUG_ENABLED: ...@@ -285,7 +287,6 @@ if DEBUG_ENABLED:
    debug_running_oauth = {} debug_running_oauth = {}
    def __start_oauth(scope: str) -> str: def __start_oauth(scope: str) -> str:
    if scope not in ["rwth", "moodle"]: if scope not in ["rwth", "moodle"]:
    raise ValueError("Expected scope to be rwth or moodle") raise ValueError("Expected scope to be rwth or moodle")
    ...@@ -297,7 +298,7 @@ if DEBUG_ENABLED: ...@@ -297,7 +298,7 @@ if DEBUG_ENABLED:
    } }
    session["oauthcode"] = oauth_code session["oauthcode"] = oauth_code
    session["oauthscope"] = scope session["oauthscope"] = scope
    return "/debug/dummy_oauth/auth/" + oauth_code return _BASE_URL + "/debug/dummy_oauth/auth/" + oauth_code
    def try_finish_running_authentication(): def try_finish_running_authentication():
    ......
    ...@@ -17,14 +17,17 @@ from api.routes.route import ( ...@@ -17,14 +17,17 @@ from api.routes.route import (
    ) )
    from api.authentication import api_moderator_route, is_moderator, get_user_id, _check_csrf_token from api.authentication import api_moderator_route, is_moderator, get_user_id, _check_csrf_token
    import api.routes.authentication from . import (
    import api.routes.courses authentication,
    import api.routes.feedback courses,
    import api.routes.job feedback,
    import api.routes.media_process job,
    import api.routes.site media_process,
    import api.routes.object_modifications site,
    import api.routes.user object_modifications,
    import api.routes.miscellaneous resources,
    user,
    miscellaneous,
    )
    __register_routes_to_flask() __register_routes_to_flask()
    ...@@ -35,7 +35,7 @@ def api_route_courses(): ...@@ -35,7 +35,7 @@ def api_route_courses():
    ("include_lectures", "?boolean", "If `true`, `lectures` will be present. Default is `false`") ("include_lectures", "?boolean", "If `true`, `lectures` will be present. Default is `false`")
    ], ],
    response_object_id="course") 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() is_mod: bool = is_moderator()
    include_lectures = "include_lectures" in request.args and request.args["include_lectures"] == "true" 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): ...@@ -46,7 +46,7 @@ def api_route_course(course_id: int = None, course_id_string: str = None):
    if course_id: if course_id:
    stmt = stmt.where(Course.id == course_id) stmt = stmt.where(Course.id == course_id)
    else: 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) course = database.query_one_or_none_and_expunge(stmt)
    if not course: if not course:
    ......
    from typing import Sequence from flask import redirect
    from flask import request, Response, redirect
    from api.routes import * from api.routes import *
    @api_route("/resources/lecture_thumbnail/<int:lecture_id>", "GET", allow_while_readonly=True, @api_route("/resources/lecture_thumbnail/<int:lecture_id>", "GET", allow_while_readonly=True,
    no_documentation=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") 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, @api_route("/resources/target_medium/<int:target_medium_id>", "GET", allow_while_readonly=True,
    no_documentation=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") return redirect("https://video.fsmpi.rwth-aachen.de/files/pub/23ws-buk/23ws-buk-231012-1080p.mp4")
    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