コード例 #1
0
 def post(self, *args, **kwargs):
     ''' Called to purchase an item '''
     uuid = self.get_argument('uuid', '')
     item = MarketItem.by_uuid(uuid)
     if not item is None:
         user = self.get_current_user()
         team = Team.by_id(user.team.id)  # Refresh object
         if user.has_item(item.name):
             self.render('market/view.html',
                         user=user,
                         errors=["You have already purchased this item."])
         elif team.money < item.price:
             message = "You only have $%d" % (team.money, )
             self.render('market/view.html', user=user, errors=[message])
         else:
             logging.info("%s (%s) purchased the market item '%s' for $%d" %
                          (user.handle, team.name, item.name, item.price))
             self.purchase_item(team, item)
             event = self.event_manager.create_purchased_item_event(
                 user, item)
             self.new_events.append(event)
             self.redirect('/user/market')
     else:
         self.render('market/view.html',
                     user=self.get_current_user(),
                     errors=["Item does not exist."])
コード例 #2
0
 def post(self, *args, **kwargs):
     """ Called to purchase an item """
     uuid = self.get_argument("uuid", "")
     item = MarketItem.by_uuid(uuid)
     if item is not None:
         user = self.get_current_user()
         team = Team.by_id(user.team.id)  # Refresh object
         if user.has_item(item.name):
             self.render(
                 "market/view.html",
                 user=user,
                 errors=["You have already purchased this item."],
             )
         elif team.money < item.price:
             if options.banking:
                 money = "$%d" % team.money
             else:
                 money = "%d points" % team.money
             message = "You only have %s" % (money)
             self.render("market/view.html", user=user, errors=[message])
         else:
             logging.info("%s (%s) purchased '%s' for $%d" %
                          (user.handle, team.name, item.name, item.price))
             self.purchase_item(team, item)
             self.event_manager.item_purchased(user, item)
             self.redirect("/user/market")
     else:
         self.render(
             "market/view.html",
             user=self.get_current_user(),
             errors=["Item does not exist."],
         )
コード例 #3
0
 def post(self, *args, **kwargs):
     ''' Called to purchase an item '''
     uuid = self.get_argument('uuid', '')
     item = MarketItem.by_uuid(uuid)
     if not item is None:
         user = self.get_current_user()
         team = Team.by_id(user.team.id)  # Refresh object
         if user.has_item(item.name):
             self.render('market/view.html',
                         user=user,
                         errors=["You have already purchased this item."]
                         )
         elif team.money < item.price:
             message = "You only have $%d" % (team.money,)
             self.render('market/view.html', user=user, errors=[message])
         else:
             logging.info("%s (%s) purchased '%s' for $%d" % (
                 user.handle, team.name, item.name, item.price
             ))
             self.purchase_item(team, item)
             self.event_manager.item_purchased(user, item)
             self.redirect('/user/market')
     else:
         self.render('market/view.html',
                     user=self.get_current_user(),
                     errors=["Item does not exist."]
                     )
コード例 #4
0
 def get(self, *args, **kwargs):
     ''' Get details on an item '''
     uuid = self.get_argument('uuid', '')
     item = MarketItem.by_uuid(uuid)
     if item is None:
         self.write({'Error': 'Item does not exist.'})
     else:
         self.write(item.to_dict())
     self.finish()
コード例 #5
0
 def get(self, *args, **kwargs):
     """ Get details on an item """
     uuid = self.get_argument("uuid", "")
     item = MarketItem.by_uuid(uuid)
     if item is None:
         self.write({"Error": "Item does not exist."})
     else:
         self.write(item.to_dict())
     self.finish()
コード例 #6
0
 def get(self, *args, **kwargs):
     ''' Get details on an item '''
     uuid = self.get_argument('uuid', '')
     item = MarketItem.by_uuid(uuid)
     if item is None:
         self.write({'Error': 'Item does not exist.'})
     else:
         self.write(item.to_dict())
     self.finish()
コード例 #7
0
 def edit_market_item(self):
     """ Change a market item's price """
     try:
         item = MarketItem.by_uuid(self.get_argument("item_uuid", ""))
         if item is None:
             raise ValidationError("Item does not exist")
         price = self.get_argument("price", item.price)
         if item.price != price:
             item.price = price
         self.dbsession.add(item)
         self.dbsession.commit()
         self.redirect("/admin/view/market_objects")
     except ValidationError as error:
         self.render("admin/view/market_objects.html", errors=[str(error)])
コード例 #8
0
 def edit_market_item(self):
     ''' Change a market item's price '''
     try:
         item = MarketItem.by_uuid(self.get_argument('item_uuid', ''))
         if item is None:
             raise ValidationError("Item does not exist")
         price = self.get_argument('price', item.price)
         if item.price != price:
             item.price = price
         self.dbsession.add(item)
         self.dbsession.commit()
         self.redirect('/admin/view/market_objects')
     except ValidationError as error:
         self.render('admin/view/market_objects.html', errors=[str(error)])
コード例 #9
0
 def edit_market_item(self):
     ''' Change a market item's price '''
     try:
         item = MarketItem.by_uuid(self.get_argument('item_uuid', ''))
         if item is None:
             raise ValidationError("Item does not exist")
         price = self.get_argument('price', item.price)
         if item.price != price:
             item.price = price
         self.dbsession.add(item)
         self.dbsession.commit()
         self.redirect('/admin/view/market_objects')
     except ValidationError as error:
         self.render('admin/view/market_objects.html', errors=[str(error)])
コード例 #10
0
 def edit_market_item(self):
     ''' Change a market item's price '''
     item = MarketItem.by_uuid(self.get_argument('item_uuid', ''))
     if item is not None:
         try:
             price = self.get_argument('price', item.price)
             if item.price != price:
                 item.price = price
             self.dbsession.add(item)
             self.dbsession.commit()
             self.redirect('/admin/view/market_objects')
         except ValueError:
             self.render('admin/view/market_objects.html',
                 errors=["Invalid price."]
             )
     else:
         self.render('admin/view/market_objects.html',
             errors=["Item does not exist."]
         )
コード例 #11
0
 def has_item(self, item_name):
     ''' Check to see if a team has purchased an item '''
     item = MarketItem.by_name(item_name)
     if item is None:
         raise ValueError("Item '%s' not in database." % str(item_name))
     return True if item in self.team.items else False
コード例 #12
0
    (u"386", [u'386.css', u'386.js', u'386.responsive.css']),
]
for css in css_files:
    theme = Theme(name=css[0])
    dbsession.flush()
    for f in css[1]:
        theme_file = ThemeFile(theme_id=theme.id, file_name=f)
        theme.files.append(theme_file)
        dbsession.add(theme_file)
    dbsession.add(theme)

# Market Items
item = MarketItem(
    name=u"Source Code Market",
    price=500,
    image=u"source_code_market.png",
    description=
    u"Allows your team access to the Source Code Black Market where you can purchase leaked source code for certain target boxes.",
)
dbsession.add(item)
dbsession.flush()

item = MarketItem(
    name=u"Password Security",
    price=1000,
    image=u"password_security.png",
    description=
    u"Allows your team to upgrade their password hashes to more secure algorithms such as SHA1, and SHA256.",
)
dbsession.add(item)
dbsession.flush()
コード例 #13
0
ファイル: User.py プロジェクト: brutalhonesty/RootTheBox
 def has_item(self, item_name):
     ''' Check to see if a team has purchased an item '''
     item = MarketItem.by_name(item_name)
     if item is None:
         raise ValueError("Item '%s' not in database." % str(item_name))
     return True if item in self.team.items else False