class Driver(Base, ReprMixin): __tablename__ = 'driver' id = Column(String, default=uuid, primary_key=True) user_id = Column(String, ForeignKey('user.id')) car_make = Column(String) car_model = Column(String) car_color = Column(String) license_plate = Column(String) telephone = Column(String) hidden = Column(Boolean, default=False) active = Column(Boolean, default=True) created = Column(DateTime, default=datetime.utcnow) updated = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) user = relationship('User', uselist=False, cascade='expunge') drive_requests = \ relationship('DriveRequest', uselist=True, cascade='expunge', primaryjoin="" "and_(Driver.id == DriveRequest.driver_id," "DriveRequest.active == True)") @property def created_day(self): return self.created.date()
class Passenger(Base, ReprMixin): __tablename__ = 'passenger' id = Column(String, default=uuid, primary_key=True) user_id = Column(String, ForeignKey('user.id')) origin = Column(Text) origin_latitude = Column(Float) origin_longitude = Column(Float) destination = Column(Text) destination_latitude = Column(Float) destination_longitude = Column(Float) distance = Column(Float, nullable=False, server_default=text('0')) seats = Column(Integer) pickup_time = Column(Time, nullable=True) pickup_time_new = Column('pickup_time_new', DateTime, nullable=True) matched = Column(Boolean, default=False) active = Column(Boolean, default=True) created = Column(DateTime, default=datetime.utcnow) updated = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) user = relationship('User', uselist=False, cascade='expunge') drive_requests = \ relationship('DriveRequest', uselist=True, cascade='expunge', primaryjoin="" "and_(Passenger.id == DriveRequest.passenger_id," "DriveRequest.active == True)") @property def created_day(self): return self.created.date()
class ActiveDriverPerk(Base, ReprMixin): __tablename__ = 'active_driver_perk' id = Column(String, default=uuid, primary_key=True) created = Column(DateTime, default=datetime.utcnow) updated = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) deleted = Column(Boolean, default=False, nullable=False) user_id = Column(String, ForeignKey('user.id'), nullable=True) perk_id = Column(String, ForeignKey('driver_perk.id'), nullable=True) valid_until = Column(DateTime, nullable=False) user = relationship('User', uselist=False, cascade='expunge') perk = relationship('DriverPerk', uselist=False, cascade='expunge')
class Token(Base, ReprMixin): __tablename__ = 'token' id = Column(String, default=uuid, primary_key=True) user_id = Column(String, ForeignKey('user.id')) created = Column(DateTime, default=datetime.utcnow) updated = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) user = \ relationship('User', uselist=False, cascade='expunge')
class DriveRequest(Base, ReprMixin): __tablename__ = 'drive_request' id = Column(String, default=uuid, primary_key=True) driver_id = Column(String, ForeignKey('driver.id')) passenger_id = Column(String, ForeignKey('passenger.id')) accepted = Column(Boolean, default=False) cancelled = Column(Boolean, default=False) active = Column(Boolean, default=True) response_time = Column(Integer, nullable=False, server_default=text('0')) offered_pickup_time = Column(DateTime, nullable=True) created = Column(DateTime, default=datetime.utcnow) updated = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) driver = relationship('Driver', uselist=False, cascade='expunge') passenger = relationship('Passenger', uselist=False, cascade='expunge') @property def created_day(self): return self.created.date()
class UserPosition(Base, ReprMixin): __tablename__ = 'user_position' id = Column(String, default=uuid, primary_key=True) archived = Column(Boolean, default=False, nullable=False) created = Column(DateTime, default=datetime.utcnow) updated = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) user_id = Column(String, ForeignKey('user.id'), nullable=False) latitude = Column(Float, nullable=False) longitude = Column(Float, nullable=False) region = Column(String, nullable=False) user = relationship('User', uselist=False, cascade='expunge')
class Feedback(Base, ReprMixin): __tablename__ = 'feedback' id = Column(String, default=uuid, primary_key=True) user_id = Column(String, ForeignKey('user.id')) message = Column(Text) created = Column(DateTime, default=datetime.utcnow) updated = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) user = relationship('User', uselist=False) @property def created_day(self): return self.created.date()
class User(Base, ReprMixin): __tablename__ = 'user' id = Column(String, default=uuid, primary_key=True) acs_id = Column(String) # XXX Should be not nullable facebook_id = Column(String) # XXX Should be not nullable facebook_token = Column(String, nullable=False, server_default=text('')) first_name = Column(String, nullable=False, server_default=text('')) last_name = Column(String, nullable=False, server_default=text('')) name = Column(String, nullable=False) avatar_unresolved = Column(String, nullable=True) avatar = Column(String, nullable=True) email = Column(String, nullable=True) locale = Column(String, nullable=False) deleted = Column(Boolean, default=False, nullable=False) created = Column(DateTime, default=datetime.utcnow) updated = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) drivers = relationship('Driver', uselist=True, cascade='expunge') active_driver = relationship('Driver', uselist=False, cascade='expunge', primaryjoin="" "and_(User.id == Driver.user_id," "Driver.active == True)") active_passenger = \ relationship('Passenger', uselist=False, cascade='expunge', primaryjoin="" "and_(User.id == Passenger.user_id," "Passenger.active == True)") token = relationship('Token', uselist=True, cascade='expunge') traces = relationship('Trace', uselist=True, cascade='expunge') position = relationship('UserPosition', uselist=False, cascade='expunge', primaryjoin="" "and_(User.id == UserPosition.user_id," "UserPosition.archived == False)") @property def created_day(self): return self.created.date()