def get_query(self, q, request): """ Répondre à la requête """ fields = ['name', 'body', 'url', 'email'] final_query = search_query(unidecode(q), fields) items = Comment.objects.filter(final_query).distinct().order_by( '-time')[0:12] return items
def get_query(self, q, request): """ Répondre à la requête """ fields = ['title', 'teaser', 'tags__name'] final_query = search_query(unidecode(q), fields) items = Content.objects.by_request(request).filter( final_query).distinct().order_by('-updated')[0:12] return items
def get_query(self, q, request): """ Renvoyer les villes correspondant à la requête """ fields = ['name', 'street', 'city__alternates__ascii'] final_query = search_query(unidecode(q), fields) items = Venue.objects.filter(final_query).distinct().order_by( 'name')[0:12] return items
def get_query(self, q, request): """ Renvoyer les villes correspondant à la requête """ items_cache = cache.get(self.CACHE_KEY.format(q), None) if items_cache is not None: return items_cache fields = ['alternates__ascii', 'parent__parent__alternates__ascii'] final_query = search_query(unidecode(q), fields) final_query = models.Q(city=True) & final_query items = City.objects.filter(final_query).distinct().order_by( '-population')[0:12] cache.set(self.CACHE_KEY.format(q), items, 1800) return items
def get_query(self, q, request): """ Renvoyer les villes correspondant à la requête """ q = unidecode(q).strip().lower() items_cache = cache.get(self.CACHE_KEY.format(q), None) if items_cache is not None: return items_cache fields = ['alternates__ascii', 'country__code2'] final_query = search_query(q, fields) final_query = models.Q(city=True, country__public=True) & final_query items = City.objects.filter(final_query).distinct().order_by( '-population')[0:10] cache.set(self.CACHE_KEY.format(q), list(items), 1800) return items
def get_query(self, q, request): """ Renvoyer le queryset de résultat de recherche """ fields = ['name'] final_query = search_query(q, fields) return Group.objects.filter(final_query).order_by('name')
def text_search(self, expression, **kwargs): """ Renvoyer les messages contenant une expression """ return search_query(expression, ['text'], self.filter(**kwargs))
def get_query(self, q, request): """ Répondre à la requête """ fields = ['title', 'description', 'image'] final_query = search_query(q, fields) return Picture.objects.by_request(request).filter( final_query).order_by('-id')[0:12]
def get_query(self, q, request): """ Renvoyer le queryset de résultats pour l'expression """ fields = ['name', 'codename'] final_query = search_query(q, fields) return Permission.objects.filter(final_query).order_by('name')
def get_query(self, q, request): """ Renvoyer un queryset de résultats pour l'expression """ fields = ['username', 'name', 'email'] final_query = search_query(q, fields) return get_user_model().objects.by_request(request).filter( final_query).order_by('username')[0:12]
def get_query(self, q, request): """ Renvoyer les objets correspondant à la requête """ fields = ['short_name', 'translations__name'] final_query = search_query(unidecode(q), fields) items = Label.objects.filter(final_query).distinct()[0:12] return items