func (this *AdminController) PostNewEntry() { this.TplNames = "admin/entry.tpl" entry := models.Entry{} err := this.ParseForm(&entry) if err != nil { panic(err) } entry.Author = this.GetSession("user").(string) entry.Collection = this.Input().Get("collection") nid, err := models.AddEntry(entry) if err != nil { this.Data["PostId"] = "new" this.Data["Message"] = err.Error() } else { this.Data["PostId"] = "update/" + nid this.Data["Message"] = "Post Successful" collections, err := models.CollectionsByUser(this.GetSession("user").(string)) if err != nil { panic(err) } this.Data["Collections"] = collections } this.Data["Entry"] = entry this.Data["MarkdownEnabled"] = true this.Data["EntryActive"] = true renderTemplate(this.Ctx, "views/admin/entry.amber", this.Data) }
func (this *AdminController) UpdateEntry() { entry := models.Entry{} err := this.ParseForm(&entry) if err != nil { panic(err) } entry.Id = this.Ctx.Input.Param(":id") entry.Author = this.GetSession("user").(string) entry.Collection = this.Input().Get("collection") err = models.UpdateEntry(entry) if err != nil { panic(err) } this.TplNames = "admin/entry.tpl" this.Data["EntryActive"] = true this.Data["PostId"] = "update/" + entry.Id this.Data["Entry"] = entry this.Data["MarkdownEnabled"] = true collections, err := models.CollectionsByUser(this.GetSession("user").(string)) if err != nil { panic(err) } this.Data["Collections"] = collections this.Data["Message"] = "Update Successful" renderTemplate(this.Ctx, "views/admin/entry.amber", this.Data) }