func EditPlant(ren render.Render, db *sql.DB, params martini.Params, t *template.TemplateData) { var plant_id string = params["id"] if plant_id != "new" { plant, err := repository.GetPlant(db, plant_id) if err != nil || plant == nil { t.SessionMessage.AddDanger("Failed to load plant.") ren.Redirect("/plant") return } id, _ := strconv.ParseInt(params["id"], 10, 64) plant.PopularNames.Names, err = repository.GetPopularNames(db, id, PLANT) t.Data = plant t.MediaList = getMediaList(db, PLANT, id) ren.HTML(200, "blah/plant/edit", t) } else { ren.HTML(200, "blah/plant/edit", nil) } }
func EditComponent(ren render.Render, db *sql.DB, params martini.Params, t *template.TemplateData) { var component_id string = params["id"] if component_id != "new" { component, err := repository.GetComponent(db, component_id) if err != nil || component == nil { t.SessionMessage.AddDanger("Failed to load component.") ren.Redirect("/component") return } t.Data = component id, _ := strconv.ParseInt(params["id"], 10, 64) t.MediaList = getMediaList(db, COMPONENT, id) ren.HTML(200, "blah/component/edit", t) } else { ren.HTML(200, "blah/component/edit", nil) } }
func EditInvertebrate(ren render.Render, db *sql.DB, params martini.Params, t *template.TemplateData) { var invertebrate_id string = params["id"] if invertebrate_id != "new" { invertebrate, err := repository.GetInvertebrate(db, invertebrate_id) if err != nil || invertebrate == nil { t.SessionMessage.AddDanger("Failed to load invertebrate.") ren.Redirect("/invertebrate") return } id, _ := strconv.ParseInt(params["id"], 10, 64) invertebrate.PopularNames.Names, err = repository.GetPopularNames(db, id, INVERTEBRATE) t.Data = invertebrate t.MediaList = getMediaList(db, INVERTEBRATE, id) ren.HTML(200, "blah/invertebrate/edit", t) } else { ren.HTML(200, "blah/invertebrate/edit", nil) } }
func EditCoral(ren render.Render, db *sql.DB, params martini.Params, t *template.TemplateData) { var coral_id string = params["id"] if coral_id != "new" { coral, err := repository.GetCoral(db, coral_id) if err != nil || coral == nil { t.SessionMessage.AddDanger("Failed to load coral.") ren.Redirect("/coral") return } id, _ := strconv.ParseInt(params["id"], 10, 64) coral.PopularNames.Names, err = repository.GetPopularNames(db, id, CORAL) t.Data = coral t.MediaList = getMediaList(db, CORAL, id) ren.HTML(200, "blah/coral/edit", t) } else { ren.HTML(200, "blah/coral/edit", nil) } }
func EditLatestNews(ren render.Render, db *sql.DB, params martini.Params, t *template.TemplateData) { latest_news_id := params["id"] if latest_news_id != "new" { latest_news, err := repository.GetLatestNews(db, latest_news_id) if err != nil || latest_news == nil { t.SessionMessage.AddDanger("Failed to load news.") ren.Redirect("/latest_news") return } t.Data = latest_news ren.HTML(200, "blah/latest_news/edit", t) } else { t.Data = entity.NewLatestNews() ren.HTML(200, "blah/latest_news/edit", t) } }