예제 #1
0
파일: form.go 프로젝트: trigrass2/wego
func (form *PostAdminForm) SetToPost(post *models.Post) {
	utils.SetFormValues(form, post)

	post.UserId = form.User
	post.LastReplyId = form.LastReply
	post.LastAuthorId = form.LastAuthor
	post.TopicId = form.Topic
	//get category
	if topic, err := models.GetTopicById(form.Topic); err == nil {
		post.CategoryId = topic.CategoryId
	}
	post.ContentCache = utils.RenderMarkdown(post.Content)
}
예제 #2
0
파일: form.go 프로젝트: trigrass2/wego
func (form *PostForm) SavePost(post *models.Post, user *models.User) error {
	utils.SetFormValues(form, post)
	post.CategoryId = form.Category
	post.TopicId = form.Topic
	post.UserId = user.Id
	post.LastReplyId = user.Id
	post.LastAuthorId = user.Id
	post.CanEdit = true
	post.ContentCache = utils.RenderMarkdown(form.Content)

	// mentioned follow users
	FilterMentions(user, post.ContentCache)

	return post.Insert()
}
예제 #3
0
파일: form.go 프로젝트: trigrass2/wego
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.UserId = user.Id
	comment.PostId = post.Id
	if err := models.InsertComment(comment); err == nil {
		post.LastReplyId = user.Id
		models.UpdateById(post.Id, post, "last_reply_id", "last_replied")

		cnt, _ := models.CountCommentsLTEId(comment.Id)
		comment.Floor = int(cnt)
		return models.UpdateById(comment.Id, comment, "floor")
	} else {
		return err
	}
}