class Newsletter(db.Model): id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(120), unique=True, nullable=False) name = db.Column(db.String(20), unique=False, nullable=False) def __repr__(self): return f"Newsletter('{self.name}','{self.email}')"
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(120), unique=True) name = db.Column(db.String(100)) surname = db.Column(db.String(100)) email = db.Column(db.String(120), unique=True) password_hash = db.Column(db.String(80)) @property def password(self): raise AttributeError('password: write-only field') @password.setter def password(self, password): password_hash = generate_password_hash(password) def check_password(self, password): return check_password_hash(self.password_hash, password) @staticmethod def get_by_username(username): return User.query.filter_by(username=username).first() def __repr__(self): return '<User %r>' % self.username def __init__(self, username, email, password_hash): self.username = username self.email = email self.password_hash = generate_password_hash(password_hash)
class Sponsor(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(40), unique=True, nullable=False) picture = db.Column(db.String(120), default="default_sponsor.jpg") managers = db.relationship("User", backref="employer", lazy=True) sponsorships = db.relationship("Sponsorship", backref="sponsor", lazy=True) catalog = db.relationship("Catalog", uselist=False, back_populates="sponsor") def __repr__(self): return f"{self.name}" def active_drivers(self): return list(sponsorship.driver for sponsorship in self.sponsorships if sponsorship.active) def applied_drivers(self): return list(sponsorship.driver for sponsorship in self.sponsorships if not sponsorship.active) def all_drivers(self): return list(sponsorship.driver for sponsorship in self.sponsorships) @classmethod def sponsor_choices(cls): sponsors = Sponsor.query.all()
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) password = db.Column(db.String(60), nullable=False) def __repr__(self): return f"Username: {self.username}, Password: {self.password}"
class Photo(db.Model): __tablename__ = 'photos' usrname = db.Column(db.String(100)) photourl = db.Column(db.String(300), primary_key=True) def __repr__(self): return '<Image{}:{}>'.format(self.username, self.photourl)
class Torrent(db.Model, CURDMixIN): __tablename__ = "torrents" id = db.Column(db.Integer, primary_key=True) # 主键 title = db.Column(db.String(200)) # 种子标题 link = db.Column(db.String(200), unique=True) # 外站链接 enclosure = db.Column(db.String(100), unique=True) # 附件链接 pub_date = db.Column(db.DateTime) # 发布日期 description = db.Column(db.String(1000)) # 介绍 def __init__(self, title, link, enclosure='', pubdate=datetime.datetime.now(), description=''): self.title = title self.link = link self.enclosure = enclosure self.pub_date = pubdate self.description = description def __repr__(self): return (u''' Torrent id: %s Title: %s Link: %s''' % (self.id, self.title, self.link)).encode('utf-8')
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) category_id = db.Column(db.Integer, db.ForeignKey('category.id')) course_id = db.Column(db.Integer, db.ForeignKey('course.id')) tags = db.relationship('Tag', secondary=tags_posts, backref='posts', lazy='dynamic') title = db.Column(db.String(120), nullable=True) img_url = db.Column(db.String(120), nullable=True) content_mini = db.Column(db.String(180), nullable=True) content = db.Column(db.Text, nullable=True) date = db.Column(db.String(120), nullable=True) def toJSON(self): return { 'id': self.id, 'title': self.title, 'img_url': self.img_url, 'content': self.content, 'content_mini': self.content_mini, 'date': self.date, } def __str__(self): return str(self.id) + ' ' + str(self.title)
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(150), unique=True) password = db.Column(db.String(150)) name = db.Column(db.String(80)) # for relationship database name should be capital notes = db.relationship("Note")
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), nullable=False, unique=True) password = db.Column(db.String(40), nullable=False) def __repr__(self): return f"User('{self.id}', '{self.username}')"
class Authors(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) username = db.Column(db.String(80), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) profile = db.Column(db.String(180), default="profile.jpg") date = db.Column(db.DateTime, nullable=True)
class Contact(db.Model): sno = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) email = db.Column(db.String(50), nullable=False) website = db.Column(db.String(120), nullable=False) message = db.Column(db.String(6000), nullable=False) date = db.Column(db.DateTime, nullable=True)
class Category(db.Model): __tablename__ = 'category' cat_id = db.Column(db.INTEGER, primary_key=True) cat_name = db.Column(db.String(120)) cat_description = db.Column(db.String(120)) post = db.relationship('Post', backref='cat', lazy='dynamic') def __unicode__(self): return self.cat_name @staticmethod def list_category(): categories = Category.query.all() return [c.to_json() for c in categories] def to_json(self): return { 'cat_id': self.cat_id, 'cat_name': self.cat_name, 'cat_description': self.cat_description } @property def password(self): raise AttributeError('password: write-only field') @password.setter def password(self, password): self.password = generate_password_hash(password) def check_password(self, password): return check_password_hash(self.password_hash, password)
class User(db.Model, UserMixin): ''' user store ''' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True) email = db.Column(db.String(120), unique=True) password_hash = db.Column(db.String) #store the hash of password instead #of the plain text as password in plain text is dangerous @property def password(self): raise AttributeError('Password: write-only field') @password.setter def password(self, pswd): self.password_hash = generate_password_hash(pswd) def check_password(self, pswd): return check_password_hash(self.password_hash, pswd) @staticmethod def get_by_username(username): return User.query.filter_by(username=username).first() def __repr__(self): return '<User %r>' % self.username
class Download(db.Model): __bind_key__ = 'sb_db' id = db.Column(db.Integer, primary_key=True) date = db.Column(db.DateTime()) version = db.Column(db.String(64)) build = db.Column(db.String(64))
class User(db.Model, UserMixin): __tablename__ = 'user' user_id = db.Column(db.INTEGER, primary_key=True) user_name = db.Column(db.String(120), nullable=False) user_qq = db.Column(db.String(120)) user_mail = db.Column(db.String(120)) password = db.Column(db.String(120)) post = db.relationship('Post', backref='author', lazy='dynamic') roles = db.relationship('Role', secondary='user_roles') course_auth = db.relationship('Course', secondary=course_author, backref=db.backref('course')) sharedfile = db.relationship('SharedFile', backref='author_shared', lazy='dynamic') # Flask-Login integration def is_authenticated(self): return True def is_active(self): return True def is_anonymous(self): return False def get_id(self): return self.user_id def __unicode__(self): return self.user_name
class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(32), unique=True) password_hash = db.Column(db.String(192)) role = db.Column(db.String(32)) fullname = db.Column(db.String(32)) exam_id = db.Column(db.String(32)) answer_page = db.Column(JSON) def hash_password(self, password): self.password_hash = pbkdf2_sha512.encrypt(password) def check_password(self, password): return pbkdf2_sha512.verify(password, self.password_hash) def is_authenticated(self): return True def is_active(self): return True def is_anonymous(self): return False def get_id(self): return str(self.id) def __repr__(self): return '<User {}>'.format(self.username)
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) posts = db.relationship('Post', backref='author', lazy=True) liked_comments = db.relationship('CommentLike', backref='user', lazy=True) liked_posts = db.relationship('PostLike', backref='user', lazy=True) def get_reset_token(self, expires_sec=1800): s = Serializer(current_app.config['SECRET_KEY'], expires_sec) return s.dumps({'user_id': self.id}).decode('utf-8') @staticmethod def verify_reset_token(token): s = Serializer(current_app.config['SECRET_KEY']) try: user_id = s.loads(token)['user_id'] except: return None return User.query.get(user_id) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class User(db.Model, UserMixin): __tablename__ = "users" id = db.Column(db.Integer, primary_key=True) # pick random image # random_robot_file=pick_random_image() profile_image = db.Column(db.String(64), nullable=False) # default=random_robot_file) email = db.Column(db.String(64), unique=True, index=True) username = db.Column(db.String(64), unique=True, index=True) password_hash = db.Column(db.String(128)) post = db.relationship("BlogPost", backref="author", lazy=True) def __init__(self, email, username, password, image): self.email = email self.username = username self.password_hash = generate_password_hash(password) self.profile_image = image def check_password(self, password): return check_password_hash(self.password_hash, password) def __repr__(self): return f"Username {self.username}"
class NewsCourse(db.Model): __tablename__ = 'newscourse' news_id = db.Column(db.INTEGER, primary_key=True) news_title = db.Column(db.String(120)) news_description = db.Column(db.String(120)) course = db.Column(db.INTEGER, db.ForeignKey('course.course_id'))
class Syllabes(db.Model): __tablename__ = 'syllabes' syllabes_id = db.Column(db.INTEGER, primary_key=True) syllabes_title = db.Column(db.String(120)) syllabes_description = db.Column(db.String(120)) course = db.Column(db.INTEGER, db.ForeignKey('course.course_id'))
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) function_name = db.Column(db.String(1000), nullable=False) filepath = db.Column(db.String(1000), nullable=False) function_docstring = db.Column(db.String(1000), nullable=True) def __repr__(self): return f"Function({self.function_name}) \n Filepath:({self.filepath}))"
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, nullable=False) title = db.Column(db.String(255), nullable=False) image_url = db.Column(db.String(255), nullable=False) content = db.Column(db.Text, nullable=False) create_at = Column(DateTime(timezone=True), server_default=func.now()) update_at = Column(DateTime(timezone=True), onupdate=func.now())
class User(db.Model): __tablename__ = 'testtable' email = db.Column(db.String(100), unique=True) username = db.Column(db.String(100), primary_key=True, unique=True) password = db.Column(db.String(300)) def __repr__(self): # how to print User return '<User:{}>'.format(self.username)
class user_list(db.Model, UserMixin): username = db.Column(db.String(20), unique=True, nullable=False, primary_key=True) password = db.Column(db.String(80), nullable=False) def __repr__(self): return f"User('{self.username}')" def get_id(self): return (self.username)
class client(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50), nullable=False) tele = db.Column(db.String(20), nullable=False) email = db.Column(db.String(50), nullable=False) descrip = db.Column(db.String(200), nullable=False) def __repr__(self): return "Client #{self.id}: {self.name} | {self.tele} | {self.email} - {self.desc}"
class ModalData(db.Model): __tablename__ = 'modal_data' id = db.Column(db.Integer, primary_key=True) participantId = db.Column(db.Integer, db.ForeignKey('demographic_data.id'), nullable=False) currentWebsite = db.Column(db.String(50), nullable=False) consent = db.Column(db.String(3), nullable=False) def __repr__(self): return f"modalData('{self.participantId}', '{self.id}', '{self.currentWebsite}', '{self.consent}')"
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) # username = email username = db.Column(db.String(20), unique=True, nullable=False) password = db.Column(db.String(60), nullable=False) datasets = db.relationship('Dataset', backref='author', lazy=True) def __repr__(self): return f"Username: {self.username}"
class Download(db.Model): __bind_key__ = 'sb_db' id = db.Column(db.Integer, primary_key=True) date = db.Column(db.DateTime()) version = db.Column(db.String(64)) build = db.Column(db.String(64)) location_info = db.Column(db.String(256)) user_agent = db.Column(db.String(256))
class Review(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) movie_id = db.Column(db.String(20), nullable=False) title = db.Column(db.String(50), nullable=False) data = db.Column(db.Text, nullable=False) date = db.Column(db.DateTime(timezone=True), default=datetime.now()) rating = db.Column(db.String(70), nullable=False) spoiler_tag = db.Column(db.Boolean)
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) user_name = db.Column(db.String(20), nullable=False) email = db.Column(db.String(20), unique=True, nullable=False) password = db.Column(db.String(120), nullable=False) role = db.Column(db.String(20), default='user') def __repr__(self): return f"User('{self.user_name}', '{self.email}', '{self.role}')"