當前位置: 首頁>>代碼示例>>Golang>>正文


Golang utils.SetFormValues函數代碼示例

本文整理匯總了Golang中github.com/beego/wetalk/modules/utils.SetFormValues函數的典型用法代碼示例。如果您正苦於以下問題:Golang SetFormValues函數的具體用法?Golang SetFormValues怎麽用?Golang SetFormValues使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了SetFormValues函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: UpdatePost

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.Category.Id = form.Category
	post.Topic.Id = 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.LastAuthor != nil && post.LastAuthor.Id != user.Id {
		post.LastAuthor = user
		changes = append(changes, "LastAuthor")
	}

	changes = append(changes, "Updated")

	return post.Update(changes...)
}
開發者ID:oyoy8629,項目名稱:XWetalk,代碼行數:25,代碼來源:form.go

示例2: SetToPost

func (form *PostAdminForm) SetToPost(post *models.Post) {
	utils.SetFormValues(form, post)

	if post.User == nil {
		post.User = &models.User{}
	}
	post.User.Id = form.User

	if post.LastReply == nil {
		post.LastReply = &models.User{}
	}
	post.LastReply.Id = form.LastReply

	if post.LastAuthor == nil {
		post.LastAuthor = &models.User{}
	}
	post.LastAuthor.Id = form.LastAuthor

	if post.Topic == nil {
		post.Topic = &models.Topic{}
	}
	post.Topic.Id = form.Topic
	//get category
	topic := &models.Topic{Id: form.Topic}
	if err := topic.Read("Id"); err == nil {
		if post.Category == nil {
			post.Category = &models.Category{}
		}
		post.Category.Id = topic.Category.Id
	}
	post.ContentCache = utils.RenderMarkdown(post.Content)
}
開發者ID:netxfly,項目名稱:wetalk,代碼行數:32,代碼來源:form.go

示例3: SetToPost

func (form *PostAdminForm) SetToPost(post *models.Post) {
	utils.SetFormValues(form, post)

	if post.User == nil {
		post.User = &models.User{}
	}
	post.User.Id = form.User

	if post.LastReply == nil {
		post.LastReply = &models.User{}
	}
	post.LastReply.Id = form.LastReply

	if post.LastAuthor == nil {
		post.LastAuthor = &models.User{}
	}
	post.LastAuthor.Id = form.LastAuthor

	if post.Topic == nil {
		post.Topic = &models.Topic{}
	}
	post.Topic.Id = form.Topic

	if post.Category == nil {
		post.Category = &models.Category{}
	}
	post.Category.Id = form.Category

	post.ContentCache = utils.RenderMarkdown(post.Content)
}
開發者ID:oyoy8629,項目名稱:XWetalk,代碼行數:30,代碼來源:form.go

示例4: SetToUser

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)
}
開發者ID:JessonChan,項目名稱:wetalk,代碼行數:8,代碼來源:form.go

示例5: SetToTopic

func (form *TopicAdminForm) SetToTopic(topic *models.Topic) {
	utils.SetFormValues(form, topic, "Id")
	if topic.Category != nil {
		topic.Category.Id = form.Category
	} else {
		topic.Category = &models.Category{Id: form.Category}
	}
}
開發者ID:netxfly,項目名稱:wetalk,代碼行數:8,代碼來源:topic_form.go

示例6: SetFromComment

func (form *CommentAdminForm) SetFromComment(comment *models.Comment) {
	utils.SetFormValues(comment, form)

	if comment.User != nil {
		form.User = comment.User.Id
	}

	if comment.Post != nil {
		form.Post = comment.Post.Id
	}
}
開發者ID:oyoy8629,項目名稱:XWetalk,代碼行數:11,代碼來源:form.go

示例7: SetFromArticle

