示例#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))
示例#2
0
 def updateDefaultLinksConfig(self):
   config = model.getDefaultLinksConfig()
   config.enable = bool(self.request.get('enable'))
   url = str(self.request.get('url')).lower()
   config.default_links_url = url
   config.refresh_period_sec = int(self.request.get('refresh'))
   config.throttle = int(self.request.get('throttle'))
   config.throttle_outgoing = bool(self.request.get('outgoing'))
   config.put()
   self.redirect('defaultlinks.html?status=updated')
示例#3
0
 def lazyLoad(self):
   now = time.time()
   refresh = False
   if now - self.lastLoad > self.secToRefresh:
     refresh = True
   if not self.config or refresh:
     self.lastLoad = time.time()
     self.config = model.getDefaultLinksConfig()
     self.secToRefresh = self.config.refresh_period_sec
     if self.secToRefresh < 10:
       self.secToRefresh = 10
     logging.info('Reloading defaultlinks')