Skip to content
Snippets Groups Projects
Commit c5d89586 authored by Adrian Block's avatar Adrian Block
Browse files

Merge branch 'dev' into feat/semester-update

# Conflicts:
#	app/routes/api_v1/endpoints/courses.py
#	app/routes/api_v1/endpoints/semesters.py
#	app/schemas/__init__.py
parents 4badaf35 68b78896
No related branches found
No related tags found
No related merge requests found
from typing import List
from cachetools import TTLCache, cached
from fastapi import APIRouter, Depends, Query, Path
from fastapi import APIRouter, Depends, Query, Path, HTTPException
from app import schemas
from app.data.brokers import Broker, DatabaseBroker
......@@ -30,11 +30,14 @@ def list_all_courses_of_semester(semesterId: int = Query(..., example=1),
return broker.get_all_courses_of_semester(semesterId)
@router.get("/{courseId}", response_model=schemas.Course)
@router.get("/{courseId}", response_model=schemas.Course, responses={404: {"model": schemas.DetailMessage}})
def retrieve_information_of_a_course(semesterId: int = Query(..., example=1),
courseId: str = Path(..., example="L.079.05401"),
broker: Broker = Depends(get_database_broker)):
"""
Querries course by id with all small groups and appointments.
"""
return broker.find_course_by_id(semesterId, courseId)
course = broker.find_course_by_id(semesterId, courseId)
if not course:
raise HTTPException(status_code=404, detail="Course not found")
return course
import os
from typing import List
from fastapi import APIRouter, Depends
......@@ -23,3 +24,8 @@ def see_newest_semesters(broker: DatabaseBroker = Depends(get_database_broker)):
Returns newest semester of all semesters with same name.
"""
return broker.get_newest_semesters()
@router.get("/revision", response_model=int)
def see_current_data_revision():
return os.environ.get("REVISION", 1)
from .course import Course, Appointment, SmallGroup, CourseList, CourseWithoutAppointments, Semester, SemesterList, \
SemesterWithoutCourses, SemesterWithoutCoursesButId
from .message import DetailMessage
from pydantic import BaseModel
class DetailMessage(BaseModel):
detail: str
class Config:
schema_extra = {
"example": {
"detail": "something with XY"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment