Exemple #1
0
 def get(self, url):
     user = users.get_current_user()
         
     if user and users.is_current_user_admin():
         context = {'user' : user.nickname()}
         logout_url = users.create_logout_url(self.request.uri)
         context['logout_url'] = logout_url
         if url == 'algorithm.html':
           context['alg'] =  model.getOrderingAlgorithmParams()
         elif url == 'background.html':
           activities = model.getActivities(False)
           i = 0
           for activity in activities:
             activity.index = i
             i += 1
           newActivity = model.ActivityParams()
           newActivity.name = NEW_ACTIVITY_NAME
           newActivity.activity_load = 0
           newActivity.index = i
           newActivity.enabled = False
           newActivity.threshold_total[model.ActivityTypes.ITEM] = 0
           newActivity.threshold_time_sec[model.ActivityTypes.ITEM] = 0
           activities.append(newActivity)
           context['activities'] = activities
           context['timePeriod'] = activityManager.getActivityPeriod()
         elif url =='publishers.html':
           publishers = model.getPublisherSites()
           context['publishers'] = publishers
         elif url =='paymentsconfig.html':
           context['paymentparams'] = model.getPaymentConfig()
         elif url =='ligerpediaconfig.html':
           context['ligerpediaconfig'] = model.getLigerpediaConfig()
         elif url =='defaultlinks.html':
           config = model.getDefaultLinksConfig()
           context['publisher'] = model.getPublisherSite(config.default_links_url)
           context['defaultlinksconfig'] = config
           items = defaultItemList.getOrderedItems()
           views = 0
           for item in items:
             views += item.stats[model.StatType.VIEWS]
           context['items'] = items
           context['totalviews'] = views
         path = ''
         if url and len(url) > 0:
           path = os.path.join(os.path.dirname(__file__), 'webadmin', url)
         else:
           path = os.path.join(os.path.dirname(__file__), 'webadmin', 'index.html')
         self.response.out.write(template.render(path, context))
     elif user and users.is_current_user_admin() == False:
         context = {'user' : user.nickname()}
         login_url = users.create_login_url(self.request.uri)
         context['login_url'] = login_url
         path = os.path.join(os.path.dirname(__file__), 'webadmin', 'unauthorized.html')
         self.response.out.write(template.render(path, context))
     else:
         self.redirect(users.create_login_url(self.request.uri))
Exemple #2
0
 def updatePaymentConfig(self):
   config = model.getPaymentConfig()
   
   if self.request.get('test'):
     config.test_mode = True
   else:
     config.test_mode = False
   if self.request.get('email'):
     config.send_email = True
   else:
     config.send_email = False
   config.put()
Exemple #3
0
 def post(self):
   try:
     BaseHandler.initFromRequest(self, self.request)
     # TODO: assert https
     item = BaseHandler.getItem(self, self.getParam('itemId'))
     paymentConfig = model.getPaymentConfig()
     if item and self._verifyTransaction(item, paymentConfig.test_mode):  
       price = int(self.getParam('price'))
       item.updatePrice(price, self.getParam('email'))
       item.put()
       publisherSite = model.getPublisherSite(item.publisherUrl)
       db.run_in_transaction(updatePublisherPrice_, publisherSite.key(), price)
       itemList.refreshCacheForDefaultOrderedItems(item.publisherUrl)
       logging.info('Number of price updates : %d' % len(item.payments))
       logging.info('Last price update : %s' % str(item.payments[len(item.payments)-1]))
       if paymentConfig.send_email:
         BaseHandler.sendConfirmationEmail(self, self.getParam('email'), self.getParam('price'), item)                                   
     self.common_response.setItems([item], response.ItemInfo.WITH_PRICE)
   except Exception:
     BaseHandler.logException(self)
   BaseHandler.writeResponse(self)