Example #1
0
func (form *PageAdminForm) SetToPage(page *models.Page) {
	utils.SetFormValues(form, page)

	if page.User == nil {
		page.User = &models.User{}
	}
	page.User.Id = form.User

	if page.LastAuthor == nil {
		page.LastAuthor = &models.User{}
	}
	page.LastAuthor.Id = form.LastAuthor

	page.ContentCache = utils.RenderMarkdown(page.Content)
}
Example #2
0
// view for new object save
func (this *PageAdminRouter) Save() {
	form := page.PageAdminForm{Create: true}
	if !this.ValidFormSets(&form) {
		return
	}

	var a models.Page
	form.SetToPage(&a)
	if err := a.Insert(); err == nil {
		this.FlashRedirect(fmt.Sprintf("/admin/page/%d", a.Id), 302, "CreateSuccess")
		return
	} else {
		beego.Error(err)
		this.Data["Error"] = err
	}
}