Exemplo n.º 1
0
 def setDefaultItems(self, num):
   if defaultItemList.getPublisherUrl() == self.getParam('publisherUrl'):
     return # Do not sets default links for the url that is hosting it
   defaultItems = defaultItemList.getOrderedItems()
   if num < len(defaultItems):
     defaultItems = defaultItems[0: num]
   if len(defaultItems):
     self.common_response.setDefaultItems(defaultItems, response.ItemInfo.SHORT)
Exemplo n.º 2
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))