コード例 #1
0
 def register_user(self):
     user = User(login=self.login.data,
             password = bcrypt.generate_password_hash(self.password.data))
     try:
         db_session.add(user)
         db_session.commit()
         return user
     except:
         return None
コード例 #2
0
ファイル: views.py プロジェクト: Rastii/Weekly_Challenge
def submit_challenge(challenge_id):
    user = current_user
    challenge = db_session.query(Challenge).filter_by(id=challenge_id).first()
    if challenge:
        if challenge in user.submissions:
            #Already solved!
            return "0"
        else:
            if request.form['key'] == challenge.flag:
                user.submissions.append(challenge)
                db_session.commit()
                return "1"
            else:
                return "0"
    else:
        abort(404)
コード例 #3
0
def submit_challenge(challenge_id):
    user = current_user
    challenge = db_session.query(Challenge).filter_by(id=challenge_id).first()
    if challenge:
        if challenge in user.submissions:
            #Already solved!
            return "0"
        else:
            if request.form['key'] == challenge.flag:
                user.submissions.append(challenge)
                db_session.commit()
                return "1"
            else:
                return "0"
    else:
        abort(404)