Permalink
Browse files

PEP8: Tables properly indented, newlines added.

  • Loading branch information...
1 parent 03139ae commit 871a320e3b3e382db9d699b02919e2083405fe63 @exhuma committed Apr 1, 2013
Showing with 33 additions and 20 deletions.
  1. +33 −20 lost_tracker/models.py
View
@@ -1,5 +1,5 @@
from sqlalchemy import (Column, Integer, Unicode, ForeignKey, Table, and_,
- Boolean)
+ Boolean)
from sqlalchemy.orm import relationship
from sqlalchemy.sql import select
from lost_tracker.database import Base
@@ -9,28 +9,26 @@
STATE_FINISHED = 2
group_station_state = Table(
- 'group_station_state',
- Base.metadata,
- Column('group_id', Integer, ForeignKey('group.id')),
- Column('station_id', Integer, ForeignKey('station.id')),
- Column('state', Integer, default=STATE_UNKNOWN)
- )
+ 'group_station_state',
+ Base.metadata,
+ Column('group_id', Integer, ForeignKey('group.id')),
+ Column('station_id', Integer, ForeignKey('station.id')),
+ Column('state', Integer, default=STATE_UNKNOWN))
station_scores = Table(
- 'station_scores',
- Base.metadata,
- Column('group_id', Integer, ForeignKey('group.id')),
- Column('station_id', Integer, ForeignKey('station.id')),
- Column('score', Integer, default=0)
- )
+ 'station_scores',
+ Base.metadata,
+ Column('group_id', Integer, ForeignKey('group.id')),
+ Column('station_id', Integer, ForeignKey('station.id')),
+ Column('score', Integer, default=0))
form_scores = Table(
- 'form_scores',
- Base.metadata,
- Column('group_id', Integer, ForeignKey('group.id')),
- Column('form_id', Integer),
- Column('score', Integer, default=0)
- )
+ 'form_scores',
+ Base.metadata,
+ Column('group_id', Integer, ForeignKey('group.id')),
+ Column('form_id', Integer),
+ Column('score', Integer, default=0))
+
def get_station_score(group_id, station_id):
s = select([score],
@@ -40,24 +38,28 @@ def get_station_score(group_id, station_id):
))
return s.execute().first()
+
def get_station_score_by_station(station_id):
s = select([group_id, score],
and_(
station_scores.c.station_id == station_id
)).order_by(station_scores.c.group_id)
return s.execute()
+
def get_station_score_by_group(group_id):
s = select([station_id, score],
and_(
station_scores.c.group_id == group_id
)).order_by(station_scores.c.station_id)
return s.execute()
+
def get_station_score_full():
s = select([station_scores]).order_by(station_scores.c.station_id)
return s.execute()
+
def get_form_score(group_id, form_id):
s = select([score],
and_(
@@ -66,24 +68,28 @@ def get_form_score(group_id, form_id):
))
return s.execute().first()
+
def get_form_score_by_group(group_id):
s = select([form_id, score],
and_(
form_scores.c.group_id == group_id,
)).order_by(form_scores.c.form_id)
return s.execute()
+
def get_form_score_by_form(form_id):
s = select([group_id, score],
and_(
form_scores.c.form_id == form_id
)).order_by(form_scores.c.group_id)
return s.execute()
+
def get_form_score_full():
s = select([form_scores]).order_by(form_scores.c.form_id)
return s.execute()
+
def get_state(group_id, station_id):
"""
Given a group and station ID this will return the state of the given
@@ -109,6 +115,7 @@ def get_state(group_id, station_id):
else:
return result[0]
+
def set_station_score(group_id, station_id, score):
s = select([station_scores],
and_(
@@ -124,14 +131,16 @@ def set_station_score(group_id, station_id, score):
u = update_station_score(group_id, station_id, score)
u.execute()
+
def insert_station_score(group_id, station_id, score):
i = station_scores.inster().values(
group_id = group_id,
station_id = station_id,
score = score
)
return i
-
+
+
def update_station_score(group_id, station_id, score):
u = station_scores.filter_by(
group_id = group_id,
@@ -143,6 +152,7 @@ def update_station_score(group_id, station_id, score):
)
return u
+
def set_form_score(group_id, form_id, score):
s = select([form_scores],
and_(
@@ -158,6 +168,7 @@ def set_form_score(group_id, form_id, score):
u = update_form_score(group_id, form_id, score)
u.execute()
+
def insert_form_score(group_id, form_id, score):
i = form_scores.insert().values(
group_id = group_id,
@@ -166,6 +177,7 @@ def insert_form_score(group_id, form_id, score):
)
return i
+
def update_form_score(group_id, form_id, score):
u = form_scores.filter_by(
group_id = group_id,
@@ -177,6 +189,7 @@ def update_form_score(group_id, form_id, score):
)
return u
+
def advance(group_id, station_id):
s = select(['state'], and_(
group_station_state.c.group_id == group_id,

0 comments on commit 871a320

Please sign in to comment.