summaryrefslogtreecommitdiff
path: root/f1elo/model.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2014-10-28 16:57:06 +0100
committeremkael <emkael@tlen.pl>2014-10-28 16:57:06 +0100
commita47d2c59af1425055d24f66833e090707778fc51 (patch)
treea287bfc74f7807d8b9b9c0ca87cfcb5100c82cf8 /f1elo/model.py
parent6607516ca8fddc6cad330e8789bb0f9dbcfdff3b (diff)
* find_driver moved to appropriate module
Diffstat (limited to 'f1elo/model.py')
-rw-r--r--f1elo/model.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/f1elo/model.py b/f1elo/model.py
index 4b893dc..7865198 100644
--- a/f1elo/model.py
+++ b/f1elo/model.py
@@ -85,5 +85,16 @@ class Ranking(Base):
def __repr__(self):
return ("%s: %0.2f (%s)" % (self.driver.__repr__().decode('utf8'), self.ranking, self. rank_date)).encode('utf8')
+def find_driver(name, country, session):
+ driver = session.query(Driver).filter(Driver.driver==name).first()
+ if driver:
+ return driver
+ else:
+ driver = Driver()
+ driver.driver = name
+ driver.country = country
+ session.add(driver)
+ return driver
+
__all__ = ['Driver', 'Entry', 'Ranking', 'Race', 'RaceType']