當前位置: 首頁>>代碼示例>>Python>>正文


Python FilterChain.make_url方法代碼示例

本文整理匯總了Python中ebpub.db.schemafilters.FilterChain.make_url方法的典型用法代碼示例。如果您正苦於以下問題:Python FilterChain.make_url方法的具體用法?Python FilterChain.make_url怎麽用?Python FilterChain.make_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ebpub.db.schemafilters.FilterChain的用法示例。


在下文中一共展示了FilterChain.make_url方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: bigmap_filter

# 需要導入模塊: from ebpub.db.schemafilters import FilterChain [as 別名]
# 或者: from ebpub.db.schemafilters.FilterChain import make_url [as 別名]
def bigmap_filter(request, slug):

    s = get_object_or_404(get_schema_manager(request), slug=slug, is_special_report=False)
    if not s.allow_charting:
        return HttpResponse(status=404)

    filter_sf_dict = _get_filter_schemafields(s)

    # Determine what filters to apply, based on path and/or query string.
    filterchain = FilterChain(request=request, schema=s)
    try:
        filterchain.update_from_request(filter_sf_dict)
        filters_need_more = filterchain.validate()
    except:
        logger.exception("Unhandled error")
        return HttpResponse(status=404)

    config = _decode_map_permalink(request, show_default_layers=False, filters=filterchain)

    new_url = filterchain.make_url(base_url=reverse("bigmap_filter", args=(slug,)))
    if new_url != request.get_full_path():
        return HttpResponseRedirect(new_url)

    # add in the filter layer
    base_url = reverse("ebpub-schema-filter-geojson", args=(slug,))
    layer_url = filterchain.make_url(base_url=base_url)
    custom_layer = {"url": layer_url, "params": {}, "title": "Custom Filter", "visible": True}
    config["layers"].append(custom_layer)

    if config["is_widget"]:
        return eb_render(request, "richmaps/embed_bigmap.html", {"map_config": simplejson.dumps(config, indent=2)})
    else:
        return eb_render(request, "richmaps/bigmap.html", {"map_config": simplejson.dumps(config, indent=2)})
開發者ID:horshacktest,項目名稱:openblock,代碼行數:35,代碼來源:views.py

示例2: bigmap_filter

# 需要導入模塊: from ebpub.db.schemafilters import FilterChain [as 別名]
# 或者: from ebpub.db.schemafilters.FilterChain import make_url [as 別名]
def bigmap_filter(request, slug, args_from_url):
    
    s = get_object_or_404(get_schema_manager(request), slug=slug, is_special_report=False)
    if not s.allow_charting:
        return HttpResponse(status=404)

    filter_sf_list = list(SchemaField.objects.filter(schema__id=s.id, is_filter=True).order_by('display_order'))
    textsearch_sf_list = list(SchemaField.objects.filter(schema__id=s.id, is_searchable=True).order_by('display_order'))

    # Use SortedDict to preserve the display_order.
    filter_sf_dict = SortedDict([(sf.name, sf) for sf in filter_sf_list] + [(sf.name, sf) for sf in textsearch_sf_list])

    # Determine what filters to apply, based on path and/or query string.
    filterchain = FilterChain(request=request, schema=s)
    try:
        filterchain.update_from_request(args_from_url, filter_sf_dict)
        filters_need_more = filterchain.validate()
    except:
        return HttpResponse(status=404)
        
    config = _decode_map_permalink(request, show_default_layers=False, filters=filterchain)

    new_url = filterchain.make_url(base_url=reverse('bigmap_filter', args=(slug,)))
    if new_url != request.get_full_path():
        return HttpResponseRedirect(new_url)    

    
    # add in the filter layer
    base_url = reverse('ebpub-schema-filter-geojson', args=(slug,))
    layer_url = filterchain.make_url(base_url=base_url)
    custom_layer = {
        'url': layer_url,
        'params': {},
        'title': "Custom Filter",
        'visible': True
    }
    config['layers'].append(custom_layer)



    if config['is_widget']: 
        return eb_render(request, 'richmaps/embed_bigmap.html', {
            'map_config': simplejson.dumps(config, indent=2)
        })
    else:         
        return eb_render(request, 'richmaps/bigmap.html', {
            'map_config': simplejson.dumps(config, indent=2)
        })
