Commit 99ac1463 authored by Julian Rother's avatar Julian Rother
Browse files

Fixed the way render_endpoint overwrites request.endpoint and fixed parameters of course endpoint

parent 8b65b7b1
#!/bin/python
from flask import Flask, g, request, url_for, redirect, session, render_template, flash
from werkzeug.routing import Rule
from functools import wraps
from datetime import date, timedelta, datetime, time
import os
......@@ -52,8 +53,7 @@ def render_endpoint(endpoint, flashtext=None, **kargs):
if flashtext:
flash(flashtext)
# request.endpoint is used for navbar highlighting
if request.url_rule:
request.url_rule.endpoint = endpoint
request.url_rule = Rule(request.path, endpoint=endpoint)
return app.view_functions[endpoint](**kargs)
@app.errorhandler(404)
......@@ -87,8 +87,12 @@ def videos():
return render_template('course.html', courses=courses, groupedby=groupedby)
@app.route('/course/<id>')
def course(id):
courses = query('SELECT * FROM courses WHERE ((handle = ?) or id = ?) AND (? OR visible)', id, id, ismod())
@app.route('/course/<int:numid>')
def course(numid=None, id=None):
if numid:
courses = query('SELECT * FROM courses WHERE id = ? AND (? OR visible)', numid, ismod())
else:
courses = query('SELECT * FROM courses WHERE handle = ? AND (? OR visible)', id, ismod())
if not courses:
return render_endpoint('index', 'Diese Veranstaltung existiert nicht!'), 404
lectures = query('SELECT * FROM lectures WHERE course_id = ? AND (? OR visible)', courses[0]['id'], ismod())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment