コード例 #1
0
class Comment(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), unique=False)
    email = db.Column(db.String(120), unique=False, nullable=False)
    message = db.Column(db.Text, nullable=False)
    post_id = db.Column(db.Integer, db.ForeignKey('post.id'), nullable=False)
    post = db.relationship('Post', backref=db.backref('post', lazy=True))
    pub_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    status = db.Column(db.Boolean, default=False)

    def __repr__(self):
        return '<User %r>' % self.username
コード例 #2
0
ファイル: models.py プロジェクト: 008009/moment
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)

    def __repr__(self):
        return f"User('{self.username}','{self.email}','{self.image_file}')"
コード例 #3
0
ファイル: models.py プロジェクト: aletiffi/Simple-Blog
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    created_at = db.Column(db.DateTime, default=datetime.now)
    title = db.Column(db.String(120), nullable=False)
    slug = db.Column(db.String(250))
    description = db.Column(db.String(240))
    body = db.Column(db.Text(), nullable=False)
    image = db.Column(db.String(120))

    def __repr__(self):
        return f"Post('{ self.id }', '{ self.title }')"
コード例 #4
0
class Comment(db.Model):
    __tablename__ = 'comment'
    id = db.Column('id', db.Integer, primary_key=True)
    author_id = db.Column('author_id', db.Integer, db.ForeignKey(User.id))
    created = db.Column('created', db.DateTime, default=datetime.utcnow)
    body = db.Column('body', db.String(500))
    section = db.Column('section', db.String(20))
    article = db.Column('article', db.String(40))
    approval = db.Column('approval', db.String(20))

    def __repr__(self):
        return '<Comment {}>'.format(self.body)
コード例 #5
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    neckname = db.Column(db.String(50),
                         index=True,
                         unique=True,
                         nullable=False)
    email = db.Column(db.String(100), index=True, unique=True)
    role = db.Column(db.SmallInteger, default=ROLE_ADMIN)
    posts = db.relationship('Post', backref='user', lazy='dynamic')

    def __repr__(self):
        return '<User %s>' % self.neckname
コード例 #6
0
class Account(db.Model):
    __tablename__ = 'accounts'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    hashed_password = db.Column(db.String(1000), nullable=False)

    def __init__(self, name=None, hashed_password=None):
        self.name = name
        self.hashed_password = hashed_password

    def __repr__(self):
        return '<Account id:{} name:{} hashed_password:{}>'.format(
            self.id, self.name, self.hashed_password)
コード例 #7
0
class Ip_blacklist(db.Model):
    ip = db.Column(db.String(15), primary_key=True, index=True)
    address = db.Column(db.String(50))
    visit_count = db.Column(db.Integer, default=1)
    attack_count = db.Column(db.Integer, default=1)
    is_forbid = db.Column(db.Integer, default=0)  # 是否禁止访问
    forbid_date = db.Column(db.Integer)  # 禁止日期
    reason = db.Column(db.String(50))  # 原因

    @classmethod
    def find_by_ip(cls, ip):
        ip = Ip_blacklist.query.filter_by(ip=ip).first()
        return ip
コード例 #8
0
class Comment(db.Model):
    __tablename__ = "comments_table"
    id = db.Column(db.Integer, primary_key=True)
    article_id = db.Column(db.Integer)
    name = db.Column(db.String(15))
    text = db.Column(db.Text)
    created_at = db.Column(db.String(15))

    def __init__(self, name="名無しさん", text=None, article_id=None):
        self.name = name
        self.text = text
        self.created_at = "{0:%Y/%m/%d/ %H:%M:%S}".format(datetime.now())
        self.article_id = article_id
コード例 #9
0
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)
    password = db.Column(db.String(100), nullable=False)
    image_file = db.Column(db.String(20),
                           nullable=False,
                           default='default.jpg')
    rel = db.relationship('Post', backref='author', lazy=True)

    def __repr__(self):  #how objects are print
        return ("User('{}','{}','{}')".format(self.username, self.email,
                                              self.image_file))