開發者ID:UniversityDailyKansan,項目名稱:openblock,代碼行數:50,代碼來源:views.py

示例3: get_featured_lookups_by_schema

# 需要導入模塊: from ebpub.db.schemafilters import FilterChain [as 別名]
# 或者: from ebpub.db.schemafilters.FilterChain import make_url [as 別名]
def get_featured_lookups_by_schema(context):
    """
    Get all :ref:`featured_lookups` names and URLs for them; 
    puts in the context as
    'featured_lookups', a mapping grouped by schema.

    Example:

    .. code-block:: html+django

        {% get_featured_lookups_by_schema %}
        {% for schema, lookups in featured_lookups.items %}
           <ul>{{ schema }}
            {% for info in lookups %}
              <a href="{{ info.url }}">{{ info.lookup }}</a>
               ...
            {% endfor %}
        {% endfor %}
    """
    lookups = {}
    for lookup in Lookup.objects.filter(featured=True).select_related():
        sf = lookup.schema_field
        schema = sf.schema
        filters = FilterChain(schema=schema)
        filters.add(sf, lookup)
        info = {"lookup": lookup.name, "url": filters.make_url()}
        lookups.setdefault(schema.slug, []).append(info)
    context["featured_lookups"] = lookups
    return u""
開發者ID:kultus,項目名稱:openblock,代碼行數:31,代碼來源:eb.py

示例4: bigmap_filter

# 需要導入模塊: from ebpub.db.schemafilters import FilterChain [as 別名]
# 或者: from ebpub.db.schemafilters.FilterChain import make_url [as 別名]
def bigmap_filter(request, slug):
    """
    Big map with just one Schema (identified by ``slug``) enabled by
    default.
    """
    s = get_object_or_404(get_schema_manager(request), slug=slug, is_special_report=False)
    if not s.allow_charting:
        return HttpResponse(status=404)

    filter_sf_dict = _get_filter_schemafields(s)

    # Determine what filters to apply, based on path and/or query string.
    filterchain = FilterChain(request=request, schema=s)
    try:
        filterchain.update_from_request(filter_sf_dict)
        filters_need_more = filterchain.validate()
    except:
        logger.exception("Unhandled error")
        return HttpResponse(status=404)

    config = _decode_map_permalink(request, show_default_layers=False, filters=filterchain)


    # TODO: This can leave in permalink params eg. 'i', even if there
    # is also 'ids', because it doesn't recognize those as being the
    # same.
    new_url = filterchain.make_url(base_url=reverse('bigmap_filter', args=(slug,)))
    if new_url != request.get_full_path():
        return HttpResponseRedirect(new_url)

    if config['is_widget']:
        return eb_render(request, 'richmaps/embed_bigmap.html', {
            'map_config': simplejson.dumps(config, indent=2)
        })
    else:
        return eb_render(request, 'richmaps/bigmap.html', {
            'map_config': simplejson.dumps(config, indent=2)
        })
開發者ID:DotNetWebs,項目名稱:openblock,代碼行數:40,代碼來源:views.py

示例5: render

