Exemple #1
0
 def post_admin(self, data):
     cid = data.get('cid', None)
     tid = data.get('tid', None)
     if not cid or not tid:
         raise errors.ValidationError('Requires team and challenge.')
     challenge = models.Challenge.query.get(data['cid'])
     team = models.Team.query.get(data['tid'])
     if not challenge or not team:
         raise errors.ValidationError('Requires team and challenge.')
     user = models.User.current()
     app.challenge_log.info(
         'Admin %s <%s> submitting flag for challenge %s <%d>, '
         'team %s <%d>', user.nick, user.email, challenge.name,
         challenge.cid, team.name, team.tid)
     try:
         points = controllers.save_team_answer(challenge, team, None)
     except (errors.IntegrityError, errors.FlushError) as ex:
         app.logger.exception('Unable to save answer for %s/%s: %s',
                              str(data['tid']), str(data['tid']), str(ex))
         models.db.session.rollback()
         raise errors.AccessDeniedError(
             'Unable to save answer for team. See log for details.')
     cache.delete('cats/%d' % tid)
     cache.delete('scoreboard')
     return dict(points=points)
Exemple #2
0
 def post(self):
     data = flask.request.get_json()
     points = controllers.submit_answer(data['cid'], data['answer'])
     models.commit()
     cache.delete_team('cats/%d')
     cache.delete('scoreboard')
     return dict(points=points)
 def post(self):
     data = flask.request.get_json()
     points = controllers.submit_answer(data['cid'], data['answer'])
     models.commit()
     cache.delete_team('cats/%d')
     cache.delete('scoreboard')
     return dict(points=points)
Exemple #4
0
 def post_admin(self, data):
     cid = data.get('cid', None)
     tid = data.get('tid', None)
     if not cid or not tid:
         raise errors.ValidationError('Requires team and challenge.')
     challenge = models.Challenge.query.get(data['cid'])
     team = models.Team.query.get(data['tid'])
     if not challenge or not team:
         raise errors.ValidationError('Requires team and challenge.')
     user = models.User.current()
     app.challenge_log.info(
             'Admin %s <%s> submitting flag for challenge %s <%d>, '
             'team %s <%d>',
             user.nick, user.email, challenge.name, challenge.cid,
             team.name, team.tid)
     try:
         points = controllers.save_team_answer(challenge, team, None)
         models.commit()
     except (errors.IntegrityError, errors.FlushError) as ex:
         app.logger.exception(
                 'Unable to save answer for %s/%s: %s',
                 str(data['tid']), str(data['tid']), str(ex))
         models.db.session.rollback()
         raise errors.AccessDeniedError(
             'Unable to save answer for team. See log for details.')
     cache.delete('cats/%d' % tid)
     cache.delete('scoreboard')
     return dict(points=points)
Exemple #5
0
 def post_player(self, data):
     answer = utils.normalize_input(data['answer'])
     try:
         points = controllers.submit_answer(data['cid'], answer,
                                            data.get('token'))
     except (errors.IntegrityError, errors.FlushError):
         models.db.session.rollback()
         raise errors.AccessDeniedError(
             'Previously solved or flag already used.')
     cache.delete_team('cats/%d')
     cache.delete('scoreboard')
     return dict(points=points)
Exemple #6
0
 def post(self):
     data = flask.request.get_json()
     answer = utils.normalize_input(data['answer'])
     points = controllers.submit_answer(data['cid'], answer)
     try:
         models.commit()
     except (errors.IntegrityError, errors.FlushError):
         models.db.session.rollback()
         raise errors.AccessDeniedError("You've already solved that one!")
     cache.delete_team('cats/%d')
     cache.delete('scoreboard')
     return dict(points=points)
Exemple #7
0
 def post_player(self, data):
     answer = utils.normalize_input(data['answer'])
     try:
         points = controllers.submit_answer(
             data['cid'], answer, data.get('token'))
     except errors.IntegrityError:
         raise errors.AccessDeniedError(
                 'Previously solved or flag already used.')
     try:
         models.commit()
     except (errors.IntegrityError, errors.FlushError):
         models.db.session.rollback()
         raise errors.AccessDeniedError("You've already solved that one!")
     cache.delete_team('cats/%d')
     cache.delete('scoreboard')
     return dict(points=points)