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