Ejemplo n.º 1
0
func (this *AdminController) CreateCollection() {
	this.TplNames = "admin/collection.tpl"

	collection := models.Collection{}
	err := this.ParseForm(&collection)
	if err != nil {
		panic(err)
	}
	fmt.Println(this.GetSession("user"))
	collection.Author = this.GetSession("user").(string)
	cid, err := models.CreateCollection(collection)
	if err != nil {
		this.Data["PostId"] = "new"
		this.Data["Message"] = err.Error()
	} else {
		this.Data["PostId"] = "update/" + cid
		this.Data["Message"] = "Post Successful"
	}
	this.Data["Collection"] = collection
	this.Data["CollectionActive"] = true

	renderTemplate(this.Ctx, "views/admin/collection.amber", this.Data)
}
Ejemplo n.º 2
0
func (this *AdminController) UpdateCollection() {
	this.TplNames = "admin/collection.tpl"

	collection := models.Collection{}
	err := this.ParseForm(&collection)
	if err != nil {
		panic(err)
	}

	collection.Id = this.Ctx.Input.Param(":id")
	collection.Author = this.GetSession("user").(string)
	nid, err := models.UpdateCollection(collection)
	if err != nil {
		this.Data["PostId"] = "update/" + collection.Id
		this.Data["Message"] = err.Error()
	} else {
		this.Data["PostId"] = "update/" + nid
		this.Data["Message"] = "Update Successful"
	}
	this.Data["Collection"] = collection
	this.Data["CollectionActive"] = true

	renderTemplate(this.Ctx, "views/admin/collection.amber", this.Data)
}