Esempio n. 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."]
         )
Esempio n. 2
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:
             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."]
         )
Esempio n. 3
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()
Esempio n. 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()