예제 #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
파일: home.go 프로젝트: Cloakaac/core
func ShowCharacterCreate(res http.ResponseWriter, req *http.Request, base *BaseController) {
	csrf_token := GenerateToken(12)
	base.Session.SetValue("csrf", csrf_token)
	towns, err := models.GetTowns()
	if err != nil {
		http.Error(res, "Error while getting town list", 500)
		return
	}
	r := &CreateCharacterResponse{towns, "account-manage", csrf_token, base.Session.GetFlashes("error")}
	views.Parser.ExecuteTemplate(res, "create_character.html", r)
}
예제 #3
0
파일: admin.go 프로젝트: Cloakaac/core
func ShowAdminTowns(res http.ResponseWriter, req *http.Request, base *BaseController) {
	// TODO: add remove town
	success := base.Session.GetFlashes("success")
	towns, err := models.GetTowns()
	if err != nil {
		http.Error(res, "Error while getting town list: "+err.Error(), 500)
		return
	}
	views.Parser.ExecuteTemplate(res, "admin_towns.html", &AdminTownsResponse{
		towns,
		success,
	})
}
예제 #4
0
파일: community.go 프로젝트: Cloakaac/core
func ShowHouses(res http.ResponseWriter, req *http.Request, base *BaseController) {
	csrf_token := GenerateToken(12)
	base.Session.SetValue("csrf", csrf_token)
	random_town := models.RandomTown()
	house_list, err := models.GetHouseList(random_town.Town_id)
	if err != nil {
		http.Error(res, "Error while getting house list: "+err.Error(), 500)
		return
	}
	towns, err := models.GetTowns()
	if err != nil {
		http.Error(res, "Error while getting town list:"+err.Error(), 500)
		return
	}
	views.Parser.ExecuteTemplate(res, "houses.html", &HousesResponse{
		house_list,
		towns,
		random_town,
		csrf_token,
	})
}