コード例 #10
0
ファイル: models.py プロジェクト: anandteertha/DeepBlue
class CameraDb(db.Model, UserMixin):
    ip = db.Column(db.String(15), nullable=False)
    port = db.Column(db.String(5), nullable=False)
    region = db.Column(db.String(20), primary_key=True, nullable=False)
    count = db.Column(db.Integer, nullable=False, default=0)
    x1 = db.Column(db.Float, nullable=False, default=0)
    y1 = db.Column(db.Float, nullable=False, default=0)
    x2 = db.Column(db.Float, nullable=False, default=0)
    y2 = db.Column(db.Float, nullable=False, default=0)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.now)

    def __repr__(self):
        return f"Camera('{self.ip}','{self.region}','{self.count}','{self.date_posted}','{self.x1}','{self.y1}','{self.x2}','{self.y2}')"
コード例 #11
0
ファイル: model.py プロジェクト: Nivaya/blog
class Comment(db.Model):
    __tablename__ = 'comment'
    __bind_key__ = 'blog2'
    id = db.Column(db.Integer, primary_key=True)
    body = db.Column(db.String(500))
    email = db.Column(db.String(100))
    create_user = db.Column(db.String(50))
    create_date = db.Column(db.DateTime, default=datetime.now)
    article_id = db.Column(db.Integer, db.ForeignKey('article.id'))

    comment_article = db.relationship('Article', backref='comment_article')

    def __repr__(self):
        return '<Comment %r>' % self.id
コード例 #12
0
ファイル: models.py プロジェクト: astik-dahal/nepsocial
class Post(db.Model):
    __searchable__ = ['title', 'content']
    id = db.Column(db.Integer, primary_key=True)
    date_posted = db.Column(db.DateTime, default=datetime.utcnow)
    title = db.Column(db.String(90), nullable=True, default='')
    content = db.Column(db.String(3000), nullable=False)
    # contentPrv = db.Column(db.String(150), nullable=False)
    image_file = db.Column(db.String(60))
    category = db.Column(db.String(20), default='Public')
    user_id = db.Column(db.Integer(), db.ForeignKey('user.id'), nullable=False)
    likes = db.relationship('PostLike', backref='post', lazy='dynamic')

    def __repr__(self):
        return f"Post('{self.date_posted}', '{self.title}')"
コード例 #13
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(80), unique=True, nullable=False)
    feature = db.Column(db.Boolean, default=False)
    description = db.Column(db.String(150), nullable=False)
    body = db.Column(db.Text, unique=False, nullable=False)
    pub_date = db.Column(db.DateTime, nullable=False, default=datetime.now())
    owner = db.Column(db.Integer(), db.ForeignKey('user.id'))
    tags = db.relationship('Tag',
                           secondary=tags,
                           backref=db.backref('posts', lazy='dynamic'))

    def __repr__(self):
        return '<Post %r>' % self.title
コード例 #14
0
class User(db.Model, UserMixin):
    __tablename__ = "users"

    id = db.Column(db.Integer, primary_key=True)
    profile_image = db.Column(db.String(1), nullable=False)
    email = db.Column(db.String(64), unique=True, index=True)
    username = db.Column(db.String(64), index=True)
    password_hash = db.Column(db.String(64))
    confirmed = db.Column(db.Boolean, nullable=False)
    last_viewed_catagory1 = db.Column(db.String(64), index=True)
    last_viewed_catagory2 = db.Column(db.String(64), index=True)
    last_viewed_catagory3 = db.Column(db.String(64), index=True)
    background = db.Column(db.String(1), index=True, nullable=False)

    posts = db.relationship('BlogPost', backref='author', lazy=True)

    def __init__(self, email, username, password):
        self.username = username
        self.email = email
        self.password_hash = generate_password_hash(password)
        self.confirmed = False
        self.profile_image = "profile_img_" + str(randint(1, 9)) + ".png"
        self.background = "1"

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)

    def __repr__(self):
        return f"User-name: {self.username}\nEmail: {self.email}"

    @staticmethod
    def gen_pass(password):
        return generate_password_hash(password)
