コード例 #1
0
class User(db.Model):
    __tablename__ = "user_v2"
    id = db.Column(db.Integer, primary_key=True, index=True)
    login = db.Column(db.String, unique=True, index=True)
    node_id = db.Column(db.String)
    avatar_url = db.Column(db.String)
    gravatar_id = db.Column(db.String)
    url = db.Column(db.String)
    html_url = db.Column(db.String)
    followers_url = db.Column(db.String)
    following_url = db.Column(db.String)
    gists_url = db.Column(db.String)
    starred_url = db.Column(db.String)
    subscriptions_url = db.Column(db.String)
    organizations_url = db.Column(db.String)
    repos_url = db.Column(db.String)
    events_url = db.Column(db.String)
    received_events_url = db.Column(db.String)
    type = db.Column(db.String)
    site_admin = db.Column(db.Boolean)
    name = db.Column(db.String)
    company = db.Column(db.String)
    blog = db.Column(db.String)
    location = db.Column(db.String)
    email = db.Column(db.String)
    hireable = db.Column(db.String)
    bio = db.Column(db.String)
    public_repos = db.Column(db.Integer)
    public_gists = db.Column(db.Integer)
    followers = db.Column(db.Integer)
    following = db.Column(db.Integer)
    created_at = db.Column(db.String())
    updated_at = db.Column(db.String())
コード例 #2
0
class movies(db.Model):
	id = db.Column(db.Integer, primary_key=True)
	title = db.Column(db.String(40))
	desc = db.Column(db.String(255), nullable=False, default=False)
	category = db.Column(db.String(40), nullable=False, default=False)


	rental = db.relationship('rental_info', backref='rental_info', uselist=False)
コード例 #3
0
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
コード例 #4
0
class Survey(db.Model):
    __table__ = 'survey'

    id = db.Column(db.Integer, primary_key=True, index=True)
    description = db.Column(db.String(250), index=True)
    startdate = db.Column(db.DateTime)
    enddate = db.Column(db.DateTime)
    status = db.Column(db.Boolean, default=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    questions = db.relationship('Question',
                                backref='questions',
                                lazy='dynamic')
    response = db.Column(db.String(250), index=True)

    def __repr__(self):
        return "<Survey {}".format(self.description)
コード例 #5
0
class User(db.Model):
    """Basic user model
    """
    __tablename__ = ("user_v2")
    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)
    list_of_rented_movies = db.relationship('rental_info', backref='renter')

    def __init__(self, **kwargs):
        super(User, self).__init__(**kwargs)
        self.password = pwd_context.hash(self.password)

    def __repr__(self):
        return "<User %s>" % self.username
コード例 #6
0
ファイル: tweet.py プロジェクト: handole/restful_api
class Tweet(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    tweet = db.Column(db.String(250), index=True)
    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)
    user_id = db.Column(db.Integer, db.ForeignKey('user_v2.id'))

    def __repr__(self):
        return '<Tweet {}>'.format(self.tweet)
コード例 #7
0
class Task(db.Model):
    """Basic task model"""

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), unique=True, nullable=False)
    status = db.Column(db.Boolean, default=False)

    def __repr__(self):
        return "<Task %s>" % self.name
コード例 #8
0
class User(db.Model):
    """Basic user model
    """
    __tablename__ = "user_v2"
    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)
    tweets = db.relationship('Tweet', backref='tweet_user', lazy='dynamic')
    followed = db.relationship('User',
                               secondary=followers,
                               primaryjoin=(followers.c.follower_id == id),
                               secondaryjoin=(followers.c.followed_id == id),
                               backref=db.backref('follower', lazy='dynamic'),
                               lazy='dynamic')

    active = db.Column(db.Boolean, default=False)

    def __init__(self, **kwargs):
        super(User, self).__init__(**kwargs)
        self.password = pwd_context.hash(self.password)

    def __repr__(self):
        return "<User %s>" % self.username

    def follow(self, user):
        if not self.is_following(user):
            self.followed.append(user)

    def unfollow(self, user):
        if self.is_following(user):
            self.followed.remove(user)

    def is_following(self, user):
        return self.followed.filter(
            followers.c.followed_id == user.id).count() > 0

    def followed_tweet(self):
        followed = Tweet.query.join(
            followers, (followers.c.followed_id == Tweet.user_id)).filter(
                followers.c.followed_id == self.id)
        own = Tw.query.filter_by(user_id=self.id)
        return followed.union(own).order_by(Tweet.timestamp.desc())
コード例 #9
0
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("password", db.String(255), nullable=False)
    active = db.Column(db.Boolean, default=True)

    @hybrid_property
    def password(self):
        return self._password

    @password.setter
    def password(self, value):
        self._password = pwd_context.hash(value)

    def __repr__(self):
        return "<User %s>" % self.username
コード例 #10
0
ファイル: blocklist.py プロジェクト: donos-63/socle_technique
class TokenBlocklist(db.Model):
    """Blocklist representation"""

    id = db.Column(db.Integer, primary_key=True)
    jti = db.Column(db.String(36), nullable=False, unique=True)
    token_type = db.Column(db.String(10), nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
    revoked = db.Column(db.Boolean, nullable=False)
    expires = db.Column(db.DateTime, nullable=False)

    user = db.relationship("User", lazy="joined")

    def to_dict(self):
        return {
            "token_id": self.id,
            "jti": self.jti,
            "token_type": self.token_type,
            "user_identity": self.user_identity,
            "revoked": self.revoked,
            "expires": self.expires,
        }
コード例 #11
0
class TokenBlacklist(db.Model):
    """Blacklist representation
    """
    id = db.Column(db.Integer, primary_key=True)
    jti = db.Column(db.String(36), nullable=False, unique=True)
    token_type = db.Column(db.String(10), nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    revoked = db.Column(db.Boolean, nullable=False)
    expires = db.Column(db.DateTime, nullable=False)

    user = db.relationship('User', lazy='joined')

    def to_dict(self):
        return {
            'token_id': self.id,
            'jti': self.jti,
            'token_type': self.token_type,
            'user_identity': self.user_identity,
            'revoked': self.revoked,
            'expires': self.expires
        }
コード例 #12
0
class Answer(db.Model):
    __table__ = 'answer'
    id = db.Column(db.Integer, primary_key=True, index=True)
    question_id = db.Column(db.Integer, db.ForeignKey('question.id'))
    answering = db.Column(db.String(250), index=True)
コード例 #13
0
class OfferedAnswer(db.Model):
    __table__ = 'offeredanswer'
    id = db.Column(db.Integer, primary_key=True, index=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    response = db.Column(db.String(250), index=True)
コード例 #14
0
class Question(db.Model):
    __table__ = "question"
    id = db.Column(db.Integer, primary_key=True, index=True)
    survey_id = db.Column(db.Integer, db.ForeignKey('survey.id'))
    question_type = db.Column(db.String(100), index=True)
    question = db.Column(db.String(250), index=True)