Esempio n. 1
0
func ShowLatestNewsCollection(ren render.Render, db *sql.DB, t *template.TemplateData) {
	var err error

	t.Data, err = repository.GetLatestNewsCollection(db, false)

	if err != nil {
		t.SessionMessage.AddDanger("Failed to load last news collection.")

		ren.Redirect("/")

		return
	}

	ren.HTML(200, "blah/latest_news/list", t)
}
Esempio n. 2
0
func GetAllInJson(r render.Render, db *sql.DB) {
	var err error

	json := entity.AllInJson{}

	json.LatestNewsCollection, err = repository.GetLatestNewsCollection(db, true)
	if err != nil {
		log.Fatalln(err)
		r.JSON(500, "Loading data failed")
		return
	}

	json.Corals, err = repository.GetCorals(db)
	if err != nil {
		log.Fatalln(err)
		r.JSON(500, "Loading data failed")
		return
	}

	json.Components, err = repository.GetComponents(db)
	if err != nil {
		log.Fatalln(err)
		r.JSON(500, "Loading data failed")
		return
	}

	json.Inhabitants, err = repository.GetInhabitants(db)
	if err != nil {
		log.Fatalln(err)
		r.JSON(500, "Loading data failed")
		return
	}

	json.Invertebrates, err = repository.GetInvertebrates(db)
	if err != nil {
		log.Fatalln(err)
		r.JSON(500, "Loading data failed")
		return
	}

	json.Plants, err = repository.GetPlants(db)
	if err != nil {
		log.Fatalln(err)
		r.JSON(500, "Loading data failed")
		return
	}

	media, err := repository.GetAllMedia(db)
	if err != nil {
		log.Fatalln(err)
		r.JSON(500, "Loading data failed")
		return
	}

	json.AssignMediaToEntities(&media)

	popular_names, err := repository.GetAllPopularNames(db)
	if err != nil {
		log.Fatalln(err)
		r.JSON(500, "Loading data failed")
		return
	}

	json.AssignPopularNamesToEntities(popular_names)

	r.JSON(200, json)
}