# 需要導入模塊: from ebpub.db.schemafilters import FilterChain [as 別名]
# 或者: from ebpub.db.schemafilters.FilterChain import make_url [as 別名]
 def render(self, context):
     filterchain = self.filterchain_var.resolve(context)
     if isinstance(filterchain, FilterChain):
         schema = filterchain.schema
     elif isinstance(filterchain, Schema):
         schema = filterchain
         # Note, context['request'] only works if
         # django.core.context_processors.request is enabled in
         # TEMPLATE_CONTEXT_PROCESSORS.
         filterchain = FilterChain(context=context, request=context['request'],
                                   schema=schema)
     else:
         raise template.TemplateSyntaxError(
             "%r is neither a FilterChain nor a Schema" % filterchain)
     removals = [r.resolve(context) for r in self.removals]
     if self.clear:
         filterchain = filterchain.copy()
         filterchain.clear()
     additions = []
     for key, values in self.additions:
         key = key.resolve(context)
         additions.append((key, [v.resolve(context) for v in values]))
     schema = filterchain.schema
     return filterchain.make_url(additions=additions, removals=removals)
開發者ID:UniversityDailyKansan,項目名稱:openblock,代碼行數:26,代碼來源:eb_filter.py

示例6: _decode_map_permalink

# 需要導入模塊: from ebpub.db.schemafilters import FilterChain [as 別名]
# 或者: from ebpub.db.schemafilters.FilterChain import make_url [as 別名]

#.........這裏部分代碼省略.........
            'title':  schema.plural_name,
            'url':    reverse('map_items_json'),
            'params': {'type': schema.slug, 'limit': 1000,
                       'startdate': api_startdate,
                       'enddate': api_enddate},
            'bbox': False,
            'visible': visible
        })

    # Explicit filtering by ID.
    ids = params.get('i') or u''
    ids = [i.strip() for i in re.split(r'[^\d]+', ids)
           if i.strip()]
    if ids:
        show_custom_layer = True
        if filters is None:
            filters = FilterChain(request)
        filters.replace('id', *ids)


    # 'Custom' layer. This is a catch-all for all filtering
    # that isn't just enabling a default layer with the default
    # date range.
    # Not visible unless there is something like that to show.
    if filters and sorted(filters.keys()) not in ([],
                                                  ['date'],
                                                  ['date', 'schema'],
                                                  ['schema']):
        show_custom_layer = True

    if filters is not None:
        # Don't inspect filters['schema']; that's already covered by schemas above.
        base_url = reverse('map_items_json')
        layer_url = filters.make_url(base_url=base_url)
        # Quick ugly hacks to make the itemquery api happy.
        # Hooray proliferation of spellings.
        layer_url = layer_url.replace('locations=', 'locationid=')
        layer_url = layer_url.replace('start_date=', 'startdate=')
        layer_url = layer_url.replace('end_date=', 'enddate=')

        if 'schema' in filters:
            # Normally, filters.make_url() captures the schema in the
            # path part of the URL. But map_items_json doesn't,
            # so we add a query parameter.
            params = {'type': [s.slug for s in filters['schema'].schemas]}
        else:
            params = {}
        custom_layer = {
            'url': layer_url,
            'params': params,
            'title': u"Custom Filter",
            'visible': show_custom_layer,
            'id': 'c1',
            }
        layers.append(custom_layer)

    is_widget = params.get('x', None) is not None
    controls = {}
    control_list = params.get("v", None)
    if control_list is not None: 
        if 'l' in control_list: 
            controls['layers'] = True
        if 'h' in control_list: 
            controls['headline_list'] = True
        if 'p' in control_list: 
            controls['permalink'] = True
開發者ID:DotNetWebs,項目名稱:openblock,代碼行數:70,代碼來源:views.py

示例7: item_date_url

# 需要導入模塊: from ebpub.db.schemafilters import FilterChain [as 別名]
# 或者: from ebpub.db.schemafilters.FilterChain import make_url [as 別名]
 def item_date_url(self):
     from ebpub.db.schemafilters import FilterChain
     chain = FilterChain(schema=self.schema)
     chain.add('date', self.item_date)
     return chain.make_url()
開發者ID:mesrut,項目名稱:openblock,代碼行數:7,代碼來源:models.py


注:本文中的ebpub.db.schemafilters.FilterChain.make_url方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。