class CW_position(db.Model): __tablename__ = 'cw_positions' id = db.Column(db.Integer, primary_key=True) doors_quantity = db.Column(db.Integer) cw_vendor_code_id = db.Column(db.Integer, db.ForeignKey('cw_vendor_codes.id')) cw_order_id = db.Column(db.Integer, db.ForeignKey('cw_orders.id'))
class Sentence(db.Model): id = db.Column(db.Integer, primary_key=True) body = db.Column(db.String(350), unique=True, nullable=False) word_id = db.Column(db.Integer, db.ForeignKey('word.id'), nullable=False) def __repr__(self): return '{}'.format(self.body)
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) body = db.Column(db.String(140)) timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) def __repr__(self): return 'Post {}'.format(self.body)
class OrderRemark(db.Model): id = db.Column(db.Integer, primary_key=True) body = db.Column(db.String()) order_id = db.Column(db.Integer, db.ForeignKey('order.id'), index=True, unique=True) def __repr__(self): return self.body
class CW_order(db.Model): __tablename__ = 'cw_orders' id = db.Column(db.Integer, primary_key=True) order_number = db.Column(db.String(16)) customer_manager = db.Column(db.String(32)) customer_city = db.Column(db.String(32)) timestamp = db.Column(db.DateTime, default=datetime.utcnow) sketch_is_ready = db.Column(db.Boolean) stickers_is_ready = db.Column(db.Boolean) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) cw_positions = db.relationship('CW_position', backref='cw_order')
class Order(db.Model): id = db.Column(db.Integer, primary_key=True) positions = db.relationship('Position', backref='order') order_number = db.Column(db.Integer, unique=True, index=True) timestamp = db.Column(db.DateTime, default=datetime.utcnow) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) customer_manager = db.Column(db.String(64)) customer_city = db.Column(db.String(64)) sketch_is_ready = db.Column(db.Boolean) ord_rem = db.relationship('OrderRemark', backref='remark', uselist=False) def __repr__(self): return 'Заказ № {}'.format(self.order_number)
if isinstance(obj, SearchableMixin): remove_from_index(obj.__tablename__, obj) session._changes = None @classmethod def reindex(cls): for obj in cls.query: add_to_index(cls.__tablename__, obj) db.event.listen(db.session, 'before_commit', SearchableMixin.before_commit) db.event.listen(db.session, 'after_commit', SearchableMixin.after_commit) followers = db.Table( 'followers', db.Column('follower_id', db.Integer, db.ForeignKey('user.id')), db.Column('followed_id', db.Integer, db.ForeignKey('user.id'))) class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(64), index=True, unique=True) email = db.Column(db.String(120), index=True, unique=True) password_hash = db.Column(db.String(128)) posts = db.relationship('Post', backref='author', lazy='dynamic') about_me = db.Column(db.String(140)) last_seen = db.Column(db.DateTime, default=datetime.utcnow) followed = db.relationship('User', secondary=followers, primaryjoin=(followers.c.follower_id == id), secondaryjoin=(followers.c.followed_id == id),
class Position(db.Model): id = db.Column(db.Integer, primary_key=True) serial_number = db.Column(db.Integer, index=True) order_id = db.Column(db.Integer, db.ForeignKey('order.id'), index=True) room = db.Column(db.String(32)) doormodel_id = db.Column(db.Integer, db.ForeignKey('door_models.id')) base_decor_id = db.Column(db.Integer, db.ForeignKey('decor.id')) second_decor_id = db.Column(db.Integer, db.ForeignKey('decor.id')) base_decor = db.relationship('Decor', foreign_keys=[base_decor_id]) second_decor = db.relationship('Decor', foreign_keys=[second_decor_id]) alum_butt_id = db.Column(db.Integer, db.ForeignKey('aluminum_butts.id')) frame_id = db.Column(db.Integer, db.ForeignKey('frame_type.id')) doors_height = db.Column(db.Integer) doors_width = db.Column(db.Integer) casing_id = db.Column(db.Integer, db.ForeignKey('casings.id')) expander_id = db.Column(db.Integer, db.ForeignKey('expanders.id')) lock_purpose_id = db.Column(db.Integer, db.ForeignKey('lock_purpose.id')) lock_kind_id = db.Column(db.Integer, db.ForeignKey('lock_type.id')) lock_color_id = db.Column(db.Integer, db.ForeignKey('lock_color.id')) hinge_side_id = db.Column(db.Integer, db.ForeignKey('hinge_sides.id')) hinge_kind_id = db.Column(db.Integer, db.ForeignKey('hinge_types.id')) hinge_color_id = db.Column(db.Integer, db.ForeignKey('hinge_colors.id')) doors_seal_id = db.Column(db.Integer, db.ForeignKey('door_seals.id'))