mirror of
https://github.com/Xevion/the-office.git
synced 2025-12-15 00:13:23 -06:00
fix routes up to support rendering using passed Season/Episode
still need to decide how to display "errors", perhaps a custom 404 page containing all episode links
This commit is contained in:
@@ -8,15 +8,12 @@ def index():
|
|||||||
|
|
||||||
@app.route('/view')
|
@app.route('/view')
|
||||||
def view():
|
def view():
|
||||||
seasonID = request.args.get('season')
|
season = request.args.get('season', default=-1, type=int)
|
||||||
episodeNUM = request.args.get('episode')
|
episode = request.args.get('episode', default=-1, type=int)
|
||||||
|
|
||||||
season = Season.query.get(int(seasonID))
|
if season != -1:
|
||||||
episode = Episode.query.filter_by(season_id=season.id, number=int(episodeNUM))
|
if episode != -1:
|
||||||
|
return render_template('episode.html', episode=Episode.query.filter_by(season_id=season, episode=episode).first_or_404())
|
||||||
if season:
|
|
||||||
if episode:
|
|
||||||
return render_template('episode.html')
|
|
||||||
else:
|
else:
|
||||||
return render_template('season.html', season=Season.query.get())
|
return render_template('season.html', season=Season.query.filter_by(id=season).first_or_404())
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
Reference in New Issue
Block a user