class rbVisitType(db.Model): __tablename__ = u'rbVisitType' id = db.Column(db.Integer, primary_key=True) code = db.Column(db.Unicode(8), nullable=False, index=True) name = db.Column(db.Unicode(64), nullable=False, index=True) serviceModifier = db.Column(db.Unicode(128), nullable=False)
class Roles(db.Model): __bind_key__ = 'caesar' __tablename__ = '%s_roles' % TABLE_PREFIX id = db.Column(db.Integer, primary_key=True, autoincrement=True) code = db.Column(db.String(20), unique=True) name = db.Column(db.Unicode(80), unique=True) description = db.Column(db.Unicode(255))
class Settings(db.Model): __bind_key__ = 'caesar' __tablename__ = '%s_settings' % TABLE_PREFIX id = db.Column(db.Integer, primary_key=True, autoincrement=True) code = db.Column(db.String(25), unique=True, nullable=False) name = db.Column(db.Unicode(50), unique=True, nullable=False) value = db.Column(db.Unicode(100)) def __unicode__(self): return self.name
class Street(db.Model): __bind_key__ = 'kladr' __tablename__ = 'STREET' __table_args__ = (db.Index('NAME_SOCR', 'NAME', 'SOCR', 'CODE'), ) NAME = db.Column(db.Unicode(40), nullable=False) SOCR = db.Column(db.Unicode(10), nullable=False) CODE = db.Column(db.String(17), primary_key=True) INDEX = db.Column(db.String(6), nullable=False) GNINMB = db.Column(db.String(4), nullable=False) UNO = db.Column(db.String(4), nullable=False) OCATD = db.Column(db.String(11), nullable=False) infis = db.Column(db.String(5), nullable=False, index=True)
class rbAppointmentType(db.Model): __tablename__ = 'rbAppointmentType' id = db.Column(db.Integer, primary_key=True, autoincrement=True) code = db.Column(db.Unicode(32), nullable=False) name = db.Column(db.Unicode(64), nullable=False) def __unicode__(self): return u'(%s) %s' % (self.code, self.name) def __json__(self): return { 'id': self.id, 'code': self.code, 'name': self.name, }
class Kladr(db.Model): __bind_key__ = 'kladr' __tablename__ = 'KLADR' __table_args__ = (db.Index('long_name', 'prefix', 'NAME', 'SOCR', 'STATUS'), db.Index('NAME', 'NAME', 'SOCR'), db.Index('parent', 'parent', 'NAME', 'SOCR', 'CODE')) NAME = db.Column(db.Unicode(40), nullable=False) SOCR = db.Column(db.Unicode(10), nullable=False) CODE = db.Column(db.String(13), primary_key=True) INDEX = db.Column(db.String(6), nullable=False) GNINMB = db.Column(db.String(4), nullable=False) UNO = db.Column(db.String(4), nullable=False) OCATD = db.Column(db.String(11), nullable=False, index=True) STATUS = db.Column(db.String(1), nullable=False) parent = db.Column(db.String(13), nullable=False) infis = db.Column(db.String(5), nullable=False, index=True) prefix = db.Column(db.String(2), nullable=False) id = db.Column(db.Integer, nullable=False, unique=True)
class Office(db.Model): __tablename__ = 'Office' id = db.Column(db.Integer, primary_key=True, autoincrement=True) code = db.Column(db.Unicode(32), nullable=False) name = db.Column(db.Unicode(64), nullable=False) orgStructure_id = db.Column(db.ForeignKey('OrgStructure.id')) orgStructure = db.relationship('OrgStructure') def __unicode__(self): return self.code def __json__(self): return { 'id': self.id, 'code': self.code, 'name': self.name, 'org_structure': self.orgStructure }
class EventLocalContract(db.Model): __tablename__ = u'Event_LocalContract' __table_args__ = (db.Index(u'lastName', u'lastName', u'firstName', u'patrName', u'birthDate', u'id'), ) id = db.Column(db.Integer, primary_key=True) createDatetime = db.Column(db.DateTime, nullable=False, default=datetime.datetime.now) createPerson_id = db.Column(db.Integer, index=True, default=safe_current_user_id) modifyDatetime = db.Column(db.DateTime, nullable=False, default=datetime.datetime.now, onupdate=datetime.datetime.now) modifyPerson_id = db.Column(db.Integer, index=True, default=safe_current_user_id, onupdate=safe_current_user_id) deleted = db.Column(db.Integer, nullable=False, server_default=u"'0'", default=0) master_id = db.Column(db.Integer) coordDate = db.Column(db.DateTime) coordAgent = db.Column(db.String(128), nullable=False, server_default=u"''") coordInspector = db.Column(db.String(128), nullable=False, server_default=u"''") coordText = db.Column(db.String, nullable=False) dateContract = db.Column(db.Date, nullable=False) numberContract = db.Column(db.Unicode(64), nullable=False) sumLimit = db.Column(db.Float(asdecimal=True), nullable=False) lastName = db.Column(db.Unicode(30), nullable=False) firstName = db.Column(db.Unicode(30), nullable=False) patrName = db.Column(db.Unicode(30), nullable=False) birthDate = db.Column(db.Date, nullable=False, index=True) documentType_id = db.Column(db.Integer, db.ForeignKey('rbDocumentType.id'), index=True) serialLeft = db.Column(db.Unicode(8), nullable=False) serialRight = db.Column(db.Unicode(8), nullable=False) number = db.Column(db.String(16), nullable=False) regAddress = db.Column(db.Unicode(64), nullable=False) org_id = db.Column(db.Integer, db.ForeignKey('Organisation.id'), index=True) org = db.relationship(u'Organisation') documentType = db.relationship(u'rbDocumentType') # payments = db.relationship('EventPayment', backref=db.backref('local_contract')) # Это что вообще?! @property def document(self): document = ClientDocument() document.documentType = self.documentType document.serial = u'%s %s' % (self.serialLeft, self.serialRight) document.number = self.number return document def __unicode__(self): parts = [] if self.coordDate: parts.append(u'согласовано ' + self.coordDate) if self.coordText: parts.append(self.coordText) if self.number: parts.append(u'№ ' + self.number) if self.date: parts.append(u'от ' + self.date) if self.org: parts.append(unicode(self.org)) else: parts.append(self.lastName) parts.append(self.firstName) parts.append(self.patrName) return ' '.join(parts) def __json__(self): return { 'id': self.id, 'number_contract': self.numberContract, 'date_contract': self.dateContract, 'first_name': self.firstName, 'last_name': self.lastName, 'patr_name': self.patrName, 'birth_date': self.birthDate, 'doc_type_id': self.documentType_id, 'doc_type': self.documentType, 'serial_left': self.serialLeft, 'serial_right': self.serialRight, 'number': self.number, 'reg_address': self.regAddress, 'payer_org_id': self.org_id, 'payer_org': self.org, } def __int__(self): return self.id
class ScheduleClientTicket(db.Model): __tablename__ = 'ScheduleClientTicket' id = db.Column(db.Integer, primary_key=True, autoincrement=True) client_id = db.Column(db.Integer, db.ForeignKey('Client.id'), nullable=False) ticket_id = db.Column(db.Integer, db.ForeignKey('ScheduleTicket.id'), nullable=False) isUrgent = db.Column(db.Boolean) note = db.Column(db.Unicode(256), default=u'') appointmentType_id = db.Column(db.Integer, db.ForeignKey('rbAppointmentType.id')) infisFrom = db.Column(db.Unicode(20)) createDatetime = db.Column(db.DateTime, nullable=False, default=datetime.datetime.now) createPerson_id = db.Column(db.Integer, db.ForeignKey('Person.id'), index=True, default=safe_current_user_id) modifyDatetime = db.Column(db.DateTime, nullable=False, default=datetime.datetime.now, onupdate=datetime.datetime.now) modifyPerson_id = db.Column(db.Integer, db.ForeignKey('Person.id'), index=True, default=safe_current_user_id, onupdate=safe_current_user_id) deleted = db.Column(db.SmallInteger, nullable=False, server_default='0', default=0) event_id = db.Column(db.ForeignKey('Event.id')) client = db.relationship('Client', lazy='joined', uselist=False) appointmentType = db.relationship('rbAppointmentType', lazy=False, innerjoin=True) createPerson = db.relationship('Person', foreign_keys=[createPerson_id]) event = db.relationship('Event') ticket = db.relationship( 'ScheduleTicket', lazy=True, innerjoin=True, uselist=False, primaryjoin='and_(' 'ScheduleClientTicket.deleted == 0, ' 'ScheduleTicket.deleted == 0, ' 'ScheduleClientTicket.ticket_id == ScheduleTicket.id)') @property def org_from(self): if not self.infisFrom: return from .exists import Organisation org = Organisation.query.filter( Organisation.infisCode == self.infisFrom).first() if not org: return self.infisFrom return org.title