mirror of
https://github.com/Xevion/the-office.git
synced 2025-12-16 10:13:35 -06:00
add rebuild parameter, fix multi printing
This commit is contained in:
@@ -15,10 +15,10 @@ class Season(db.Model):
|
|||||||
assert 0 <= kwargs.get('id') <= 9, "Season ID must be 0-9 inclusive"
|
assert 0 <= kwargs.get('id') <= 9, "Season ID must be 0-9 inclusive"
|
||||||
super(Season, self).__init__(**kwargs)
|
super(Season, self).__init__(**kwargs)
|
||||||
|
|
||||||
def build(self):
|
def build(self, rebuild=False):
|
||||||
"""runs build operations on every Episode under this season"""
|
"""runs build operations on every Episode under this season"""
|
||||||
for episode in range(1, episodes[self.id - 1] + 1):
|
|
||||||
print(f'Running build() on Season {self.id}')
|
print(f'Running build() on Season {self.id}')
|
||||||
|
for episode in range(1, episodes[self.id - 1] + 1):
|
||||||
ep = Episode.query.filter_by(season_id=self.id, number=episode).first()
|
ep = Episode.query.filter_by(season_id=self.id, number=episode).first()
|
||||||
if ep is None:
|
if ep is None:
|
||||||
# Add the episode, then build
|
# Add the episode, then build
|
||||||
@@ -29,7 +29,8 @@ class Season(db.Model):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
ep.build()
|
ep.build()
|
||||||
else:
|
else:
|
||||||
# Regardless of whether it existended before hand, the episode will be built.
|
if rebuild:
|
||||||
|
ep.build()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user