Example #1
0
func (c *Topic) NewPost(topic models.Topic) revel.Result {
	topic.Validate(c.Validation)
	if c.Validation.HasErrors() {
		c.Validation.Keep()
		c.FlashParams()
		return c.Redirect(routes.Topic.New())
	}

	topic.UserId = c.RenderArgs["user"].(*models.User).Id
	if topic.Save() {
		c.Flash.Success("发表新帖成功")
	} else {
		c.Flash.Error("发表新帖失败")
	}

	return c.Redirect(routes.Topic.New())
}