本文整理汇总了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
}