def create_continent(request):
    """ create a continent throught post data """
    data = request.POST
    print data
    if data.has_key("continent_name"):
        continent_name = data.get("continent_name")
        try:
            c = Continent(name=continent_name)
            c.save()
            if data.has_key("parent"):
                parent = data.get("parent")
                if not parent == "-1":
                    try:
                        parent_continent = Continent.objects.get(id=parent)
                        c.parent = parent_continent
                        c.save()
                        # also reverse for children saving
                    except Exception as e:
                        print e
            if data.has_key("lat") and data.has_key("lon"):
                lat = data.get("lat")
                lon = data.get("lon")
                if not lat == "" and not lon == "":
                    geo_center = [float(lat), float(lon)]
                    print geo_center
                    try:
                        c.geo_center = geo_center
                        c.save()
                    except Exception as e:
                        print e
        except Exception as e:
            print e
    return redirect("/datamanage/continent/")
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})