Example #1
0
func (form *CommentAdminForm) SetToComment(comment *models.Comment) {
	utils.SetFormValues(form, comment)

	comment.UserId = int64(form.User)
	comment.PostId = int64(form.Post)
	comment.MessageCache = utils.RenderMarkdown(comment.Message)
}
Example #2
0
func (form *PostForm) UpdatePost(post *models.Post, user *models.User) error {
	changes := utils.FormChanges(post, form)
	if len(changes) == 0 {
		return nil
	}
	utils.SetFormValues(form, post)
	post.CategoryId = form.Category
	post.TopicId = form.Topic
	for _, c := range changes {
		if c == "Content" {
			post.ContentCache = utils.RenderMarkdown(form.Content)
			changes = append(changes, "ContentCache")
		}
	}

	// update last edit author
	if post.LastAuthorId != user.Id {
		post.LastAuthorId = user.Id
		changes = append(changes, "LastAuthor")
	}

	changes = append(changes, "Updated")

	return models.UpdateById(post.Id, post, models.Obj2Table(changes)...)
}
Example #3
0
File: form.go Project: zeuson/wego
func (form *UserAdminForm) SetToUser(user *models.User) {
	// set md5 value if the value is an email
	if strings.IndexRune(form.GrEmail, '@') != -1 {
		form.GrEmail = utils.EncodeMd5(form.GrEmail)
	}

	utils.SetFormValues(form, user)
}
Example #4
0
func (form *PostAdminForm) SetFromPost(post *models.Post) {
	utils.SetFormValues(post, form)

	form.User = post.UserId
	form.LastReply = post.LastReplyId
	form.LastAuthor = post.LastAuthorId
	form.Topic = post.TopicId
}
Example #5
0
func (form *PageAdminForm) SetToPage(page *models.Page) {
	utils.SetFormValues(form, page)

	page.UserId = int64(form.User)
	page.LastAuthorId = int64(form.LastAuthor)

	page.ContentCache = utils.RenderMarkdown(page.Content)
}
Example #6
0
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)
}
Example #7
0
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()
}
Example #8
0
File: form.go Project: zeuson/wego
func (form *ProfileForm) SaveUserProfile(user *models.User) error {
	// set md5 value if the value is an email
	if strings.IndexRune(form.GrEmail, '@') != -1 {
		form.GrEmail = utils.EncodeMd5(form.GrEmail)
	}

	changes := utils.FormChanges(user, form)
	if len(changes) > 0 {
		// if email changed then need re-active
		if user.Email != form.Email {
			user.IsActive = false
			changes = append(changes, "IsActive")
		}

		utils.SetFormValues(form, user)
		return models.UpdateById(user.Id, user, changes...)
	}
	return nil
}
Example #9
0
func (form *PostForm) SetFromPost(post *models.Post) {
	utils.SetFormValues(post, form)
	form.Category = post.CategoryId
	form.Topic = post.TopicId
}
Example #10
0
func (form *PageAdminForm) SetFromPage(page *models.Page) {
	utils.SetFormValues(page, form)

	form.User = int(page.UserId)
	form.LastAuthor = int(page.LastAuthorId)
}
Example #11
0
func (form *BulletinAdminForm) SetToBulletin(bulletin *models.Bulletin) {
	utils.SetFormValues(form, bulletin, "Id")
}
Example #12
0
func (form *BulletinAdminForm) SetFromBulletin(bulletin *models.Bulletin) {
	utils.SetFormValues(bulletin, form)
}
Example #13
0
func (form *CategoryAdminForm) SetFromCategory(cat *models.Category) {
	utils.SetFormValues(cat, form)
}
Example #14
0
func (form *CommentAdminForm) SetFromComment(comment *models.Comment) {
	utils.SetFormValues(comment, form)

	form.User = int(comment.UserId)
	form.Post = int(comment.PostId)
}
Example #15
0
func (form *CategoryAdminForm) SetToCategory(cat *models.Category) {
	utils.SetFormValues(form, cat, "Id")
}
Example #16
0
func (form *TopicAdminForm) SetFromTopic(topic *models.Topic) {
	utils.SetFormValues(topic, form)
	form.Category = int(topic.CategoryId)
}
Example #17
0
File: form.go Project: zeuson/wego
func (form *UserAdminForm) SetFromUser(user *models.User) {
	utils.SetFormValues(user, form)
}
Example #18
0
func (form *TopicAdminForm) SetToTopic(topic *models.Topic) {
	utils.SetFormValues(form, topic, "Id")
	topic.CategoryId = int64(form.Category)
}
Example #19
0
File: form.go Project: zeuson/wego
func (form *ProfileForm) SetFromUser(user *models.User) {
	utils.SetFormValues(user, form)
}