Esempio n. 1
0
def search_place(request):
    # get place name
    data_from_get = request.GET
    if data_from_get.has_key("place_name"):
        place_name = data_from_get.get("place_name")
        continents = Continent.objects(name__iexact=place_name)
        countries = Country.objects(name__iexact=place_name)
        provinces = Province.objects(name__iexact=place_name)
        cities = City.objects(name__iexact=place_name)
        places = gathering(list(continents) + list(countries) + list(provinces) + list(cities))
        return render_json({"status": SUCCESS, "places": places})
    else:
        return render_json({"status": FAIL})
Esempio n. 2
0
def retrieve_place(request):
    data_from_post = request.GET
    if data_from_post.has_key("place_type") and data_from_post.has_key("object_id"):
        place_type = data_from_post.get("place_type")
        object_id = data_from_post.get("object_id")
        # have to work on details
        if place_type == "Continent":
            continent = Continent.objects.get(id=object_id)
            countries = Country.objects(continents=continent)
            return render_to_response("continent.html", {"continent": continent, "countries": countries})
        elif place_type == "Country":
            country = Country.objects.get(id=object_id)
            provinces = Province.objects(country=country)
            return render_to_response("country.html", {"country": country, "provinces": provinces})
        elif place_type == "Province":
            province = Province.objects.get(id=object_id)
            return render_to_response("province.html", {"province": province})
        elif place_type == "City":
            city = City.objects.get(id=object_id)
            return render_to_response("city.html", {"city": city})
        else:
            return render_to_response("home.html")
    else:
        return render_to_response("error.html")