From 4aa971ba9f8cd8b66ae3a2287c40b3af92f1b8f8 Mon Sep 17 00:00:00 2001 From: Xevion Date: Sun, 19 Jan 2020 22:34:48 -0600 Subject: [PATCH] finish Section's Quote builder --- app/models.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/models.py b/app/models.py index b8e894f..fc2024f 100644 --- a/app/models.py +++ b/app/models.py @@ -58,12 +58,15 @@ class Section(db.Model): episode_id = db.Column(db.Integer, db.ForeignKey('episode.id')) quotes = db.relationship('Quote', backref='section', lazy='dynamic') - def build(self, quotes): - """given an List of unformatted script quotes, automatically creates Quotes""" + def build(self, quotes, commit=False): + """given an List of unformatted script quotes, automatically creates Quotes assigned to this Section""" for quote in quotes: - match = re.match(r'()') + match = re.match() assert match != None, "Quote '{}' could not be processed.".format(quote) - + q = Quote(section=self, speaker=match[1], text=match[2]) + db.session.add(q) + if commit: db.session.commit() + class Quote(db.Model): """represents a specific quote by a specific speaker""" id = db.Column(db.Integer, primary_key=True)