uselist=False) def get_url(self): return url_for("www.path", username=self.path_user.username, path_slug=self.slug) like_list_user_bridge = db.Table( "like_list_user_bridge", db.Column( "user_id", db.Integer, db.ForeignKey("users.id", ondelete="CASCADE"), primary_key=True, ), db.Column( "like_list_id", db.Integer, db.ForeignKey("like_lists.id", ondelete="CASCADE"), primary_key=True, ), ) class LikeList(PkModel): __tablename__ = "like_lists" path_id = db.Column(db.Integer, db.ForeignKey("paths.id"), nullable=False) users = db.relationship(
from flask_wtf import FlaskForm from wtforms import StringField, PasswordField, BooleanField, SubmitField, TextAreaField from flask_login import LoginManager, login_user, logout_user, login_required, UserMixin, current_user from wtforms.validators import DataRequired, ValidationError, Email, EqualTo, Length from werkzeug.security import generate_password_hash, check_password_hash from datetime import datetime from init import db 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): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) first_name = db.Column(db.String(24), index=True) last_name = db.Column(db.String(24), index=True) where_from = db.Column(db.String(50), index=True) email = db.Column(db.String(72), index=True) password_hash = db.Column(db.String(128)) posts = db.relationship('Post', backref='user', lazy='dynamic') profile_picture = db.relationship('Files', backref='user') phone = db.Column(db.Unicode(255)) dob = db.Column(db.DateTime) about_me = db.Column(db.String(200)) liked = db.relationship('PostLike', foreign_keys='PostLike.user_id', backref='user', lazy='dynamic')
import hashlib from datetime import timedelta from passlib.hash import bcrypt from flask_security import Security, SQLAlchemyUserDatastore, UserMixin, RoleMixin from flask_jwt_extended import create_access_token, create_refresh_token from init import db, app roles_users = db.Table( 'roles_users', db.Column('user_id', db.Integer(), db.ForeignKey('user.id')), db.Column('role_id', db.Integer(), db.ForeignKey('role.id')) ) class Role(RoleMixin, db.Model): """ роль пользователя """ id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(80), unique=True) description = db.Column(db.String(255)) def __str__(self): return self.name class User(UserMixin, db.Model): """ модель пользователя """ id = db.Column(db.Integer, primary_key=True)
from itsdangerous import URLSafeTimedSerializer from werkzeug.security import check_password_hash from werkzeug.security import generate_password_hash from flask import current_app from init import db from shopyo.api.models import PkModel role_user_bridge = db.Table( "role_user_bridge", db.Column( "user_id", db.Integer, db.ForeignKey("users.id", ondelete="CASCADE"), primary_key=True, ), db.Column( "role_id", db.Integer, db.ForeignKey("roles.id", ondelete="CASCADE"), primary_key=True, ), ) class AnonymousUser(AnonymousUserMixin): """ Anonymous user class """ def __init__(self): self.username = "******" self.email = "<anonymous-user-no-email>"
from werkzeug.security import generate_password_hash, check_password_hash from itsdangerous import TimedJSONWebSignatureSerializer as Serializer from datetime import datetime from flask import current_app, request, url_for from init import db, login_manager #用户角色多对多关系表 from pyfw.util import JsonUtil user_role_mapper = db.Table( 'common_user_roles', db.Column('user_id', db.Integer, db.ForeignKey('common_user_info.id'), nullable=False, primary_key=True), db.Column('role_id', db.Integer, db.ForeignKey('common_role_info.id'), nullable=False, primary_key=True)) #用户组织多对多关系表 user_org_mapper = db.Table( 'common_user_org', db.Column('user_id', db.Integer, db.ForeignKey('common_user_info.id'), nullable=False, primary_key=True), db.Column('org_id',
backref="reviewer_list_conf", lazy=True, uselist=False) def __repr__(self): return 'conf:{}'.format(self.year) conf_list_user_bridge = db.Table( "conf_list_user_bridge", db.Column( "user_id", db.Integer, db.ForeignKey("users.id", ondelete="CASCADE"), primary_key=True, ), db.Column( "reviewer_list_id", db.Integer, db.ForeignKey("reviewer_lists.id", ondelete="CASCADE"), primary_key=True, ), ) class ReviewerList(PkModel): __tablename__ = "reviewer_lists" conf_id = db.Column(db.Integer, db.ForeignKey("conferences.id"),