def index(self, query=None, radius=None, center=None, *args, **kwargs): if not query and not radius and not center: redirect('/societes-qui-recrutent') search_query = CompanyElastic().search() if query: search_query.query = self._compute_keyword_queries(query) try: geoloc_query = json.loads(center) coordinates = geoloc_query['coordinates'] lat, lon = (coordinates['lat'], coordinates['lon']) except (ValueError, TypeError): # One of the following case has occurred: # - Center wasn't a valid json string # - Radius couldn't be converted to float # Since both these information are required to set a geolocation # filter are required, we ignore it. pass else: search_query = self._apply_geolocation_filters( search_query, (lat, lon), radius if radius else 5.0) return dict(companies=PaginatedSearch(search_query), company_search_form=CompaniesResearchForm)
def _redirect(): redirect_to = '/societes-qui-recrutent' redirect_msg = u"Votre demande d'ajout d'entreprise a bien été " \ u"soumise à modération. L'entreprise sera ajoutée à " \ u"cette liste sous peu si elle satisfait les critères " \ u"attendus." redirect_status = 'ok' tg.flash(redirect_msg, redirect_status) redirect(redirect_to)
def _redirect(): redirect_to = "/societes-qui-recrutent" redirect_msg = ( u"Votre demande d'ajout d'entreprise a bien été " u"soumise à modération. L'entreprise sera ajoutée à " u"cette liste sous peu si elle satisfait les critères " u"attendus." ) redirect_status = "ok" tg.flash(redirect_msg, redirect_status) redirect(redirect_to)
def index(self, query=None, radius=None, center=None, sort_by=None, *args, **kwargs): if not query and not radius and not center: redirect('/jobs') search_query = JobElastic().search() relevance_sort = sort_by == 'scores' if query: keyword_queries = self._compute_keyword_queries(query) decay_functions = self._compute_decay_functions() search_query.query = Q('function_score', query=keyword_queries, functions=decay_functions) else: relevance_sort = False try: geoloc_query = json.loads(center) coordinates = geoloc_query['coordinates'] lat, lon = (coordinates['lat'], coordinates['lon']) except (ValueError, TypeError): # One of the following case has occurred: # - Center wasn't a valid json string # - Radius couldn't be converted to float # Since both these information are required to set a geolocation # filter are required, we ignore it. pass else: search_query = self._apply_geolocation_filters( search_query, (lat, lon), radius if radius else 5.0) date_sort = not relevance_sort if date_sort: search_query = self._apply_date_sort(search_query) return dict(sources=SOURCES, jobs=PaginatedSearch(search_query), job_offer_search_form=JobsResearchForm)
def index(self, query=None, radius=None, center=None, sort_by=None, *args, **kwargs): if not query and not radius and not center: redirect('/jobs') search_query = JobElastic().search() relevance_sort = sort_by == 'scores' if query: keyword_queries = self._compute_keyword_queries(query) decay_functions = self._compute_decay_functions() search_query.query = Q( 'function_score', query=keyword_queries, functions=decay_functions ) else: relevance_sort = False try: geoloc_query = json.loads(center) coordinates = geoloc_query['coordinates'] lat, lon = (coordinates['lat'], coordinates['lon']) except (ValueError, TypeError): # One of the following case has occurred: # - Center wasn't a valid json string # - Radius couldn't be converted to float # Since both these information are required to set a geolocation # filter are required, we ignore it. pass else: search_query = self._apply_geolocation_filters( search_query, (lat, lon), radius if radius else 5.0) date_sort = not relevance_sort if date_sort: search_query = self._apply_date_sort(search_query) return dict(sources=SOURCES, jobs=PaginatedSearch(search_query), job_offer_search_form=JobsResearchForm)
def index(self, query=None, radius=None, center=None, *args, **kwargs): if not query and not radius and not center: redirect("/societes-qui-recrutent") search_query = CompanyElastic().search() if query: search_query.query = self._compute_keyword_queries(query) try: geoloc_query = json.loads(center) coordinates = geoloc_query["coordinates"] lat, lon = (coordinates["lat"], coordinates["lon"]) except (ValueError, TypeError): # One of the following case has occurred: # - Center wasn't a valid json string # - Radius couldn't be converted to float # Since both these information are required to set a geolocation # filter are required, we ignore it. pass else: search_query = self._apply_geolocation_filters(search_query, (lat, lon), radius if radius else 5.0) return dict(companies=PaginatedSearch(search_query), company_search_form=CompaniesResearchForm)