Ejemplo n.º 1
0
func PostReplysCount(post *models.Post) {
	cnt, err := post.Comments().Count()
	if err == nil {
		post.Replys = int(cnt)
		err = post.Update("Replys")
	}
	if err != nil {
		beego.Error("PostReplysCount ", err)
	}
}
Ejemplo n.º 2
0
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)
	}
}
Ejemplo n.º 3
0
func (this *PostRouter) loadComments(post *models.Post, comments *[]*models.Comment) {
	qs := post.Comments()
	if num, err := qs.RelatedSel("User").OrderBy("Id").All(comments); err == nil {
		this.Data["Comments"] = *comments
		this.Data["CommentsNum"] = num
	}
}
Ejemplo n.º 4
0
func (form *CommentForm) SaveComment(comment *models.Comment, user *models.User, post *models.Post) error {
	comment.Message = form.Message
	comment.MessageCache = utils.RenderMarkdown(form.Message)
	comment.User = user
	comment.Post = post
	if err := comment.Insert(); err == nil {
		post.LastReply = user
		post.Update("LastReply", "Updated")

		cnt, _ := post.Comments().Filter("Id__lte", comment.Id).Count()
		comment.Floor = int(cnt)
		return comment.Update("Floor")
	} else {
		return err
	}
}