Ejemplo n.º 1
0
class Player(db.Model):

    player_id = db.Column(db.Integer, primary_key=True, unique=True)
    player_name = db.Column(db.String(25), nullable=False)
    player_image = db.Column(db.String(20),
                             nullable=False,
                             default='default.jpg')
    player_style = db.Column(db.String(10), nullable=True)
    player_mat = db.Column(db.Integer, nullable=True)
    player_inns = db.Column(db.Integer, nullable=True)
    player_runs = db.Column(db.Integer, nullable=True)
    player_hs = db.Column(db.Integer, nullable=True)
    player_sr = db.Column(db.Float, nullable=True)
    player_ave = db.Column(db.Float, nullable=True)
    player_century = db.Column(db.Integer, nullable=True)
    player_country = db.Column(db.String(15), nullable=True)
    player_type = db.Column(db.String(12), nullable=True)
    player_bruns = db.Column(db.Integer, nullable=True)
    player_wkts = db.Column(db.Integer, nullable=True)
    player_bave = db.Column(db.Float, nullable=True)
    player_bsr = db.Column(db.Float, nullable=True)

    def __repr__(self):
        return f"Player('{self.player_id}', '{self.player_name}', '{self.player_image}', '{self.player_style}'," \
               f" '{self.player_mat}', '{self.player_inns}', '{self.player_country}', '{self.player_runs}'," \
               f" '{self.player_hs}', '{self.player_sr}', '{self.player_century}', '{self.player_type}'," \
               f" '{self.player_bruns}', '{self.player_bave}', '{self.player_bsr}')"
Ejemplo n.º 2
0
class Question(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(30))
    text = db.Column(db.String(1000))
    register_date = db.Column(db.DateTime,
                              nullable=False,
                              default=datetime.utcnow)
    engineer = db.Column(db.String(30))
    closed = db.Column(db.Boolean)
    user_id = db.Column(db.Integer, nullable=False)
    ups = db.Column(db.Integer)
    downs = db.Column(db.Integer)
    tags = db.Column(db.String(1000))

    def __repr__(self):
        return '<Question %r>' % self.id

    # the Questions object can now be iterated over. (also allows us to convert to a dict() )
    def __iter__(self):
        yield 'id', self.id
        yield 'title', self.title
        yield 'text', self.text
        yield 'register_date', str(self.register_date)
        yield 'engineer', self.engineer
        yield 'closed', self.closed
        yield 'user_id', self.user_id
        yield 'ups', self.ups
        yield 'downs', self.downs
        yield 'tags', self.tags
Ejemplo n.º 3
0
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)

    # posts = db.relationship('Post', backref="author", lazy=True)

    def __repr__(self):
        return f"User('{self.id}', {self.username}, {self.password})"
Ejemplo n.º 4
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(30), nullable=False)

    def __repr__(self):
        return f"User('{self.username}', '{self.email}', '{self.image_file}')"
Ejemplo n.º 5
0
class Users(UserMixin, db.Model):
    id = db.Column(db.Integer,
                   primary_key=True)  # primary keys are required by SQLAlchemy
    username = db.Column(db.String(100), unique=True)
    password = db.Column(db.String(100))
    admin = db.Column(db.Boolean, default=False)

    def is_admin(self):
        return admin
Ejemplo n.º 6
0
class Regtb(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    Name = db.Column(db.String(255))
    Email = db.Column(db.String, unique=True, nullable=False)
    Password = db.Column(db.String(255))
    Registered_id = db.Column(db.Integer)
    Reg_Datee = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)


# if __name__ =='__main__':
#     manager.run()
Ejemplo n.º 7
0
class User(db.Model):
    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}')"
Ejemplo n.º 8
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, index=True)
    password_hash = db.Column(db.String(128))

    items = db.relationship('Item', back_populates='author', cascade='all')

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

    def validate_password(self, password):
        return check_password_hash(self.password_hash, password)
Ejemplo n.º 9
0
class Answer(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    text = db.Column(db.String(1000))
    register_date = db.Column(db.DateTime,
                              nullable=False,
                              default=datetime.utcnow)
    accepted = db.Column(db.Boolean)
    user_id = db.Column(db.Integer, nullable=False)
    question_id = db.Column(db.Integer, nullable=False)
    ups = db.Column(db.Integer)
    downs = db.Column(db.Integer)

    def __repr__(self):
        return '<Answer %r>' % self.id

    # the Answers object can now be iterated over. (also allows us to convert to a dict() )
    def __iter__(self):
        yield 'id', self.id
        yield 'text', self.text
        yield 'register_date', str(self.register_date)
        yield 'accepted', self.accepted
        yield 'user_id', self.user_id
        yield 'question_id', self.question_id
        yield 'ups', self.ups
        yield 'downs', self.downs
Ejemplo n.º 10
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    body = db.Column(db.String(140))
    timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))

    def __repr__(self):
        return '<Post {}>'.format(self.body)
