Пример #1
0
    def index(self, request, extra_context={}):
        """
        This index view implementation adds Google Analytics
        integration so that you can view important metrics 
        right from the administrator interface.
        """        
        dashboard = self.dashboard_class(self._app_labels, self.name)

        #if admin google analytics is enabled
        if ls.ADMIN_GOOGLE_ANALYTICS_FLOW:
            #get the analytics user credentials
            storage = Storage(ls.ADMIN_GOOGLE_ANALYTICS['token_file_name'])
            credential = storage.get()
            
            if credential is None or credential.invalid == True:
                extra_context['ga_data'] = { 'error' : 'authentication' }
            else:
                #get the data
                from utils import get_analytics_data
                http = httplib2.Http()
                extra_context['ga_data'] = get_analytics_data(credential.authorize(http))

        context = {
            'title': _('Site administration'),
            'app_list': dashboard.get_app_list(request, self._registry),
            'dashboard': dashboard
        }
        context.update(extra_context or {})
        return TemplateResponse(request, self.get_index_template() or
                                'admin/index.html', context,
                                current_app=self.name)
Пример #2
0
    def index(self, request, extra_context={}):
        """
        This index view implementation adds Google Analytics
        integration so that you can view important metrics 
        right from the administrator interface.
        """        
        dashboard = self.dashboard_class(self._app_labels, self.name)

        #if admin google analytics is enabled
        if ls.ADMIN_GOOGLE_ANALYTICS_FLOW:
            #get the analytics user credentials
            storage = Storage(ls.ADMIN_GOOGLE_ANALYTICS['token_file_name'])
            credential = storage.get()
            
            if credential is None or credential.invalid == True:
                extra_context['ga_data'] = { 'error' : 'authentication' }
            else:
                #get the data
                from utils import get_analytics_data
                http = httplib2.Http()
                extra_context['ga_data'] = get_analytics_data(credential.authorize(http))

        context = {
            'title': _('Site administration'),
            'app_list': dashboard.get_app_list(request, self._registry),
            'dashboard': dashboard
        }
        context.update(extra_context or {})
        return TemplateResponse(request, self.index_template or
                                'admin/index.html', context,
                                current_app=self.name)
Пример #3
0
 def index(self, request, extra_context={}):
     """
     This index view implementation adds Google Analytics
     integration so that you can view important metrics 
     right from the administrator interface.
     """
     #if admin google analytics is enabled
     if ls.ADMIN_GOOGLE_ANALYTICS_FLOW:
         #get the analytics user credentials
         storage = Storage(ls.ADMIN_GOOGLE_ANALYTICS['token_file_name'])
         credential = storage.get()
         
         if credential is None or credential.invalid == True:
             extra_context['ga_data'] = { 'error' : 'authentication' }
         else:
             #get the data
             from utils import get_analytics_data
             http = httplib2.Http()
             extra_context['ga_data'] = get_analytics_data(credential.authorize(http))
         
     return super(YawdAdminSite, self).index(request, extra_context)