add more text alignment fixes, create "unbuilt" parameter to track and build episodes as needed

This commit is contained in:
Xevion
2020-01-22 01:41:32 -06:00
parent 283f15794e
commit 283c4dbcc6
3 changed files with 26 additions and 7 deletions

View File

@@ -65,6 +65,7 @@ class Episode(db.Model):
id = db.Column(db.Integer, primary_key=True) # arbitrary ID, should NOT be relied on to determine episode number or correlating season
number = db.Column(db.Integer) # episode number
season_id = db.Column(db.Integer, db.ForeignKey('season.id')) # correlating season number
built = db.Column(db.Boolean, default=False)
sections = db.relationship('Section', backref='episode', lazy='dynamic') # sections of quotes under this episode
def build(self):
@@ -97,9 +98,11 @@ class Episode(db.Model):
s = Section(episode_id=self.id, deleted=deleted if isDeletedScene else -1, newpeat=isNewpeat)
s.build(quotes[1:] if isDeletedScene else quotes)
db.session.add(s)
self.built = True
db.session.commit()
def rebuild(self):
"""functions that clears relevant sections from this Episode"""
self.clear()
self.build()
@@ -109,6 +112,7 @@ class Episode(db.Model):
print(f'Clearing {len(sections)} Sections of Ep {self.number} Season {self.season_id}')
for section in sections:
section.clear(commit=False, delete=True)
self.built = False
db.session.commit()
@staticmethod

View File

@@ -12,7 +12,11 @@ def viewSeason(season):
@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())
e = Episode.query.filter_by(season_id=season, number=episode).first_or_404()
if not e.built:
print('Rebuilding')
e.build()
return render_template('episode.html', episode=e)
@app.route('/season/<season>/<episode>/rebuild')
def rebuildEpisode(season, episode):

View File

@@ -1,4 +1,12 @@
{% extends 'content.html' %}
{% block head %}
{{ super() }}
<style>
.quote {
text-align: left;
}
</style>
{% endblock head %}
{% block content %}
<a href="{{ url_for('viewSeason', season=episode.season_id) }}">Go to Season {{ episode.season_id }}</a>
<br>
@@ -6,10 +14,13 @@
<br>
<br>
{% for section in episode.sections %}
<div style="padding: 2rem 1rem 1rem 2rem;">
<p>
{% for quote in section.quotes %}
<b>{{ quote.speaker }}:</b> {{ quote.text }}
<span class="quote"><b>{{ quote.speaker }}:</b> {{ quote.text }}</span>
<br>
{% endfor %}
<br>
</p>
</div>
{% endfor %}
{% endblock content %}