Source code for timApp.slide.routes
import json
from timApp.auth.accesshelper import get_doc_or_abort, verify_manage_access
from timApp.slide.slidestatus import SlideStatus
from timApp.timdb.sqa import db
from timApp.util.flask.responsehelper import json_response, ok_response
from timApp.util.flask.typedblueprint import TypedBlueprint
slide_bp = TypedBlueprint(
"slide",
__name__,
url_prefix="",
)
[docs]@slide_bp.get("/getslidestatus")
def getslidestatus(doc_id: int):
status: SlideStatus = SlideStatus.query.filter_by(doc_id=doc_id).first()
st = status.status if status else None
return json_response(json.loads(st))
[docs]@slide_bp.post("/setslidestatus")
def setslidestatus(
doc_id: int,
indexf: int,
indexh: int,
indexv: int,
):
d = get_doc_or_abort(doc_id)
verify_manage_access(d)
s = SlideStatus(
doc_id=doc_id,
status=json.dumps(dict(indexf=indexf, indexh=indexh, indexv=indexv)),
)
db.session.merge(s)
db.session.commit()
return ok_response()