Beispiel #1
0
 def post(self, *args, **kwargs):
     """ Purchase a hint """
     uuid = self.get_argument("uuid", "")
     hint = Hint.by_uuid(uuid)
     if hint is not None:
         user = self.get_current_user()
         flag = hint.flag
         if (flag and flag.box.flag_submission_type !=
                 FlagsSubmissionType.SINGLE_SUBMISSION_BOX
                 and Penalty.by_count(
                     flag, user.team) >= self.config.max_flag_attempts):
             self.render_page(
                 hint.box, info=["You can no longer purchase this hint."])
         elif hint.price <= user.team.money:
             logging.info(
                 "%s (%s) purchased a hint for $%d on %s" %
                 (user.handle, user.team.name, hint.price, hint.box.name))
             self._purchase_hint(hint, user.team)
             self.render_page(hint.box)
         else:
             self.render_page(
                 hint.box,
                 info=["You cannot afford to purchase this hint."])
     else:
         self.render("public/404.html")
 def edit_hint(self):
     """ Edit a hint object """
     try:
         hint = Hint.by_uuid(self.get_argument("uuid", ""))
         if hint is None:
             raise ValidationError("Hint does not exist")
         logging.debug("Edit hint object with uuid of %s" % hint.uuid)
         price = self.get_argument("price", "")
         if hint.price != price:
             hint.price = price
         description = self.get_argument("description", "")
         hint.description = description
         flag = Flag.by_uuid(self.get_argument("hint-flag_uuid", ""))
         if flag:
             flag_id = flag.id
         else:
             flag_id = None
         hint.flag_id = flag_id
         box = Box.by_id(flag.box_id)
         self.dbsession.add(hint)
         self.dbsession.commit()
         self.redirect("/admin/view/game_objects#%s" % box.uuid)
     except ValidationError as error:
         self.render("admin/view/game_objects.html",
                     success=None,
                     errors=[str(error)])
Beispiel #3
0
 def post(self, *args, **kwargs):
     ''' Purchase a hint '''
     uuid = self.get_argument('uuid', '')
     hint = Hint.by_uuid(uuid)
     if hint is not None:
         user = self.get_current_user()
         if self.application.settings['game_started'] or user.is_admin():
             flag = hint.flag
             if flag and flag.box.flag_submission_type != FlagsSubmissionType.SINGLE_SUBMISSION_BOX and Penalty.by_count(
                     flag, user.team) >= self.config.max_flag_attempts:
                 self.render_page(
                     hint.box,
                     info=["You can no longer purchase this hint."])
             elif hint.price <= user.team.money:
                 logging.info("%s (%s) purchased a hint for $%d on %s" %
                              (user.handle, user.team.name, hint.price,
                               hint.box.name))
                 self._purchase_hint(hint, user.team)
                 self.render_page(hint.box)
             else:
                 self.render_page(
                     hint.box,
                     info=["You cannot afford to purchase this hint."])
         else:
             self.render('missions/status.html',
                         errors=None,
                         info=["The game has not started yet"])
     else:
         self.render('public/404.html')
Beispiel #4
0
 def del_hint(self):
     ''' Delete a hint from the database '''
     hint = Hint.by_uuid(self.get_argument('uuid', ''))
     if hint is not None:
         logging.info("Delete hint: %s" % hint.uuid)
         self.dbsession.delete(hint)
         self.dbsession.commit()
         self.redirect('/admin/view/game_objects')
     else:
         self.render('admin/view/game_objects.html',
                     errors=["Hint does not exist in database."])
 def del_hint(self):
     ''' Delete a hint from the database '''
     hint = Hint.by_uuid(self.get_argument('uuid', ''))
     if hint is not None:
         logging.info("Delete hint: %s" % hint.uuid)
         self.dbsession.delete(hint)
         self.dbsession.commit()
         self.redirect('/admin/view/game_objects')
     else:
         self.render('admin/view/game_objects.html',
             errors=["Hint does not exist in database."]
         )
 def del_hint(self):
     """ Delete a hint from the database """
     hint = Hint.by_uuid(self.get_argument("uuid", ""))
     if hint is not None:
         logging.info("Delete hint: %s" % hint.uuid)
         self.dbsession.delete(hint)
         self.dbsession.commit()
         self.redirect("/admin/view/game_objects")
     else:
         self.render(
             "admin/view/game_objects.html",
             errors=["Hint does not exist in database."],
         )
