mirror of
https://github.com/Xevion/the-office.git
synced 2025-12-13 14:13:15 -06:00
finish Section's Quote builder
This commit is contained in:
@@ -58,11 +58,14 @@ class Section(db.Model):
|
|||||||
episode_id = db.Column(db.Integer, db.ForeignKey('episode.id'))
|
episode_id = db.Column(db.Integer, db.ForeignKey('episode.id'))
|
||||||
quotes = db.relationship('Quote', backref='section', lazy='dynamic')
|
quotes = db.relationship('Quote', backref='section', lazy='dynamic')
|
||||||
|
|
||||||
def build(self, quotes):
|
def build(self, quotes, commit=False):
|
||||||
"""given an List of unformatted script quotes, automatically creates Quotes"""
|
"""given an List of unformatted script quotes, automatically creates Quotes assigned to this Section"""
|
||||||
for quote in quotes:
|
for quote in quotes:
|
||||||
match = re.match(r'()')
|
match = re.match()
|
||||||
assert match != None, "Quote '{}' could not be processed.".format(quote)
|
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):
|
class Quote(db.Model):
|
||||||
"""represents a specific quote by a specific speaker"""
|
"""represents a specific quote by a specific speaker"""
|
||||||
|
|||||||
Reference in New Issue
Block a user