func PostReplysCount(post *models.Post) { cnt, err := post.Comments().Count() if err == nil { post.Replys = int(cnt) //disable post editable post.CanEdit = false err = post.Update("Replys", "CanEdit") } if err != nil { beego.Error("PostReplysCount ", err) } }
func (form *PostForm) SavePost(post *models.Post, user *models.User) error { utils.SetFormValues(form, post) post.Category = &models.Category{Id: form.Category} post.Topic = &models.Topic{Id: form.Topic} post.User = user post.LastReply = user post.LastAuthor = user post.CanEdit = true post.ContentCache = utils.RenderMarkdown(form.Content) // mentioned follow users FilterMentions(user, post.ContentCache) return post.Insert() }