コード例 #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,
	})
}