コード例 #15
0
ファイル: models.py プロジェクト: Joan-w/Blogpost
class Comment(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(20), unique=False, nullable=False)
    email = db.Column(db.String(120), unique=False, nullable=False)
    message = db.Column(db.Text, nullable=False)
    post_id = db.Column(db.Integer, db.ForeignKey('post.id'), nullable=False)
    post = db.relationship('Post', backref=db.backref('post', lazy=True))
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    status = db.Column(db.Boolean, default=False)

    def __repr__(self):
        return f"User('{self.name}', '{self.message}')"
コード例 #16
0
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)
    # Backref allows us to access the user by calling post.author
    # Lazy=True means that it won't be queried until needed.
    posts = db.relationship('Post', backref='author', lazy=True)

    def __repr__(self):
        return f"User('{self.username}, '{self.email}', '{self.image_file}')"
コード例 #17
0
ファイル: models.py プロジェクト: nikolxxlyes/LodalBlog
class WeatherPoint(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    city = db.Column(db.String(32))
    country = db.Column(db.String(32))
    timestamp = db.Column(db.DateTime(),index=True,)
    temp = db.Column(db.Float(precision=2))
    feels_like = db.Column(db.Float(precision=2))
    wind_spd = db.Column(db.Float(precision=2))
    description = db.Column(db.String(16))
    icon = db.Column(db.String(8))
    precipitation = db.Column(db.Float(precision=2))

    def __repr__(self):
        return f"<{self.city}/{self.country} on {self.timestamp}>".capitalize()
コード例 #18
0
ファイル: model.py プロジェクト: yashrathi-git/flask_blog
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    title = db.Column(db.String(128), nullable=False)
    short_description = db.Column(db.String(250), nullable=False)
    post = db.Column(db.Text, nullable=False)
    date = db.Column(db.DateTime)

    def __init__(self, user_id, title, post, short_description):
        self.user_id = user_id
        self.post = post
        self.title = title
        self.date = datetime.now()
        self.short_description = short_description
コード例 #19
0
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(50),
                           nullable=False,
                           default='default.jpg')
    password = db.Column(db.String(60), nullable=False)
    posts = db.relationship('Post', backref='author', lazy=True)

    def __repr__(
            self):  # the string that returns while using print() explicitly
        return "User('{}', '{}', '{}')".format(self.username, self.email,
                                               self.image_file)
コード例 #20
0
ファイル: model.py プロジェクト: BAGGK/lzk_blog
class Posts(db.Model, DbBase):
    posts_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    # 文件原来的名字
    filename = db.Column(db.String(128), nullable=False)
    # 文件的存储地址
    last_modify_time = db.Column(db.BigInteger, index=True)
    content = db.Column(db.String(15000))

    # 关联变量
    tags = db.relationship('Tag', secondary='posts_tag', backref=db.backref('posts_set'))
    # 添加配置设置编码
    __table_args__ = {
        'mysql_charset': 'utf8'
    }
コード例 #21
0
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='profile.jpg')
    password = db.Column(db.String(60), nullable=False)
    # bacref is similar to adding a column in Post Model
    # lazy argument defines the data when SQLALCHEMY loads the data from the database
    posts = db.relationship('Post', backref='author', lazy=True)

    def __repr__(self):
        return f'User("{self.username}","{self.email}","{self.image_file}")'
