Ejemplo 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."]
         )
Ejemplo 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."]
         )
Ejemplo 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()
Ejemplo 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()
Ejemplo n.º 5
0
    (u"Simplex", u'simplex.min.css'),
    (u"Spacelab", u'spacelab.min.css'),
    (u"Superhero", u'superhero.min.css'),
]
for css in css_files:
    theme = Theme(
        name=css[0],
        cssfile=css[1],
    )
    dbsession.add(theme)
    dbsession.flush()

# Market Items
item = MarketItem(
    name=u"Source Code Market",
    price=5000,
    description=u"Buy leaked source code.",
)
dbsession.add(item)
dbsession.flush()

item = MarketItem(
    name=u"Password Security",
    price=7500,
    description=
    u"Allows your team to upgrade their password hashes to SHA1, and SHA256.",
)
dbsession.add(item)
dbsession.flush()

item = MarketItem(