예제 #1
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), nullable=False, unique=True)
    password = db.Column(db.String(256), nullable=False)

    # 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.id

    def __repr__(self):
        return "User('%s')" % (self.username)
예제 #2
0
class Challenge(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(64), nullable=False)
    description = db.Column(db.Text)
    level = db.Column(db.Integer, nullable=False)
    requirement = db.Column(db.Integer)
    flag = db.Column(db.String(256), nullable=False)
    url = db.Column(db.String(256), nullable=False)

    categories = db.relationship('Category',
                                 secondary=categories,
                                 backref=db.backref('challenges',
                                                    lazy='dynamic'))

    tags = db.relationship('Tag',
                           secondary=tags,
                           backref=db.backref('challenges', lazy='dynamic'))

    def __repr__(self):
        return "Challenge('%s')" % (self.title)
예제 #3
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    admin = db.Column(db.Boolean, default=False)
    salt = db.Column(db.String(32), default=str(time.time()))
    username = db.Column(db.String(64), nullable=False, unique=True)
    password = db.Column(db.String(256), nullable=False)

    # Contains the list of challenges created by the user
    created = db.relationship('Challenge',
                              secondary=created,
                              backref=db.backref('authors', lazy='dynamic'))

    # Contains the list of challenges validated by the user
    validated = db.relationship('Challenge',
                                secondary=validated,
                                backref=db.backref('validated',
                                                   lazy='dynamic'))

    # Flask-Login integration
    def is_authenticated(self):
        return True

    def is_admin(self):
        return self.admin

    def is_active(self):
        return True

    def is_anonymous(self):
        return False

    def get_id(self):
        return self.id

    def __repr__(self):
        return "User('%s')" % (self.username)
예제 #4
0
class Tag(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    label = db.Column(db.String(64))

    def __repr__(self):
        return "Tag('%s')" % (self.label)
예제 #5
0
class Category(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(128))

    def __repr__(self):
        return "Category('%s')" % (self.name)