From 15d163b3ef4e86c40f2645446518fa4fbaad2acb Mon Sep 17 00:00:00 2001 From: Xevion Date: Mon, 20 Jan 2020 16:12:17 -0600 Subject: [PATCH] create a Season wide builder --- app/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models.py b/app/models.py index 46d5033..cbf69bc 100644 --- a/app/models.py +++ b/app/models.py @@ -31,6 +31,16 @@ class Season(db.Model): else: # Regardless of whether it existended before hand, the episode will be built. pass + + @staticmethod + def create_all(build=True): + """creates new Season objects and runs build() on them""" + for i in range(1, 10): + if Season.query.get(i) is None: + s = Season(id=i) + db.session.add(s) + s.build() + db.session.commit() @property def episodes(self):