Beispiel #1
0
    def test_hotel_create(self):
        city = City()
        city.continent = 1
        city.city_zh = "海南"
        city.city_en = "HaiNan"
        city.save()

        params = {}
        params["city"] = 1
        params["name"] = "北京饭店"
        params["star"] = 5
        params["desc"] = "五星级饭店"
        response = self.c.post("/common/hotel/create", params)
        self.assertEqual(response.status_code, 302)
Beispiel #2
0
def create(request):
    if request.method == "POST":
        continent = int(request.REQUEST.get("continent", 1))
        city_zh = request.REQUEST.get("city_zh", "")
        city_en = request.REQUEST.get("city_en", "")

        city = City()
        city.continent = continent
        city.city_zh = city_zh
        city.city_en = city_en
        try:
            city.save()
            return HttpResponseRedirect("/common/city/index")
        except:
            return {}
    return {}