Beispiel #7
0
 def post(self, *args, **kwargs):
     ''' Purchase a hint '''
     uuid = self.get_argument('uuid', '')
     hint = Hint.by_uuid(uuid)
     if hint is not None:
         user = self.get_current_user()
         if hint.price <= user.team.money:
             logging.info("%s (%s) purchased a hint for $%d on %s" % (
                 user.handle, user.team.name, hint.price, hint.box.name
             ))
             self._purchase_hint(hint, user.team)
             self.render_page(hint.box)
         else:
             self.render_page(hint.box, ["You cannot afford to purchase this hint."])
     else:
         self.render('public/404.html')
 def edit_hint(self):
     ''' Edit a hint object '''
     try:
         hint = Hint.by_uuid(self.get_argument('uuid', ''))
         if hint is None:
             raise ValidationError("Hint does not exist")
         logging.debug("Edit hint object with uuid of %s" % hint.uuid)
         price = self.get_argument('price', '')
         if hint.price != price:
             hint.price = price
         description = self.get_argument('description', '')
         hint.description = description
         self.dbsession.add(hint)
         self.dbsession.commit()
         self.redirect('/admin/view/game_objects')
     except ValidationError as error:
         self.render("admin/view/game_objects.html", errors=[str(error), ])
Beispiel #9
0
 def edit_hint(self):
     ''' Edit a hint object '''
     hint = Hint.by_uuid(self.get_argument('uuid', ''))
     if hint is not None:
         try:
             logging.debug("Edit hint object with uuid of %s" % hint.uuid)
             price = self.get_argument('price', hint.price)
             if hint.price != price:
                 hint.price = price
             description = self.get_argument('description', hint.description)
             if hint.description != description:
                 hint.description = description
             self.dbsession.add(hint)
             self.dbsession.commit()
             self.redirect('/admin/view/game_objects')
         except ValueError as error:
             self.render("admin/view/game_objects.html", errors=["%s" % error])
     else:
         self.render("admin/view/game_objects.html", errors=["User does not exist"])
Beispiel #10
0
 def edit_hint(self):
     ''' Edit a hint object '''
     try:
         hint = Hint.by_uuid(self.get_argument('uuid', ''))
         if hint is None:
             raise ValidationError("Hint does not exist")
         logging.debug("Edit hint object with uuid of %s" % hint.uuid)
         price = self.get_argument('price', '')
         if hint.price != price:
             hint.price = price
         description = self.get_argument('description', '')
         hint.description = description
         self.dbsession.add(hint)
         self.dbsession.commit()
         self.redirect('/admin/view/game_objects')
     except ValidationError as error:
         self.render("admin/view/game_objects.html", errors=[
             str(error),
         ])
Beispiel #11
0
 def post(self, *args, **kwargs):
     ''' Purchase a hint '''
     uuid = self.get_argument('uuid', '')
     hint = Hint.by_uuid(uuid)
     if hint is not None:
         user = self.get_current_user()
         if self.application.settings['game_started'] or user.is_admin():
             flag = hint.flag
             if flag and flag.box.flag_submission_type != FlagsSubmissionType.SINGLE_SUBMISSION_BOX and Penalty.by_count(flag, user.team) >= self.config.max_flag_attempts:
                 self.render_page(
                     hint.box, info=["You can no longer purchase this hint."])
             elif hint.price <= user.team.money:
                 logging.info("%s (%s) purchased a hint for $%d on %s" % (
                     user.handle, user.team.name, hint.price, hint.box.name
                 ))
                 self._purchase_hint(hint, user.team)
                 self.render_page(hint.box)
             else:
                 self.render_page(
                     hint.box, info=["You cannot afford to purchase this hint."])
         else:
             self.render('missions/status.html', errors=None, info=["The game has not started yet"])
     else:
         self.render('public/404.html')