コード例 #1
0
 def index(self):
     try:
         query = query_for(model.Package)
         query.run({'q': '*:*'})
         c.package_count = query.count
         c.latest_packages = get.current_package_list_with_resources(
             {'model': model, 'user': c.user},
             {'limit': 5}
         )  
     except SearchError, se:
         c.package_count = 0
         c.latest_packages = []
コード例 #2
0
ファイル: home.py プロジェクト: AdamJensen-dk/ckan-drupal
    def index(self):
        cache_key = self._home_cache_key()
        etag_cache(cache_key)

        query = query_for(model.Package)
        query.run(query='*:*', facet_by=g.facets,
                  limit=0, offset=0, username=c.user)
        c.facets = query.facets
        c.fields = []
        c.package_count = query.count
        c.latest_packages = current_package_list_with_resources({'model': model,
                                                                'user': c.user,
                                                                'limit': 5},
                                                                 {})      
        return render('home/index.html', cache_key=cache_key,
                cache_expire=cache_expires)
コード例 #3
0
def current_package_list_with_resources_minimal(context, data_dict):
    '''Return a list of the site's datasets (packages) and their resources.

    The list is sorted most-recently-modified first.

    :param limit: if given, the list of datasets will be broken into pages of
        at most ``limit`` datasets per page and only one page will be returned
        at a time (optional)
    :type limit: int
    :param offset: when ``limit`` is given, the offset to start
        returning packages from
    :type offset: int
    :param page: when ``limit`` is given, which page to return,
        Deprecated: use ``offset``
    :type page: int

    :rtype: list of dictionaries

    '''
    results = get.current_package_list_with_resources(context, data_dict)

    if check_logged_in(context):
        for result in results:
            fulltext = _get_fulltext(result['id'])
            if fulltext:
                fulltext_dict = {
                    'key': 'full_text_search',
                    'value': fulltext.text
                }
                result['extras'].append(fulltext_dict)
        return results

    new_packages = []
    for result in results:
        new_package = _del_extra_field_from_dict(result)
        new_package = _del_main_field_from_dict(new_package)
        new_packages.append(new_package)

    return new_packages
コード例 #4
0
    def index(self):
        cache_key = self._home_cache_key()
        etag_cache(cache_key)

        query = query_for(model.Package)
        query.run(query='*:*',
                  facet_by=g.facets,
                  limit=0,
                  offset=0,
                  username=c.user)
        c.facets = query.facets
        c.fields = []
        c.package_count = query.count
        c.latest_packages = current_package_list_with_resources(
            {
                'model': model,
                'user': c.user,
                'limit': 5
            }, {})
        return render('home/index.html',
                      cache_key=cache_key,
                      cache_expire=cache_expires)
コード例 #5
0
def current_package_list_with_resources_minimal(context, data_dict):
    '''Return a list of the site's datasets (packages) and their resources.

    The list is sorted most-recently-modified first.

    :param limit: if given, the list of datasets will be broken into pages of
        at most ``limit`` datasets per page and only one page will be returned
        at a time (optional)
    :type limit: int
    :param offset: when ``limit`` is given, the offset to start
        returning packages from
    :type offset: int
    :param page: when ``limit`` is given, which page to return,
        Deprecated: use ``offset``
    :type page: int

    :rtype: list of dictionaries

    '''
    results = get.current_package_list_with_resources(context, data_dict)
    
    if check_logged_in(context):
        for result in results:
            fulltext = _get_fulltext(result['id'])
            if fulltext:
                fulltext_dict = { 'key': 'full_text_search',
                                  'value': fulltext.text
                                }
                result['extras'].append(fulltext_dict)  
        return results
    
    new_packages = []
    for result in results:
        new_package = _del_extra_field_from_dict(result)
        new_package = _del_main_field_from_dict(new_package)
        new_packages.append(new_package)

    return new_packages