class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20), nullable=False) password = db.Column(db.String(20)) email = db.Column(db.String(30))
class Post(db.Model): __tablename__ = 'posts' id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(200)) short_body = db.Column(db.Text) body = db.Column(db.Text) time = db.Column(db.DateTime) u_id = db.Column(db.Integer, db.ForeignKey('users.id')) user = db.relationship('User', backref=db.backref('posts')) blog_image = db.Column(db.String(300)) t_id = db.Column(db.Integer, db.ForeignKey('tags.id')) tag = db.relationship('Tag', backref=db.backref('posts')) def __init__(self, title=None, short_body=None, body=None, time=None, user=None, blog_image=None, **kwargs): super(Post, self).__init__(**kwargs) self.title = title self.short_body = short_body self.body = body self.time = time self.user = user self.blog_image = blog_image def __repr__(self): return '<Post %r>' % (self.title)
class Payment(db.Model): __tablename__ = 'payments' id = db.Column(db.Integer, primary_key=True) firstname = db.Column(db.String(255)) lastname = db.Column(db.String(255)) mode = db.Column(db.String(255)) reserve_id = db.Column(db.Integer) def __init__(self, firstname, lastname, mode, reserve_id): self.firstname = firstname self.lastname = lastname self.mode = mode self.reserve_id = reserve_id def store(self): db.session.add(self) return db.session.commit() def update(self, firstname, lastname, mode, reserve_id): self.firstname = firstname self.lastname = lastname self.mode = mode self.reserve_id = reserve_id return db.session.commit() def delete(self): db.session.delete(self) return db.session.commit()
class BaseNoticeModel(db.Model): __abstract__ = True id: int = db.Column(db.Integer(), primary_key=True) post_date: datetime = db.Column(db.DateTime(), default=kst_now) title: str = db.Column(db.String()) content: str = db.Column(db.String())
class ArticleType(db.Model): __tablename__ = 'article_type' id = db.Column(db.Integer, autoincrement=True, primary_key=True) types = db.Column(db.String(32)) create_user = db.Column(db.String(32)) create_time = db.Column(db.DateTime, default=datetime.datetime.utcnow)
class Rooms(db.Model): __tablename__ = 'rooms' id = db.Column(db.Integer, primary_key=True) room_type = db.Column(db.String(255)) status = db.Column(db.String(255)) price = db.Column(db.Integer) def __init__(self, room_type, status, price): self.room_type = room_type self.status = status self.price = price def store(self): db.session.add(self) return db.session.commit() def update(self, room_type, status, price): self.room_type = room_type self.status = status self.price = price return db.session.commit() def delete(self): db.session.delete(self) return db.session.commit()
class User(db.Model): __tablename__ = 'user' username = db.Column(db.String(50), primary_key=True) firstname = db.Column(db.String(100), nullable=False) lastname = db.Column(db.String(100), nullable=False) email = db.Column(db.String(30), nullable=False) password = db.Column(db.String(100), nullable=False)
class FacilityReportModel(db.Model): __tablename__ = 'facility_report' id: int = db.Column(db.Integer(), primary_key=True) student_id: str = db.Column( db.String(), db.ForeignKey('student.username', ondelete='CASCADE')) room_number: int = db.Column(db.Integer()) content: str = db.Column(db.String())
class item(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(120), unique=True) price = db.Column(db.String(120)) #imgsrc = db.Column(db.Text) def __init__(self, title, price): self.title = title self.price = price
class Destination(db.Model, Utf8Set): """ Cities """ __tablename__ = 'destination' id = db.Column(db.Integer, primary_key=True, autoincrement=True) title = db.Column(db.String(64), nullable=False) remark = db.Column(db.String(255))
class User(db.Model): __tablename__ = "user" id = db.Column(db.Integer, primary_key=True) role = db.Column(db.String(20), default="user") name = db.Column(db.String(30), nullable=False) password = db.Column(db.String(20)) email = db.Column(db.String(30)) phone = db.Column(db.String(20))
class StudentModel(BaseStudent): __tablename__ = 'student' username: str = db.Column(db.String(), primary_key=True) password: str = db.Column(db.String()) @classmethod async def query_by_username(cls, username: str): return await cls.query.where(cls.username == username).gino.first()
class Schedule(db.Model): __tablename__ = 'schedules' id = db.Column(db.Integer, primary_key=True) departured_at = db.Column(db.DateTime) arrived_at = db.Column(db.DateTime) driver_id = db.Column(db.Integer, db.ForeignKey('users.id')) bus_id = db.Column(db.Integer, db.ForeignKey('busses.id')) conductor_id = db.Column(db.Integer) origin = db.Column(db.String(20)) destination = db.Column(db.String(255)) status = db.Column(db.String(20)) amount = db.Column(db.Float) duration = db.Column(db.String(20)) reservations = db.relationship('Reservation', backref="schedule", lazy=True) def __init__(self, departured_at, arrived_at, driver_id, bus_id, conductor_id, origin, destination, status, amount, duration): self.departured_at = departured_at self.arrived_at = arrived_at self.driver_id = driver_id self.bus_id = bus_id self.conductor_id = conductor_id self.origin = origin self.destination = destination self.status = status self.amount = amount self.duration = duration def store(self): db.session.add(self) return db.session.commit() def update(self, departured_at, arrived_at, driver_id, bus_id, conductor_id, origin, destination, status, amount, duration): self.departured_at = departured_at self.arrived_at = arrived_at self.driver_id = driver_id self.bus_id = bus_id self.conductor_id = conductor_id self.origin = origin self.destination = destination self.status = status self.amount = amount self.duration = duration return db.session.commit() def delete(self): db.session.delete(self) return db.session.commit() def update1(self, status): self.status = status return db.session.commit()
class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True, autoincrement=True) telephone = db.Column(db.String(11), nullable=False) username = db.Column(db.String(50), nullable=False) password = db.Column(db.String(100), nullable=False) image_path = db.Column( db.String(256), nullable=False, server_default='img/7dc3c78d-edf1-4827-b6d4-9043638f8024.jpg')
class Diary(db.Model): __tablename__ = 'diarys' id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(200)) short_body = db.Column(db.String(300)) body = db.Column(db.Text) time = db.Column(db.DateTime) diary_image = db.Column(db.String(300)) u_id = db.Column(db.Integer, db.ForeignKey('users.id')) user = db.relationship('User', backref=db.backref('diarys'))
class UserGroup(db.Model): """用户组""" __tablename__ = 'user_group' id = db.Column(db.Integer, primary_key=True, autoincrement=True) tag = db.Column(db.String(56)) user = db.Column(db.String(150), index=True) status = db.Column(db.Integer, default=1) content = db.Column(db.String(256)) create_time = db.Column(db.DateTime, default=datetime.datetime.utcnow)
class BaseStudent(db.Model): __abstract__ = True name: str = db.Column(db.String()) number: int = db.Column(db.Integer(), unique=True) email: str = db.Column(db.String(), unique=True) @classmethod async def query_by_number(cls, number: int): return await cls.query.where(cls.number == number).gino.first()
class User(db.Model): """用户表""" __tablename__ = "user" id = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(150), index=True) email = db.Column(db.String(50)) # 邮箱 password = db.Column(db.String(128)) # 密码 active = db.Column(db.Boolean(), default=True) nickname = db.Column(db.String(100)) # 昵称
class Product(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50), unique=True, nullable=False) description = db.Column(db.String(200), unique=False, nullable=True) image = db.Column(db.String(1000)) stock = db.Column(db.Integer, default=0) promo = db.Column(db.String(300), nullable=True) prix = db.Column(db.Integer, default=0) def __repr__(self): return 'Product #: %i name: %r Description: %s image_url: %s stock: %i Promo %s\n' % (self.id, self.name, self.description, self.image, self.stock, self.promo)
class Article(db.Model): __talbename__ = 'article' id = db.Column(db.Integer, autoincrement=True, primary_key=True) title = db.Column(db.String(32)) name = db.Column(db.String(32)) content = db.Column(db.TEXT) create_user = db.Column(db.String(32)) create_time = db.Column(db.DateTime, default=datetime.datetime.utcnow) update_time = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now)
class User(db.Model): id = db.Column(db.Integer, primary_key=True) first_name = db.Column(db.String(100)) last_name = db.Column(db.String(100)) email = db.Column(db.String(120), unique=True) # pets = db.relationship('Pet', backref='owner') def __str__(self): return "{}, {}".format(self.last_name, self.first_name) def __repr__(self): return "{}: {}".format(self.id, self.__str__())
class GoingoutApplyModel(BaseApplyModel): __tablename__ = 'apply_goingout' go_out_date: datetime = db.Column(db.DateTime()) come_back_date: datetime = db.Column(db.DateTime()) reason: str = db.Column(db.String()) status: str = db.Column(db.Enum(GOINGOUT_STATUS))
class Tag(db.Model, Utf8Set): """ 'My life' 'Beautiful Chengdu' 'Small City Tongliang' 'Hometown Zhuji' """ __tablename__ = 'tag' id = db.Column(db.Integer, primary_key=True, autoincrement=True) title = db.Column(db.String(64), nullable=False) tagType = db.Column(db.String(64), default='destination') remark = db.Column(db.String(255), default=u'No introduction for tag') albums = db.relationship('Album', backref='tag', lazy='dynamic') articles = db.relationship('Article', backref='tag', lazy='dynamic')
class User(db.Model): """Basic user model """ id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True, nullable=False) email = db.Column(db.String(80), unique=True, nullable=False) password = db.Column(db.String(255), nullable=False) active = db.Column(db.Boolean, default=True) def __init__(self, **kwargs): super(User, self).__init__(**kwargs) self.password = pwd_context.hash(self.password) def __repr__(self): return "<User %s>" % self.username
class Tag(db.Model): __tablename__ = 'tags' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(200), unique=True) def __repr__(self): return '<tags %r>' % (self.name)
class PointItemModel(db.Model): __tablename__ = 'point_item' id: int = db.Column(db.Integer(), primary_key=True) reason: str = db.Column(db.String()) point: int = db.Column(db.Integer()) type: bool = db.Column(db.Boolean())
class UnsignedStudentModel(BaseStudent): __tablename__ = 'unsigned_student' uuid: str = db.Column(db.String(), default=generate_uuid, unique=True) @classmethod async def query_by_uuid(cls, uuid: str): return await cls.query.where(cls.uuid == uuid).gino.first()
class ActivityVoting(db.Model): __tablename__ = "activity_voting" id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(30), nullable=False) is_validated = db.Column(db.Boolean, default=True) created_at = db.Column(db.DateTime, default=datetime.utcnow) updated_at = db.Column(db.DateTime, default=datetime.utcnow)
class Comment(db.Model): __tablename__ = "comment" id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer) activity_id = db.Column(db.Integer) content = db.Column(db.String(20), nullable=False) created_at = db.Column(db.DateTime, default=datetime.utcnow)
class PointHistoryModel(db.Model): __tablename__ = 'point_history' id: int = db.Column(db.Integer(), primary_key=True) student_id: str = db.Column( db.String(), db.ForeignKey('student.username', ondelete='CASCADE')) point_id: int = db.Column( db.Integer(), db.ForeignKey('point_item.id', ondelete='CASCADE')) point_date: datetime = db.Column(db.DateTime())