def faq(): context = { 'doorbell_tags': doorbell.get_tags('faq'), } return render_template('root/faq.html', **context)
def press(): context = { 'doorbell_tags': doorbell.get_tags('press'), } return render_template('root/press.html', **context)
def lbb_help(): context = { 'doorbell_tags': doorbell.get_tags('help'), } return render_template('root/help.html', **context)
def entreprises(): """ This view takes arguments as a query string. Expected arguments are those returned by get_parameters and expected by the selected office search form. """ fix_csrf_session() session['search_args'] = request.args location, named_location = get_location(request.args) occupation = request.args.get('occupation', '') if not occupation and 'j' in request.args: suggestion = search_util.build_job_label_suggestions(request.args['j'], size=1) occupation = suggestion[0]['occupation'] if suggestion else None rome = mapping_util.SLUGIFIED_ROME_LABELS.get(occupation) job_doesnt_exist = not rome # Build form form_kwargs = {key: val for key, val in list(request.args.items()) if val} form_kwargs['j'] = settings.ROME_DESCRIPTIONS.get(rome, occupation) if 'occupation' not in form_kwargs: form_kwargs['occupation'] = occupation if not form_kwargs.get('l') and named_location: # Override form location only if it is not available (e.g when user has # removed it from the url) form_kwargs['l'] = named_location.name if location: form_kwargs['lat'] = location.latitude form_kwargs['lon'] = location.longitude form = make_company_search_form(**form_kwargs) # Render different template if it's an ajax call template = 'search/results.html' if not request.is_xhr else 'search/results_content.html' activity_log_properties = dict( emploi=occupation, localisation={ 'nom': named_location.name if named_location else None, 'ville': named_location.city if named_location else None, 'codepostal': named_location.zipcode if named_location else None, 'latitude': location.latitude if location else None, 'longitude': location.longitude if location else None, }, ) # Stop here in case of invalid arguments if not form.validate() or job_doesnt_exist: log_search_activity(activity_log_properties) return render_template(template, job_doesnt_exist=job_doesnt_exist, form=form) # Convert request arguments to fetcher parameters parameters = get_parameters(request.args) # Fetch offices and alternatives fetcher = search_util.HiddenMarketFetcher( location, romes=[rome], distance=parameters['distance'], travel_mode=parameters['travel_mode'], duration=parameters['duration'], sort=parameters['sort'], from_number=parameters['from_number'], to_number=parameters['to_number'], public=parameters.get('public'), headcount=parameters['headcount'], naf=parameters['naf'], naf_codes=None, aggregate_by=['naf'], departments=None, ) alternative_rome_descriptions = [] naf_codes_with_descriptions = [] offices = [] office_count = 0 alternative_distances = {} # Aggregations offices, aggregations = fetcher.get_offices(add_suggestions=True) office_count = fetcher.office_count alternative_distances = fetcher.alternative_distances alternative_rome_descriptions = fetcher.get_alternative_rome_descriptions() # If a filter or more are selected, the aggregations returned by fetcher.get_offices() # will be filtered too... To avoid that, we are doing additionnal calls (one by filter activated) if aggregations: fetcher.update_aggregations(aggregations) # Generates values for the NAF filter # aggregations could be empty if errors or empty results if aggregations: for naf_aggregate in aggregations['naf']: naf_description = '%s (%s)' % (settings.NAF_CODES.get( naf_aggregate["code"]), naf_aggregate["count"]) naf_codes_with_descriptions.append( (naf_aggregate["code"], naf_description)) duration_filter_enabled = fetcher.duration is not None # Pagination. pagination_manager = pagination.PaginationManager( office_count, fetcher.from_number, fetcher.to_number, request.full_path, ) current_page = pagination_manager.get_current_page() # Anticipate future calls by pre-computing duration-related searches if location: precompute.isochrones((location.latitude, location.longitude)) form.naf.choices = [('', 'Tous les secteurs')] + sorted( naf_codes_with_descriptions, key=lambda t: t[1]) form.validate() canonical_url = get_canonical_results_url( named_location.zipcode, named_location.city, occupation) if named_location else '' context = { 'alternative_distances': alternative_distances, 'alternative_rome_descriptions': alternative_rome_descriptions, 'canonical_url': canonical_url, 'companies': list(offices), 'companies_per_page': pagination.OFFICES_PER_PAGE, 'company_count': office_count, 'distance': fetcher.distance, 'doorbell_tags': doorbell.get_tags('results'), 'form': form, 'headcount': fetcher.headcount, 'job_doesnt_exist': False, 'naf': fetcher.naf, 'location': location, 'city_name': named_location.city if named_location else '', 'location_name': named_location.name if named_location else '', 'page': current_page, 'pagination': pagination_manager, 'rome_code': rome, 'rome_description': settings.ROME_DESCRIPTIONS.get(rome, ''), 'show_favorites': True, 'sort': fetcher.sort, 'tile_server_url': settings.TILE_SERVER_URL, 'travel_mode': fetcher.travel_mode, 'travel_modes': maps_constants.TRAVEL_MODES, 'travel_modes_french': maps_constants.TRAVEL_MODES_FRENCH, 'duration_filter_enabled': duration_filter_enabled, 'user_favs_as_sirets': UserFavoriteOffice.user_favs_as_sirets(current_user), } activity_log_properties['distance'] = fetcher.distance activity_log_properties['effectif'] = fetcher.headcount activity_log_properties['tri'] = fetcher.sort activity_log_properties['naf'] = fetcher.naf activity_log_sirets = [office.siret for office in offices] activity.log_search(sirets=activity_log_sirets, count=office_count, page=current_page, **activity_log_properties) return render_template(template, **context)