Esempio n. 1
0
File: forms.py Progetto: credis/pes
 def search(self):
     # First, store the SearchQuerySet received from other processing.
     sqs = super(ImportFacetedSearchForm, self).search()
     m = map(lambda x: models.get_model('pes_local', x), self.models)
     # print "models %s et self %s" % (m, self.models)
     # return only result not from the client site
     authority_home = get_hostname(get_current_request())
     sqs = sqs.exclude(uri__contains=authority_home)
     return sqs.models(*m)
Esempio n. 2
0
File: forms.py Progetto: credis/pes
    def search(self):
        # First, store the SearchQuerySet received from other processing.
        sqs = super(PESFacetedSearchForm, self).search()
        sqs = sqs.facet('zone').facet('category').facet('tags')  # .facet('modified')

        (point, city) = get_geoIP(get_current_request())

        self.fields['dist'].label = _(u'Distance max de %s' % city) #, get_current_request().META['REMOTE_ADDR']))

        if self.is_bound:
            if self.cleaned_data['dist']:
                max_dist = D(km=self.cleaned_data['dist'])
                sqs = sqs.dwithin('location', point, max_dist).distance('location', point).order_by('distance')

        return sqs