コード例 #1
0
 def render(self, request, place, content, context, *args, **kwargs):
     if not isinstance(content, Collection):
         return ''
     searchers = content.searcher_set.all()
     forms_search = []
     for search in searchers:
         if not search.options:
             continue
         form_search_class = modelform_factory(
             model=search.content_type.model_class(), form=SearcherForm)
         data = None
         if request.GET.get('__searcher'):
             data = request.GET
         fields = get_fields(search)
         if not fields:
             continue
         form_search_class.base_fields = get_fields(search)
         form_search = form_search_class(data=data,
                                         is_admin=False,
                                         search=search)
         if data:
             form_search.is_valid()
         forms_search.append(form_search)
     return self.render_block(request,
                              template_name='smartsearch/block_search.html',
                              block_title=_('Searchers'),
                              context={'forms_search': forms_search})
コード例 #2
0
ファイル: blocks.py プロジェクト: creativify/merengueproj
 def render(self, request, place, content, context, *args, **kwargs):
     if not isinstance(content, Collection):
         return ''
     searchers = content.searcher_set.all()
     forms_search = []
     for search in searchers:
         if not search.options:
             continue
         form_search_class = modelform_factory(model=search.content_type.model_class(),
                                               form=SearcherForm)
         data = None
         if request.GET.get('__searcher'):
             data = request.GET
         fields = get_fields(search)
         if not fields:
             continue
         form_search_class.base_fields = get_fields(search)
         form_search = form_search_class(data=data, is_admin=False, search=search)
         if data:
             form_search.is_valid()
         forms_search.append(form_search)
     return self.render_block(request, template_name='smartsearch/block_search.html',
                              block_title=_('Searchers'),
                              context={'forms_search': forms_search})
コード例 #3
0
def search_is_valid(request, searcher_id):
    search = Searcher.objects.get(pk=searcher_id)
    model = search.content_type.model_class()
    form_search_class = modelform_factory(model=model, form=SearcherForm)
    data = request.GET
    form_search_class.base_fields = get_fields(search)
    form_search = form_search_class(data=data, is_admin=False, search=search)

    __full_path = "%s?" % data.get('__path')
    del data['__path']
    __full_path = "%s%s" % (__full_path, request.GET.urlencode())

    if not form_search.is_valid():
        __full_path = "%s&__ignore_filters=1" % __full_path
    return HttpResponseRedirect(__full_path)
コード例 #4
0
ファイル: views.py プロジェクト: creativify/merengueproj
def search_is_valid(request, searcher_id):
    search = Searcher.objects.get(pk=searcher_id)
    model = search.content_type.model_class()
    form_search_class = modelform_factory(model=model,
                                          form=SearcherForm)
    data = request.GET
    form_search_class.base_fields = get_fields(search)
    form_search = form_search_class(data=data, is_admin=False, search=search)

    __full_path = "%s?" % data.get('__path')
    del data['__path']
    __full_path = "%s%s" % (__full_path, request.GET.urlencode())

    if not form_search.is_valid():
        __full_path = "%s&__ignore_filters=1" % __full_path
    return HttpResponseRedirect(__full_path)