예제 #1
0
파일: community.go 프로젝트: Cloakaac/core
func ShowTownHouses(res http.ResponseWriter, req *http.Request, base *BaseController) {
	town := req.PostFormValue("town")
	town_info := models.GetTownByName(town)
	if town_info.Name == "" {
		http.Error(res, "Unknown town name", 500)
		return
	}
	towns, err := models.GetTowns()
	if err != nil {
		http.Error(res, "Error while getting town list:"+err.Error(), 500)
		return
	}
	house_list, err := models.GetHouseList(town_info.Town_id)
	csrf_token := GenerateToken(12)
	base.Session.SetValue("csrf", csrf_token)
	views.Parser.ExecuteTemplate(res, "houses.html", &HousesResponse{
		house_list,
		towns,
		&models.Town{
			0,
			town,
			0,
		},
		csrf_token,
	})
}
예제 #2
0
파일: admin.go 프로젝트: Cloakaac/core
func ShowAdminTownEdit(res http.ResponseWriter, req *http.Request, base *BaseController) {
	name, err := url.QueryUnescape(mux.Vars(req)["name"])
	if err != nil {
		http.Error(res, "Error while getting town name: "+err.Error(), 500)
		return
	}
	town_info := models.GetTownByName(name)
	views.Parser.ExecuteTemplate(res, "admin_towns_edit.html", &AdminTownsEditResponse{
		town_info,
	})
}