def map_admin(request, entity_type=None): form_model = get_form_model_by_entity_type( get_database_manager(request.user), [entity_type.lower()]) entity_preference = get_entity_preference(get_db_manager("public"), _get_organization_id(request), entity_type) filters_in_entity_preference = [] details_in_entity_preference = [] specials_in_entity_preference = [] if entity_preference is not None: filters_in_entity_preference = entity_preference.filters details_in_entity_preference = entity_preference.details specials_in_entity_preference = entity_preference.specials filters = _build_filterable_fields(form_model.form_fields, filters_in_entity_preference) details = _build_details(form_model.form_fields, details_in_entity_preference) specials = _build_specials(form_model.form_fields, specials_in_entity_preference) return render_to_response('entity/map_edit.html', { "entity_type": entity_type, "form_code": form_model.form_code, "filters": json.dumps(filters), "details": json.dumps(details), "specials": json.dumps(specials) }, context_instance=RequestContext(request))
def share_token(request, entity_type): manager = get_db_manager("public") organization_id = _get_organization_id(request) entity_preference = get_entity_preference(manager, organization_id, entity_type) if entity_preference: return HttpResponse(json.dumps({"token": entity_preference.share_token})) entity_preference = save_entity_preference(manager, organization_id, entity_type) return HttpResponse(json.dumps({"token": entity_preference.share_token}))
def map_data(request, entity_type=None, entity_preference=None): manager = get_database_manager(request.user) form_model = get_form_model_by_entity_type(manager, [entity_type.lower()]) entity_preference = entity_preference or get_entity_preference(get_db_manager("public"), _get_organization_id(request), entity_type) details = entity_preference.details if entity_preference is not None else [] specials = entity_preference.specials if entity_preference is not None else [] fallback_location = entity_preference.fallback_location if entity_preference is not None else {} return render_to_response('map.html', { "entity_type": entity_type, "fallback_location": fallback_location, "filters": [] if entity_preference is None else _get_filters(form_model, entity_preference.filters), "idnr_filters": [] if entity_preference is None else _get_uniqueid_filters(form_model, entity_preference.filters, manager), "geo_jsons": geo_jsons(manager, entity_type, request.GET, details, specials), "mapbox_api_key": get_mapbox_api_key(request.META['HTTP_HOST']) }, context_instance=RequestContext(request))
def map_data(request, entity_type=None, entity_preference=None, map_view = False): manager = get_database_manager(request.user) form_model = get_form_model_by_entity_type(manager, [entity_type.lower()]) entity_preference = entity_preference or get_entity_preference(get_db_manager("public"), _get_organization_id(request), entity_type) details = entity_preference.details if entity_preference is not None else [] specials = entity_preference.specials if entity_preference is not None else [] total_in_label = entity_preference.total_in_label if entity_preference is not None else False entity_fields = manager.view.registration_form_model_by_entity_type(key=[entity_type], include_docs=True)[0]["doc"]["json_fields"] forward_filters, reverse_filters = _transform_filters(dict(request.GET), entity_fields) fallback_location = entity_preference.fallback_location if entity_preference is not None and not any(forward_filters) and not any(reverse_filters) else {} return render_to_response('map.html', { "entity_type": entity_type, "fallback_location": fallback_location, "filters": [] if entity_preference is None else _get_filters(form_model, entity_preference.filters, entity_preference.remove_options), "idnr_filters": [] if entity_preference is None else _get_uniqueid_filters(form_model, entity_preference.filters, manager, entity_preference.remove_options), "geo_jsons": geo_jsons(manager, entity_type, request.GET, details, specials, map_view, total_in_label), "mapbox_api_key": get_mapbox_api_key(request.META['HTTP_HOST']) }, context_instance=RequestContext(request))