Пример #1
0
func index(c appengine.Context, w http.ResponseWriter, r *http.Request) {
	page := models.NewPage(r)
	page.Title = "Home"

	pageTemplate := BuildTemplate(INDEX)
	pageTemplate.Execute(w, page)
}
Пример #2
0
func myaccount(c appengine.Context, w http.ResponseWriter, r *http.Request) {
	r.URL.Query().Set("username", "")

	page := models.NewPage(r)
	page.Title = "My Account"
	pageTemplate := BuildTemplate(ACCOUNT)
	pageTemplate.Execute(w, page)
}
Пример #3
0
func cellar(c appengine.Context, w http.ResponseWriter, r *http.Request) {
	page := models.NewPage(r)
	page.Title = "Cellar"

	id := r.URL.Query().Get("id")
	if id == "" {
		http.Redirect(w, r, "/mycellars", 303) //303 == See Other
	}

	page.Cellar = page.Account.GetCellarByID(id)

	pageTemplate := BuildTemplate(CELLAR)
	pageTemplate.Execute(w, page)
}
Пример #4
0
func users(c appengine.Context, w http.ResponseWriter, r *http.Request) {
	page := models.NewPage(r)
	page.Title = "Accounts Listing"

	accounts, err := models.GetAllAccounts(c)

	if err != nil {
		page.Error = err.Error()
	} else {
		page.Accounts = accounts
	}

	pageTemplate := BuildTemplate(USERS)
	pageTemplate.Execute(w, page)
}
Пример #5
0
func tasting(c appengine.Context, w http.ResponseWriter, r *http.Request) {
	page := models.NewPage(r)
	page.Title = "Tasting"

	cellar := r.URL.Query().Get("cellar")
	beer := r.URL.Query().Get("beer")
	id := r.URL.Query().Get("id")
	if id == "" || beer == "" || cellar == "" {
		http.Redirect(w, r, "/mycellars", 303) //303 == See Other
	}

	page.Cellar = page.Account.GetCellarByID(cellar)
	page.Beer = page.Cellar.GetBeerByID(id)
	page.Tasting = page.Beer.GetTastingByID(id)

	pageTemplate := BuildTemplate(TASTING)
	pageTemplate.Execute(w, page)
}
Пример #6
0
func mycellars(c appengine.Context, w http.ResponseWriter, r *http.Request) {
	page := models.NewPage(r)
	page.Title = "My Cellars"
	pageTemplate := BuildTemplate(MYCELLARS)
	pageTemplate.Execute(w, page)
}