mirror of
https://github.com/Xevion/the-office.git
synced 2025-12-10 02:08:48 -06:00
add in Episode route, forward/back buttons
preparing to add in CSS and stuff, but I'm kind of not-at-all-wanting-to-do-that
This commit is contained in:
@@ -99,13 +99,16 @@ class Episode(db.Model):
|
||||
db.session.add(s)
|
||||
db.session.commit()
|
||||
|
||||
def rebuild(self):
|
||||
self.clear()
|
||||
self.build()
|
||||
|
||||
def clear(self):
|
||||
"""delete all sections relevant to this episode in order to reprocess"""
|
||||
sections = Section.query.filter_by(episode_id=self.id).all()
|
||||
print(f'Clearing {len(sections)} Sections of Ep {self.number} Season {self.season_id}')
|
||||
for section in sections:
|
||||
section.clear(commit=False)
|
||||
db.session.delete(section)
|
||||
section.clear(commit=False, delete=True)
|
||||
db.session.commit()
|
||||
|
||||
@staticmethod
|
||||
@@ -139,12 +142,13 @@ class Section(db.Model):
|
||||
db.session.add(q)
|
||||
if commit: db.session.commit()
|
||||
|
||||
def clear(self, doprint=True, commit=True):
|
||||
def clear(self, doprint=True, commit=True, delete=False):
|
||||
"""delete all quotes relevant to this section"""
|
||||
quotes = Quote.query.filter_by(section_id=self.id).all()
|
||||
if doprint: print(f'Clearing {len(quotes)} quotes from Section ID {self.id}')
|
||||
for quote in quotes:
|
||||
db.session.delete(quote)
|
||||
if delete: db.session.delete(self)
|
||||
if commit: db.session.commit()
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -7,9 +7,15 @@ def index():
|
||||
return render_template('view.html', seasons=Season.query.all())
|
||||
|
||||
@app.route('/season/<season>/')
|
||||
def season(season):
|
||||
def viewSeason(season):
|
||||
return render_template('season.html', season=Season.query.filter_by(id=season).first_or_404())
|
||||
|
||||
@app.route('/season/<season>/<episode>')
|
||||
def episode(season, episode):
|
||||
return render_template('episode.html', episode=Episode.query.filter_by(season_id=season, number=episode).first_or_404())
|
||||
@app.route('/season/<season>/<episode>/')
|
||||
def viewEpisode(season, episode):
|
||||
return render_template('episode.html', episode=Episode.query.filter_by(season_id=season, number=episode).first_or_404())
|
||||
|
||||
@app.route('/season/<season>/<episode>/rebuild')
|
||||
def rebuildEpisode(season, episode):
|
||||
e = Episode.query.filter_by(season_id=season, number=episode).first_or_404()
|
||||
e.rebuild()
|
||||
return redirect(url_for('viewEpisode', season=season, episode=episode))
|
||||
@@ -1,5 +1,10 @@
|
||||
{% extends 'content.html' %}
|
||||
{% block body %}
|
||||
<a href="{{ url_for('viewSeason', season=episode.season_id) }}" >Go to Season {{ episode.season_id }}</a>
|
||||
<br>
|
||||
<a href="{{ url_for('rebuildEpisode', season=episode.season_id, episode=episode.number) }}">Rebuild Episode</a>
|
||||
<br>
|
||||
<br>
|
||||
{% for section in episode.sections %}
|
||||
{% for quote in section.quotes %}
|
||||
<b>{{ quote.speaker }}:</b> {{ quote.text }}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block body %}
|
||||
{{ super() }}
|
||||
|
||||
<a href="{{ url_for('index') }}" >See all Seasons</a>
|
||||
<br><br>
|
||||
|
||||
Season {{ season.id }}
|
||||
<br>
|
||||
{% for episode in season.episodes %}
|
||||
|
||||
Reference in New Issue
Block a user