Permalink
Browse files

fixed models

  • Loading branch information...
1 parent 56757f2 commit 647e1f9d65b2dc2cbfcdd1725ba17b4d5a0b4b2a @jdubs committed Apr 26, 2012
Showing with 76 additions and 22 deletions.
  1. +1 −1 README
  2. +75 −21 models.py
View
2 README
@@ -1,4 +1,4 @@
stuff & things
-requires flask-login
+requires flask-login, Flask-OAuth
rquires googlemaps api & python
View
@@ -1,23 +1,22 @@
-from sqlalchemy import * #Table, models.Column, Integer, String, DateTime, ForeignKey
-from sqlalchemy.orm import *
+from sqlalchemy import Table, Column, Integer, String, DateTime, ForeignKey
+from sqlalchemy.orm import relationship, backref
from database import Base
from datetime import datetime
-metadata = MetaData()
class User(Base):
"""
Describes the users
"""
__tablename__ = 'user'
__table_args__ = {'mysql_engine':'InnoDB', 'useexisting':True}
- uid = Column(Integer, primary_key=True),
- firstname = Column(String(50)),
- lastname = Column(String(50)),
- email = Column(String(120), unique=True),
- password = Column(String(64)),
- createDate = Column(DateTime, default=datetime.now()),
- updateDate = Column(DateTime, default=datetime.now()),
+ uid = Column(Integer, primary_key=True)
+ firstname = Column(String(50))
+ lastname = Column(String(50))
+ email = Column(String(120), unique=True)
+ password = Column(String(64))
+ createDate = Column(DateTime, default=datetime.now())
+ updateDate = Column(DateTime, default=datetime.now())
status = Column(String(8))
def __init__(self, name=None, email=None):
@@ -26,25 +25,25 @@ def __init__(self, name=None, email=None):
def __repr__(self):
return '<User %r>' % (self.name)
-mapper(User, user, primary_key='uid')
class UserAddresses(Base):
"""
Describes the user's location information.
"""
__tablename__ = 'userAddresses'
__table_args__ = {'mysql_engine':'InnoDB', 'useexisting':True}
- id = Column(Integer, primary_key=True),
- user_id = Column(Integer, ForeignKey('users.uid')),
- streetAddress = Column(String(250)),
- city = Column(String(120)),
- state = Column(String(2)),
- late = Column(String(30)),
- long = Column(String(30)),
- addressType = Column(String(30)),
- createDate = Column(DateTime, default=datetime.now()),
- updateDate = Column(DateTime, default=datetime.now()),
+ id = Column(Integer, primary_key=True)
+ user_id = Column(Integer, ForeignKey('user.uid'))
+ streetAddress = Column(String(250))
+ city = Column(String(120))
+ state = Column(String(2))
+ late = Column(String(30))
+ long = Column(String(30))
+ addressType = Column(String(30))
+ createDate = Column(DateTime, default=datetime.now())
+ updateDate = Column(DateTime, default=datetime.now())
status = Column(String(8))
+ user = relationship("User", backref=backref('users', lazy='dynamic'))
def __init__(self, user_Id, streetAddress, city, state, zipCode, lat, long,
addressType):
@@ -59,3 +58,58 @@ def __init__(self, user_Id, streetAddress, city, state, zipCode, lat, long,
def __repr__(self):
return '<StreetAddress %r>' % (self.streetAddress)
+
+class Thing(Base):
+ """
+ Describes the thing
+ """
+ __tablename__ = 'thing'
+ __table_args__ = {'mysql_engine':'InnoDB', 'useexisting':True}
+ id = Column(Integer, primary_key=True)
+ thingName = Column(String(250))
+ thingType = Column(String(250))
+ createDate = Column(DateTime, default=datetime.now())
+ updateDate = Column(DateTime, default=datetime.now())
+ status = Column(String(8))
+ createdBy= Column(Integer, ForeignKey('user.uid'))
+ user = relationship("User", backref=backref('users', lazy='dynamic'))
+
+ def __init__(self, name=None):
+ self.name = name
+
+ def __repr__(self):
+ return '<Thing %r>' % (Thing.name)
+
+
+class ThingAddresses(Base):
+ """
+ Describes the Thing's location information.
+ """
+ __tablename__ = 'thingAddresses'
+ __table_args__ = {'mysql_engine':'InnoDB', 'useexisting':True}
+ id = Column(Integer, primary_key=True)
+ thing_id = Column(Integer, ForeignKey('thing.id'))
+ streetAddress = Column(String(250))
+ city = Column(String(120))
+ state = Column(String(2))
+ late = Column(String(30))
+ long = Column(String(30))
+ addressType = Column(String(30))
+ createDate = Column(DateTime, default=datetime.now())
+ updateDate = Column(DateTime, default=datetime.now())
+ status = Column(String(8))
+ thing = relationship("Thing", backref=backref('thing', lazy='dynamic'))
+
+ def __init__(self, thing_Id, streetAddress, city, state, zipCode, lat, long,
+ addressType):
+ self.thing_Id = thing_Id
+ self.streetAddress= streetAddress,
+ self.city = city
+ self.state = state
+ self.zipCode = zipCode
+ self.lat = lat
+ self.long = long
+ self.addressType = addressType
+
+ def __repr__(self):
+ return '<ThingAddress %r>' % (self.thingAddress)

0 comments on commit 647e1f9

Please sign in to comment.