Ejemplo n.º 11
0
class Post(db.Model):
    id = db.Column(db.Integer,primary_key=True)
    title = db.Column(db.String(100),nullable=False)
    date_posted = db.Column(db.DateTime,nullable=False,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"User('{self.title}','{self.date_posted}')"
Ejemplo n.º 12
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(120), nullable=False)
    content = db.Column(db.Text, nullable=False)
    # date_posted = db.Column(db.DateTime,nullable=False,default=datetime.utcnow)
    # image_file = db.Column(db.String(20),nullable=False,default='default.jpg')
    # password= db.Column(db.String(60),nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def __repr__(self):
        return f"Post('{self.title}')"
Ejemplo n.º 13
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    fname = db.Column(db.String(30))
    lname = db.Column(db.String(30))
    email = db.Column(db.String(120), unique=True, nullable=False)
    password_hash = db.Column(db.String(100), nullable=False)
    register_date = db.Column(db.DateTime,
                              nullable=False,
                              default=datetime.utcnow)
    engineer = db.Column(db.String(30))
    display_image = db.Column(db.String(30))  # location of image
    verified = db.Column(db.Integer)
    ups = db.Column(db.Integer)
    downs = db.Column(db.Integer)
    confirmed = db.Column(db.Integer)

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

    # the User object can now be iterated over. (also allows us to convert to a dict() )
    def __iter__(self):
        yield 'id', self.id
        yield 'fname', self.fname
        yield 'lname', self.lname
        yield 'email', self.email
        yield 'password_hash', self.password_hash
        yield 'register_date', str(self.register_date)
        yield 'engineer', self.engineer
        yield 'display_image', self.display_image
        yield 'verified', self.verified
        yield 'ups', self.ups
        yield 'downs', self.downs
        yield 'confirmed', self.confirmed
Ejemplo n.º 14
0
class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    email = db.Column(db.String(120), index=True, unique=True)
    password_hash = db.Column(db.String(128))
    posts = db.relationship('Post', backref='author', lazy='dynamic')
    about_me = db.Column(db.String(140))
    last_seen = db.Column(db.DateTime, default=datetime.utcnow)

    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)

    def avatar(self, size):
        digest = md5(self.email.lower().encode('utf-8')).hexdigest()
        return 'https://www.gravatar.com/avatar/{}?d=identicon&s={}'.format(
            digest, size)
Ejemplo n.º 15
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)
    posts = db.relationship('Post',backref='author',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}')"
Ejemplo n.º 16
0
class Player(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    player_name = db.Column(db.String(25), nullable=False)
    player_image = db.Column(db.String(20), nullable=False, default='default.jpg')
    player_style = db.Column(db.String(10), nullable=False)
    player_stats = db.Column(db.String(10), nullable=True)
    player_average = db.Column(db.String(10), nullable=True)
    player_country = db.Column(db.String(15), nullable=True)

    def __repr__(self):
        return f"Player('{self.player_name}', '{self.player_image}', '{self.player_style}'," \
               f" '{self.player_stats}', '{self.player_average}', '{self.player_country}')"
Ejemplo n.º 17
0
class Vote(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    vote_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    user_id = db.Column(db.Integer, nullable=False)  # user_id
    comment_id = db.Column(db.Integer,
                           nullable=False)  # question_id or answer_id
    comment_status = db.Column(db.String(20))  # 'answer' | 'question'
    vote_status = db.Column(db.Integer,
                            nullable=False)  # 1 => up, 0 => none, -1 => down

    def __repr__(self):
        return '<Vote %r>' % self.id

    # the Questions object can now be iterated over. (also allows us to convert to a dict() )
    def __iter__(self):
        yield 'id', self.id
        yield 'vote_date', str(self.vote_date)
        yield 'user_id', self.user_id
        yield 'comment_id', self.comment_id
        yield 'comment_status', self.comment_status
        yield 'vote_status', self.vote_status
Ejemplo n.º 18
0
class Infected_france(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.Date, unique=True)
    infected = db.Column(db.String(100))
    dead = db.Column(db.String(100))
    country_name = db.Column(db.String(255))