class Activity(ActiveRecord): """ Activity Table """ __tablename__ = "activities" __amf_class__ = "vrs.shared.Activity" id = Column(Integer, primary_key=True) guid = Column(String, unique=True, nullable=False, index=True) modified = Column(DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False) revision = Column(Integer, default=0, nullable=False) alias = Column(String, unique=True, nullable=False) kind = Column(String, CheckConstraint("kind in ('game', 'test')"), nullable=False) version = Column(String, nullable=False) sessions = has_many("Session", primaryjoin="Activity.guid==Session.activity_guid") @classmethod def __serialize__(cls): return [ Activity.id, Activity.guid, Activity.alias, Activity.kind, Activity.version ]
class Issue(ActiveRecord): __tablename__ = "issues" id = Column(Integer, primary_key=True) guid = Column(String, unique=True, nullable=False, index=True, default=makeguid) created = Column(DateTime, default=datetime.datetime.utcnow, nullable=False) modified = Column(DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False) deleted = Column(Boolean, default=False, nullable=False, index=True) description = Column(UnicodeCompressedText, nullable=False, default=u"") severity = Column(Bitfield(IssueSeverity), nullable=False) status = Column(Bitfield(IssueStatus), nullable=False, default=IssueStatus.Open) stats = deferred(Column(PropertyDict(typemap=STATS_PROPERTY_TYPEMAP))) labels = has_many("Label", secondary=bind_labels) comments = has_many("Comment", secondary=bind_comments) users = has_many("User", secondary=bind_users) c_year = computed_field(int) c_week = computed_field(int) c_weekday = computed_field(int) m_year = computed_field(int) m_week = computed_field(int) m_weekday = computed_field(int) @orm.reconstructor def _onload(self): (self.c_year, self.c_week, self.c_weekday) = self.created.isocalendar() (self.m_year, self.m_week, self.m_weekday) = self.modified.isocalendar()
class Label(ActiveRecord): __tablename__ = "labels" id = Column(Integer, primary_key=True) guid = Column(String, unique=True, nullable=False, index=True, default=makeguid) title = Column(String, nullable=False) users = has_many("Issue", secondary=bind_labels)
class Customer(ActiveRecord): __tablename__ = "customers" id = Column(Integer, primary_key=True) guid = Column(String, unique=True, nullable=False, index=True, default=makeguid) name = Column(String, unique=True, nullable=False) users = has_many("User")
class Customer(ActiveRecord): __tablename__ = "customers" guid = Column(String, primary_key=True, unique=True, nullable=False, index=True, default=makeguid) contact_guid = Column(String, ForeignKey('contacts.guid'), nullable=False) name = Column(UnicodeText, nullable=False) kind = Column(String, CheckConstraint("kind in ('live', 'beta', 'stage')"), nullable=False) contact = has_one(Contact) users = has_many("User")
class User(ActiveRecord): __tablename__ = "users" id = Column(Integer, primary_key=True) guid = Column(String, unique=True, nullable=False, index=True, default=makeguid) customer_guid = Column(String, ForeignKey('customers.guid'), nullable=False) email = Column(String(32), unique=True, nullable=False, index=True) kind = Column(Bitfield(UserKind), nullable=False, default=UserKind.Customer) customer = has_one(Customer) issues = has_many("Issue", secondary=bind_users)
class Patient(ActiveRecord): """ Patient Table """ __tablename__ = "patients" __amf_class__ = "vrs.shared.Patient" id = Column(Integer, primary_key=True) zone_guid = Column(String, ForeignKey('zones.guid'), nullable=False) guid = Column(String, unique=True, nullable=False, index=True) active = Column(Boolean, default=True, nullable=False) modified = Column(DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False) revision = Column(Integer, default=0, nullable=False) alias = Column(String, nullable=False, index=True) pincode = Column(String, nullable=False, index=True) medical_record = deferred( Column(PropertyDict(typemap=MEDICAL_RECORD_PROPERTY_TYPEMAP))) settings_game = deferred( Column(PropertyDict(typemap=SETTINGS_GAME_PROPERTY_TYPEMAP))) settings_system = deferred(Column(PropertyDict)) zone = has_one(Zone) sessions = has_many("Session", primaryjoin="Patient.guid==Session.patient_guid") @classmethod def __serialize__(cls): return [ Patient.id, Patient.guid, Patient.alias, Patient.pincode, Patient.active, Patient.medical_record ]