func (form *ArticleAdminForm) SetFromArticle(article *models.Article) {
	utils.SetFormValues(article, form)

	if article.User != nil {
		form.User = article.User.Id
	}

	if article.LastAuthor != nil {
		form.LastAuthor = article.LastAuthor.Id
	}
}
開發者ID:JessonChan,項目名稱:wetalk,代碼行數:11,代碼來源:form.go

示例8: SetFromPage

func (form *PageAdminForm) SetFromPage(page *models.Page) {
	utils.SetFormValues(page, form)

	if page.User != nil {
		form.User = page.User.Id
	}

	if page.LastAuthor != nil {
		form.LastAuthor = page.LastAuthor.Id
	}
}
開發者ID:netxfly,項目名稱:wetalk,代碼行數:11,代碼來源:form.go

示例9: SavePost

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.ContentCache = utils.RenderMarkdown(form.Content)

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

	return post.Insert()
}
開發者ID:JessonChan,項目名稱:wetalk,代碼行數:14,代碼來源:form.go

示例10: SetToPage

func (form *PageAdminForm) SetToPage(page *models.Page) {
	utils.SetFormValues(form, page)

	if page.User == nil {
		page.User = &models.User{}
	}
	page.User.Id = form.User

	if page.LastAuthor == nil {
		page.LastAuthor = &models.User{}
	}
	page.LastAuthor.Id = form.LastAuthor

	page.ContentCache = utils.RenderMarkdown(page.Content)
}
開發者ID:netxfly,項目名稱:wetalk,代碼行數:15,代碼來源:form.go

示例11: SetToComment

func (form *CommentAdminForm) SetToComment(comment *models.Comment) {
	utils.SetFormValues(form, comment)

	if comment.User == nil {
		comment.User = &models.User{}
	}
	comment.User.Id = form.User

	if comment.Post == nil {
		comment.Post = &models.Post{}
	}
	comment.Post.Id = form.Post

	comment.MessageCache = utils.RenderMarkdown(comment.Message)
}
開發者ID:oyoy8629,項目名稱:XWetalk,代碼行數:15,代碼來源:form.go

示例12: SetToArticle

func (form *ArticleAdminForm) SetToArticle(article *models.Article) {
	utils.SetFormValues(form, article)

	if article.User == nil {
		article.User = &models.User{}
	}
	article.User.Id = form.User

	if article.LastAuthor == nil {
		article.LastAuthor = &models.User{}
	}
	article.LastAuthor.Id = form.LastAuthor

	article.ContentCache = utils.RenderMarkdown(article.Content)
	article.ContentCacheZhCn = utils.RenderMarkdown(article.ContentZhCn)
}
開發者ID:JessonChan,項目名稱:wetalk,代碼行數:16,代碼來源:form.go

示例13: NewSubmit

func (this *CategoryRouter) NewSubmit() {
	form := post.CategoryForm{Locale: this.Locale}
	this.TplNames = "category/new.html"
	if !this.ValidFormSets(&form) {
		return
	}

	var category models.Category

	utils.SetFormValues(&form, &category)

	if err := category.Insert(); err == nil {
		this.Redirect(category.Link(), 302)
	}

}
開發者ID:oyoy8629,項目名稱:XWetalk,代碼行數:16,代碼來源:category.go

示例14: SetFromPost

func (form *PostAdminForm) SetFromPost(post *models.Post) {
	utils.SetFormValues(post, form)

	if post.User != nil {
		form.User = post.User.Id
	}

	if post.LastReply != nil {
		form.LastReply = post.LastReply.Id
	}

	if post.LastAuthor != nil {
		form.LastAuthor = post.LastAuthor.Id
	}

	if post.Topic != nil {
		form.Topic = post.Topic.Id
	}
}
開發者ID:netxfly,項目名稱:wetalk,代碼行數:19,代碼來源:form.go

示例15: SaveUserProfile

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 user.Update(changes...)
	}
	return nil
}
開發者ID:JessonChan,項目名稱:wetalk,代碼行數:19,代碼來源:form.go


注:本文中的github.com/beego/wetalk/modules/utils.SetFormValues函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。