コード例 #22
0
class User(db.Model,UserMixin):
	id=db.Column(db.Integer,primary_key=True)
	username=db.Column(db.String(15),unique=True,nullable=False)
	password=db.Column(db.String(100),nullable=False)
	email=db.Column(db.String(50),unique=True,nullable=False)
	information=db.Column(db.String(100))
	twitter=db.Column(db.String(30))
	Linkedin=db.Column(db.String(50))
	image=db.Column(db.String(100),nullable=False,default="default.jpg")
	instagram=db.Column(db.String(30))
	posts=db.relationship("Post",backref="author",lazy=True)
	
	
	def get_reset_token(self,expires_sec=3600):
		s=Serializer(app.config["SECRET_KEY"],expires_sec)
		return s.dumps({"user_id":self.id}).decode("utf-8")
		
		
		
	@staticmethod
	def verify_reset_token(token):
		s=Serializer(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"username:{self.username},id:{self.id}")
コード例 #23
0
class Users(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    password = db.Column(db.String(80))
    email = db.Column(db.String(120))

    def __init__(self, username, age, email):
        self.username = username
        self.age = age
        self.email = email

    def __repr__(self):
        return '<User:%r>' % self.username
コード例 #24
0
ファイル: models.py プロジェクト: Hadiaj448/bookstore
class Customerregister(db.Model,UserMixin):
    id=db.Column(db.Integer,primary_key=True)
    username=db.Column(db.String(20))
    lastname=db.Column(db.String(100))
    phone=db.Column(db.Integer,nullable=False)
    add=db.Column(db.Text,nullable=False)
    image1=db.Column(db.String(150),nullable=False,default='image.jpg')
    nic=db.Column(db.Integer,nullable=False)
    hour=db.Column(db.Integer,nullable=False)
    day=db.Column(db.Integer,nullable=False)
    month=db.Column(db.Integer,nullable=False)
    year=db.Column(db.Integer,nullable=False)
    price=db.Column(db.Integer,nullable=False)
    date=db.Column(db.DateTime,nullable=False,default=datetime.utcnow)
コード例 #25
0
class User(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(50), unique=True)
    display_name = db.Column(db.String(100))
    password_hash = db.Column(db.Text())

    def set_password(self, password):
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)

    def __repr__(self):
        return self.name
コード例 #26
0
class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=False)
    email = db.Column(db.String(120), index=True, unique=False)
    password_hash = db.Column(db.String(128))
    posts = db.relationship('Post', backref='author', lazy='dynamic')

    def __repr__(self):
        return '<User {}>'.format(self.username)

    def set_password(self, password):
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)
コード例 #27
0
ファイル: models.py プロジェクト: AlexRodis/MutableMinds
class User(db.Model, UserMixin):

    idx = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(25), unique=True, nullable=False)
    email = db.Column(db.String(125), unique=True, nullable=False)
    profile_pic = db.Column(db.String(20),
                            unique=False,
                            nullable=False,
                            default='default.jpg')
    password = db.Column(db.String(20), unique=False, nullable=False)

    posts = db.relationship('Post', backref='author', lazy='dynamic')

    def __repr__(self):
        return f"< User {self.username} , {self.email}, {self.profile_pic} >"
コード例 #28
0
class User(db.Model, UserMixin):
    """This Class Handles the Admin User"""
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(50), unique=True, nullable=False)
    password = db.Column(db.String(150), nullable=False)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    admin = db.Column(db.Boolean, default=False)

    def is_admin(self):
        return self.admin

    def __repr__(self):
        return f"User('{self.username}', '{self.password}', {self.date_created}')"
コード例 #29
0
class Tag(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))
    slug = db.Column(db.String(100))

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.slug = slugify(self.name)

    def generate_slug(self):
        if self.name:
            self.slug = slugify(self.name)

    def __repr__(self):
        return f'<Tag id: {self.id}, name: {self.name}>'
コード例 #30
0
ファイル: models.py プロジェクト: wouerner/studies-flask
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)

    def __init__(self, username=None, email=None):
        self.username = username
        self.email = email

    def __repr__(self):
        return '<User %r>' % self.username

    @property
    def serialize(self):
        return {'username': self.username, 'email': self.email}