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, }) }
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) }
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, }) }
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, }) }