本文整理匯總了Golang中github.com/qor/admin.Context.URLFor方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.URLFor方法的具體用法?Golang Context.URLFor怎麽用?Golang Context.URLFor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/qor/admin.Context
的用法示例。
在下文中一共展示了Context.URLFor方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PublishOrDiscard
func (pc *publishController) PublishOrDiscard(context *admin.Context) {
var request = context.Request
var ids = request.Form["checked_ids[]"]
if scheduler := pc.Publish.WorkerScheduler; scheduler != nil {
jobResource := scheduler.JobResource
result := jobResource.NewStruct().(worker.QorJobInterface)
if request.Form.Get("publish_type") == "discard" {
result.SetJob(scheduler.GetRegisteredJob("Discard"))
} else {
result.SetJob(scheduler.GetRegisteredJob("Publish"))
}
workerArgument := &QorWorkerArgument{IDs: ids}
if t, err := utils.ParseTime(request.Form.Get("scheduled_time"), context.Context); err == nil {
workerArgument.ScheduleTime = &t
}
result.SetSerializableArgumentValue(workerArgument)
jobResource.CallSave(result, context.Context)
scheduler.AddJob(result)
http.Redirect(context.Writer, context.Request, context.URLFor(jobResource), http.StatusFound)
} else {
records := pc.searchWithPublishIDs(context.GetDB().Set(publishDraftMode, true), context.Admin, ids)
if request.Form.Get("publish_type") == "publish" {
pc.Publish.Publish(records...)
} else if request.Form.Get("publish_type") == "discard" {
pc.Publish.Discard(records...)
}
http.Redirect(context.Writer, context.Request, context.Request.RequestURI, http.StatusFound)
}
}
示例2: RunJob
func (wc workerController) RunJob(context *admin.Context) {
if newJob := wc.Worker.saveAnotherJob(context.ResourceID); newJob != nil {
wc.Worker.AddJob(newJob)
} else {
context.AddError(errors.New("failed to clone job " + context.ResourceID))
}
http.Redirect(context.Writer, context.Request, context.URLFor(wc.Worker.JobResource), http.StatusFound)
}