Permalink
Browse files

First commit of STORM lax.

  • Loading branch information...
1 parent 97d7ec8 commit 76ecaa63627f4ad7a0016a4af9a53e600d9f89fe @pauleveritt committed May 1, 2012
Showing with 61 additions and 29 deletions.
  1. +13 −6 piledriver_lax/models.py
  2. +43 −23 piledriver_lax/scratchpad.py
  3. +5 −0 stormlax/README.txt
View
@@ -5,13 +5,21 @@
Base = declarative_base()
+
class Guardian(Base):
__tablename__ = 'guardians'
id = Column(Integer, primary_key=True)
first_name = Column(String)
last_name = Column(String)
sla_rid = Column(Integer)
+ addr1 = Column(String)
+ addr2 = Column(String)
+ city = Column(String)
+ zip = Column(String)
+ home_phone = Column(String)
+ cell_phone = Column(String)
+ email = Column(String)
def __init__(self, first_name, last_name, sla_rid):
self.first_name = first_name
@@ -23,13 +31,17 @@ def __repr__(self):
c = len(self.players)
return fmt % (self.first_name, self.last_name, c)
-
class Player(Base):
__tablename__ = 'players'
id = Column(Integer, primary_key=True)
first_name = Column(String)
last_name = Column(String)
sla_rid = Column(Integer)
+ cell_phone = Column(String)
+ email = Column(String)
+ birthday = Column(String)
+ grade = Column(Integer)
+ sla_team_name = Column(String)
guardian_id = Column(Integer, ForeignKey('guardians.id'))
@@ -45,8 +57,3 @@ def __repr__(self):
guardian_first = self.guardian.first_name
return fmt % (self.first_name, self.last_name, guardian_first)
-all_guardians = [
- Guardian('Paul', 'Everitt', 12),
- Guardian('Stacey', 'Smith', 34),
- Guardian('Jim', 'Harrel', 56),
- ]
@@ -1,48 +1,68 @@
-from time import time
+from wsgiref.simple_server import make_server
+from pyramid.config import Configurator
+from pyramid.response import Response
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from piledriver_lax.models import Base
from piledriver_lax.models import Guardian
from piledriver_lax.models import Player
-from piledriver_lax.models import all_guardians
from piledriver_lax.importer import sla
-def main():
+def load_sla(session):
guardians = sla()
+ for g in guardians.values():
+ guardian = Guardian(g['first_name'], g['last_name'], g['sla_rid'])
+ guardian.addr1 = g['addr1']
+ guardian.addr2 = g['addr2']
+ guardian.city = g['city']
+ guardian.zip = g['zip']
+ guardian.home_phone = g['home_phone']
+ guardian.cell_phone = g['cell_phone']
+
+ for p in g['players']:
+ player = Player(p['first_name'], p['last_name'], p['sla_rid'])
+ player.cell_phone = p['cell_phone']
+ player.email = p['email']
+ player.birthday = p['birthday']
+ player.grade = p['grade']
+ player.sla_team_name = p['sla_team_name']
+ guardian.players.append(player)
+ session.add(guardian)
+
+ for player in session.query(Player):
+ print(player)
+
+ g_sla_rids = [a.sla_rid for a in session.query(Guardian)]
+ p_sla_rids = [a.sla_rid for a in session.query(Player)]
+ print(len(g_sla_rids) + len(p_sla_rids))
+
+def get_session():
engine = create_engine('sqlite:///:memory:')
Base.metadata.create_all(engine)
- start = time()
-
Session = sessionmaker(bind=engine)
session = Session()
- session.add_all(all_guardians)
+ load_sla(session)
session.commit()
- kirsten = Guardian('Kirsten', 'Baylor', 99)
- kirsten.players = [
- Player('Kennedy', 'Baylor', 87),
- Player('Kayla', 'Baylor', 52),
- ]
- session.add(kirsten)
+ return session
- for g in guardians.values():
- guardian = Guardian(g['first_name'], g['last_name'], g['sla_rid'])
- for p in g['players']:
- player = Player(p['first_name'], p['last_name'], p['sla_rid'])
- guardian.players.append(player)
- session.add(guardian)
- session.commit()
+def hello_world(request):
+ return Response('Hello %(name)s!' % request.matchdict)
- for player in session.query(Player):
- print(player)
- print("Elapsed time:", time() - start)
if __name__ == '__main__':
- main()
+ session = get_session()
+ config = Configurator()
+ config.add_route('hello', '/hello/{name}')
+ config.add_view(hello_world, route_name='hello')
+ app = config.make_wsgi_app()
+
+ server = make_server('0.0.0.0', 8080, app)
+ server.serve_forever()
View
@@ -0,0 +1,5 @@
+=============================
+Automation for STORM Lacrosse
+=============================
+
+Rosters, tournaments, mailings, and more.

0 comments on commit 76ecaa6

Please sign in to comment.