Exemplo n.º 1
0
def leagues_list():
    try:
        q = urlunquote(request.params["q"])
    except KeyError:
        is_search = False
    else:
        is_search = True

    db = request.db["football"]
    if is_search:
        item_count = football.get_leagues_count(db, dict={"name": q})
        page = Paginator.parse_page(request.params)
        pager = pager = Paginator(item_count, page, per_page=10)
        leagues = football.get_leagues(db, pager, dict={"name": q}, fixtures=False, teams=False)

    else:
        item_count = football.get_leagues_count(db)
        page = Paginator.parse_page(request.params)
        pager = pager = Paginator(item_count, page, per_page=10)
        leagues = football.get_leagues(db, pager, fixtures=False, teams=False)

    return dict(
        leagues=leagues,
        pager=pager,
        is_search=is_search,
        base_path=i18n_url("leagues:list"),
        view=request.params.get("view"),
    )
Exemplo n.º 2
0
def content_list():
    """ Show list of content """
    # parse search query
    query = urlunquote(request.params.get('q', '')).strip()
    # parse language filter
    default_lang = request.user.options.get('content_language', None)
    lang = request.params.get('language', default_lang)
    request.user.options['content_language'] = lang
    # parse content type filter
    content_type = request.params.get('content_type')
    if content_type not in metadata.CONTENT_TYPES:
        content_type = None
    # parse pagination params
    page = Paginator.parse_page(request.params)
    per_page = Paginator.parse_per_page(request.params)
    # get content list filtered by above parsed filter params
    item_count = content_count(query, lang, content_type)
    pager = Paginator(item_count, page, per_page)
    offset, limit = pager.items
    metas = filter_content(query,
                           lang,
                           content_type,
                           offset=offset,
                           limit=limit)
    return dict(metadata=metas,
                pager=pager,
                vals=request.params.decode(),
                query=query,
                chosen_lang=lang,
                content_types=metadata.CONTENT_TYPES,
                chosen_content_type=content_type,
                base_path=i18n_url('content:list'),
                view=request.params.get('view'))
Exemplo n.º 3
0
def content_list():
    """ Show list of content """
    # parse search query
    query = urlunquote(request.params.get('q', '')).strip()
    # parse language filter
    default_lang = request.user.options.get('content_language', None)
    lang = request.params.get('language', default_lang)
    request.user.options['content_language'] = lang
    # parse content type filter
    content_type = request.params.get('content_type')
    if content_type not in metadata.CONTENT_TYPES:
        content_type = None
    # parse pagination params
    page = Paginator.parse_page(request.params)
    per_page = Paginator.parse_per_page(request.params)
    # get content list filtered by above parsed filter params
    item_count = content_count(query, lang, content_type)
    pager = Paginator(item_count, page, per_page)
    offset, limit = pager.items
    metas = filter_content(query,
                           lang,
                           content_type,
                           offset=offset,
                           limit=limit)
    return dict(metadata=metas,
                pager=pager,
                vals=request.params.decode(),
                query=query,
                chosen_lang=lang,
                content_types=metadata.CONTENT_TYPES,
                chosen_content_type=content_type,
                base_path=i18n_url('content:list'),
                view=request.params.get('view'))
def get_descendants(path):
    span = request.app.config['changelog.span']
    count = get_descendant_count(path, span)
    manager = Manager(request.app.supervisor)
    # parse pagination params
    page = Paginator.parse_page(request.params)
    per_page = Paginator.parse_per_page(request.params)
    pager = Paginator(count, page, per_page)
    (offset, limit) = pager.items
    (_, _, _, files, _) = manager.list_descendants(path,
                                                   offset=offset,
                                                   limit=limit,
                                                   order='-create_time',
                                                   span=span,
                                                   entry_type=0,
                                                   show_hidden=False)
    return dict(pager=pager, files=files)