class GbFileDir(db.Model): __tablename__ = 'gb_file_dir' dir_id = db.Column(db.String(96), primary_key=True) dir_name = db.Column(db.String(256)) parent_id = db.Column(db.String(96)) is_starred = db.Column(db.Integer) is_deleted = db.Column(db.Integer) user_id = db.Column(db.String(96)) create_by = db.Column(db.String(96)) create_date = db.Column(db.DateTime) update_by = db.Column(db.String(96)) update_date = db.Column(db.DateTime) def __init__(self, dir_id, dir_name, parent_id, is_starred, is_deleted, user_id, create_by, create_date, update_by, update_date): self.dir_id = dir_id self.dir_name = dir_name self.parent_id = parent_id self.is_starred = is_starred self.is_deleted = is_deleted self.user_id = user_id self.create_by = create_by self.create_date = create_date self.update_by = update_by self.update_date = update_date def __repr__(self): return '<GbFileDir %r>' % self.dir_name
class Room(db.Model): id = db.Column(db.Integer, primary_key=True) roomname = db.Column(db.String(32)) owner = db.Column(db.Integer, db.ForeignKey('user.id')) def __repr__(self): return '<Room {}>'.format(self.roomname)
class GbFileRaster(db.Model): __tablename__ = 'gb_file_raster' file_id = db.Column(db.String(96), primary_key=True) file_type_id = db.Column(db.String(96)) img_resolution = db.Column(db.DECIMAL(16, 0)) notes = db.Column(db.String(255)) raster_extent = db.Column(db.String(2560)) create_by = db.Column(db.String(96)) create_date = db.Column(db.DateTime) update_by = db.Column(db.String(96)) update_date = db.Column(db.DateTime) def __init__(self, file_id, file_type_id, img_resolution, notes, raster_extent, create_by, create_date, update_by, update_date): self.file_id = file_id self.file_type_id = file_type_id self.img_resolution = img_resolution self.notes = notes self.raster_extent = raster_extent self.create_by = create_by self.create_date = create_date self.update_by = update_by self.update_date = update_date def __repr__(self): return '<GbFileRaster %r>' % self.file_type_id
class Note(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(20), nullable=False) date_posted = db.Column(db.DateTime, nullable=True, default=datetime.utcnow) content = db.Column(db.Text, nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"Note('{self.title}', '{self.date_posted}')"
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20), unique=False, nullable=False, default='anonymous') username = db.Column(db.String(20), unique=True, nullable=False) password = db.Column(db.String(20), unique=False, nullable=False) notes = db.relationship('Note', backref='author', lazy=True) def __repr__(self): return f"User('{self.name}', '{self.username}')"
class GbSuffixBundle(db.Model): __tablename__ = 'gb_suffix_bundle' bundle_id = db.Column(db.String(32), primary_key=True) type_id = db.Column(db.String(32)) file_suffix = db.Column(db.String(256)) suffix_details = db.Column(db.String(256)) def __init__(self, bundle_id, type_id, file_suffix, suffix_details): self.bundle_id = bundle_id self.type_id = type_id self.file_suffix = file_suffix self.suffix_details = suffix_details def __repr__(self): return '<GbSuffixBundle %r>' % self.file_suffix
class GbFileDownload(db.Model): __tablename__ = 'gb_file_download' download_id = db.Column(db.String(96), primary_key=True) file_id = db.Column(db.String(96)) download_by = db.Column(db.String(96)) download_date = db.Column(db.DateTime) def __init__(self, download_id, file_id, download_by, download_date): self.download_id = download_id self.file_id = file_id self.download_by = download_by self.download_date = download_date def __repr__(self): return '<GbFileDownload %r>' % self.file_id
class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(32), index=True, unique=True) password_hash = db.Column(db.String(128)) rooms = db.relationship('Room', secondary=users_rooms, backref=db.backref('users')) invites = db.relationship('Room', secondary=users_invites) def set_password(self, pswd): self.password_hash = generate_password_hash(pswd) def check_password(self, pswd): return check_password_hash(self.password_hash, pswd) def __repr__(self): return '<User {}>'.format(self.username)
class GbFileTag(db.Model): __tablename__ = 'gb_file_raster' tag_id = db.Column(db.String(96), primary_key=True) tag_name = db.Column(db.String(96)) create_date = db.Column(db.DateTime) create_by = db.Column(db.String(96)) tag_group = db.Column(db.Integer) def __init__(self, tag_id, tag_name, parent_id, is_starred, user_id): self.tag_id = tag_id self.tag_name = tag_name self.create_date = create_date self.create_by = create_by self.tag_group = tag_group def __repr__(self): return '<GbFileRaster %r>' % self.tag_name
class GbFileVector(db.Model): __tablename__ = 'gb_file_vector' file_id = db.Column(db.String(96), primary_key=True) file_type_id = db.Column(db.String(96)) vector_extent = db.Column(db.String(2560)) create_by = db.Column(db.String(96)) create_date = db.Column(db.DateTime) update_by = db.Column(db.String(96)) update_date = db.Column(db.DateTime) def __init__(self, file_id, file_type_id, vector_extent,create_by,create_date,update_by,update_date): self.file_id = file_id self.file_type_id = file_type_id self.vector_extent = vector_extent self.create_by=create_by self.create_date=create_date self.update_by=update_by self.update_date=update_date def __repr__(self): return '<GbFileVector %r>' % self.file_type_id
class GbFileSharing(db.Model): __tablename__ = 'gb_file_sharing' sharing_id = db.Column(db.String(96), primary_key=True) file_id = db.Column(db.String(96)) sharing_from = db.Column(db.String(96)) sharing_to = db.Column(db.String(96)) sharing_date = db.Column(db.DateTime) sharing_notes = db.Column(db.String(255)) is_deleted = db.Column(db.Integer) def __init__(self, sharing_id, file_id, parent_id, is_starred, user_id): self.sharing_id = sharing_id self.file_id = file_id self.sharing_from = sharing_from self.sharing_to = sharing_to self.sharing_date = sharing_date self.sharing_notes = sharing_notes self.is_deleted = is_deleted def __repr__(self): return '<GbFileSharing %r>' % self.sharing_id
class GbFileTypeGroup(db.Model): __tablename__ = 'gb_file_type_group' group_id = db.Column(db.String(96), primary_key=True) group_name = db.Column(db.String(96)) group_name_cn = db.Column(db.String(96)) is_made_in_china = db.Column(db.Integer) is_free = db.Column(db.Integer) notes = db.Column(db.String(96)) group_icon = db.Column(db.String(96)) def __init__(self, group_id, group_name, group_name_cn, is_starred, user_id): self.group_id = group_id self.group_name = group_name self.group_name_cn = group_name_cn self.is_made_in_china = is_made_in_china self.is_free = is_free self.notes = notes self.group_icon = group_icon def __repr__(self): return '<GbFileSharing %r>' % self.group_name
class GbFileType(db.Model): __tablename__ = 'gb_file_type' type_id = db.Column(db.String(96), primary_key=True) type_name = db.Column(db.String(96)) type_icon_location = db.Column(db.String(256)) type_name_cn = db.Column(db.String(96)) notes = db.Column(db.String(256)) type_group_id = db.Column(db.String(96)) def __init__(self, type_id, file_id, parent_id, is_starred, user_id): self.type_id = type_id self.type_name = type_name self.type_icon_location = type_icon_location self.type_name_cn = type_name_cn self.notes = notes self.sharing_notes = sharing_notes self.type_group_id = type_group_id def __repr__(self): return '<GbFileType %r>' % self.type_name
class GbFile(db.Model): __tablename__ = 'gb_file' file_id = db.Column(db.String(96), primary_key=True, unique=True, nullable=False) file_display_name = db.Column(db.String(128)) file_real_name = db.Column(db.String(256)) dir_id = db.Column(db.String(96)) file_real_location = db.Column(db.String(2560)) file_type_id = db.Column(db.String(32)) file_size = db.Column(db.Integer) file_suffix = db.Column(db.String(16)) file_tag = db.Column(db.String(128)) is_public = db.Column(db.Integer) create_date = db.Column(db.DateTime) create_by = db.Column(db.String(96)) update_date = db.Column(db.DateTime) update_by = db.Column(db.String(96)) file_hashcode = db.Column(db.String(256)) notes = db.Column(db.String(512)) user_id = db.Column(db.String(96)) is_deleted = db.Column(db.Integer) upload_by = db.Column(db.String(96)) upload_date = db.Column(db.DateTime) is_starred = db.Column(db.Integer) def __init__(self, file_id, file_display_name, file_real_name, dir_id, file_real_location, file_type_id, file_size, file_suffix, file_tag, is_public, create_date, create_by, update_date, update_by, file_hashcode, notes, user_id, is_deleted, upload_by, upload_date, is_starred): self.file_id = file_id self.file_display_name = file_display_name self.file_real_name = file_real_name self.dir_id = dir_id self.file_real_location = file_real_location self.file_type_id = file_type_id self.file_size = file_size self.file_suffix = file_suffix self.file_tag = file_tag self.is_public = is_public self.create_date = create_date self.create_by = create_by self.update_date = update_date self.update_by = update_by self.file_hashcode = file_hashcode self.notes = notes self.user_id = user_id self.is_deleted = is_deleted self.upload_by = upload_by self.upload_date = upload_date self.is_starred = is_starred def __repr__(self): return '<GbFile %r>' % self.file_display_name
from box import db, loginman from sqlalchemy import Table from flask_login import UserMixin from werkzeug.security import generate_password_hash, check_password_hash users_rooms = db.Table( 'users_rooms', db.Column('user_id', db.Integer, db.ForeignKey('user.id')), db.Column('room_id', db.Integer, db.ForeignKey('room.id'))) users_invites = db.Table( 'users_invites', db.Column('user_id', db.Integer, db.ForeignKey('user.id')), db.Column('room_id', db.Integer, db.ForeignKey('room.id'))) class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(32), index=True, unique=True) password_hash = db.Column(db.String(128)) rooms = db.relationship('Room', secondary=users_rooms, backref=db.backref('users')) invites = db.relationship('Room', secondary=users_invites) def set_password(self, pswd): self.password_hash = generate_password_hash(pswd) def check_password(self, pswd): return check_password_hash(self.password_hash, pswd) def __repr__(self):
class GbUser(db.Model): __tablename__ = 'gb_user' user_id = db.Column(db.String(96), primary_key=True) user_name = db.Column(db.String(48)) user_nickname = db.Column(db.String(96)) user_password = db.Column(db.String(512)) user_type = db.Column(db.Integer) user_tel = db.Column(db.String(24)) user_email = db.Column(db.String(48)) notes = db.Column(db.String(512)) create_date = db.Column(db.DateTime) create_by = db.Column(db.String(96)) update_date = db.Column(db.DateTime) update_by = db.Column(db.String(96)) is_deleted = db.Column(db.Integer) user_avatar = db.Column(db.String(512)) def __init__(self, user_id, user_name, user_nickname, user_password, user_type, user_tel, user_email, notes, create_date, create_by, update_date, update_by, is_deleted, user_avatar): self.user_id = user_id self.user_name = user_name self.user_nickname = user_nickname self.user_password = user_password user_type = user_type user_tel = user_tel user_email = user_email notes = notes create_date = create_date create_by = create_by update_date = update_date update_by = update_by is_deleted = is_deleted user_avatar = user_avatar def __repr__(self): return '<GbUser %r>' % self.user_nickname