本文整理匯總了Golang中github.com/silvasur/mailremind/model.User.Jobs方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.Jobs方法的具體用法?Golang User.Jobs怎麽用?Golang User.Jobs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/silvasur/mailremind/model.User
的用法示例。
在下文中一共展示了User.Jobs方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: jobs
func jobs(user model.User, sess *sessions.Session, req *http.Request) (interface{}, model.User) {
if user == nil {
return &jobsTpldata{Error: "You need to be logged in to do that.", Fatal: true}, user
}
outdata := new(jobsTpldata)
if req.Method == "POST" {
if err := req.ParseForm(); err != nil {
outdata.Error = "Could not understand form data."
goto listjobs
}
if req.FormValue("Delconfirm") != "yes" {
goto listjobs
}
for _, _id := range req.Form["Jobs"] {
id, err := db.ParseDBID(_id)
if err != nil {
outdata.Error = "Not all jobs could be deleted."
continue
}
job, err := user.JobByID(id)
if err != nil {
outdata.Error = "Not all jobs could be deleted."
continue
}
if job.Delete() != nil {
outdata.Error = "Not all jobs could be deleted."
continue
}
outdata.Success = "Jobs deleted."
}
}
listjobs:
jobs := user.Jobs()
outdata.Jobs = make([]*jobTpldata, len(jobs))
for i, job := range jobs {
outdata.Jobs[i] = jobToTpldata(job, user)
}
return outdata, user
}