OLD | NEW |
---|---|
1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 package ui | 5 package ui |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "net/http" | 9 "net/http" |
10 "strconv" | 10 "strconv" |
11 "sync" | 11 "sync" |
12 | 12 |
13 "github.com/luci/luci-go/server/auth" | 13 "github.com/luci/luci-go/server/auth" |
14 "github.com/luci/luci-go/server/router" | 14 "github.com/luci/luci-go/server/router" |
15 "github.com/luci/luci-go/server/templates" | 15 "github.com/luci/luci-go/server/templates" |
16 | 16 |
17 "github.com/luci/luci-go/scheduler/appengine/engine" | 17 "github.com/luci/luci-go/scheduler/appengine/engine" |
18 "github.com/luci/luci-go/scheduler/appengine/presentation" | |
18 ) | 19 ) |
19 | 20 |
20 func invocationPage(c *router.Context) { | 21 func invocationPage(c *router.Context) { |
21 projectID := c.Params.ByName("ProjectID") | 22 projectID := c.Params.ByName("ProjectID") |
22 jobID := c.Params.ByName("JobID") | 23 jobID := c.Params.ByName("JobID") |
23 invID, err := strconv.ParseInt(c.Params.ByName("InvID"), 10, 64) | 24 invID, err := strconv.ParseInt(c.Params.ByName("InvID"), 10, 64) |
24 if err != nil { | 25 if err != nil { |
25 http.Error(c.Writer, "No such invocation", http.StatusNotFound) | 26 http.Error(c.Writer, "No such invocation", http.StatusNotFound) |
26 return | 27 return |
27 } | 28 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 | 72 |
72 func abortInvocationAction(c *router.Context) { | 73 func abortInvocationAction(c *router.Context) { |
73 handleInvAction(c, func(jobID string, invID int64) error { | 74 handleInvAction(c, func(jobID string, invID int64) error { |
74 who := auth.CurrentIdentity(c.Context) | 75 who := auth.CurrentIdentity(c.Context) |
75 return config(c.Context).Engine.AbortInvocation(c.Context, jobID , invID, who) | 76 return config(c.Context).Engine.AbortInvocation(c.Context, jobID , invID, who) |
76 }) | 77 }) |
77 } | 78 } |
78 | 79 |
79 func handleInvAction(c *router.Context, cb func(string, int64) error) { | 80 func handleInvAction(c *router.Context, cb func(string, int64) error) { |
80 projectID := c.Params.ByName("ProjectID") | 81 projectID := c.Params.ByName("ProjectID") |
81 jobID := c.Params.ByName("JobID") | 82 jobID := c.Params.ByName("JobID") |
Vadim Sh.
2017/06/21 23:39:09
JobName here (and in all similar places).
ByName(
tandrii(chromium)
2017/06/22 15:52:55
oops, indeed I missed these.
| |
82 invID := c.Params.ByName("InvID") | 83 invID := c.Params.ByName("InvID") |
83 » if !isJobOwner(c.Context, projectID, jobID) { | 84 » if !presentation.IsJobOwner(c.Context, projectID, jobID) { |
84 http.Error(c.Writer, "Forbidden", 403) | 85 http.Error(c.Writer, "Forbidden", 403) |
85 return | 86 return |
86 } | 87 } |
87 invIDAsInt, err := strconv.ParseInt(invID, 10, 64) | 88 invIDAsInt, err := strconv.ParseInt(invID, 10, 64) |
88 if err != nil { | 89 if err != nil { |
89 http.Error(c.Writer, "Bad invocation ID", 400) | 90 http.Error(c.Writer, "Bad invocation ID", 400) |
90 return | 91 return |
91 } | 92 } |
92 if err := cb(projectID+"/"+jobID, invIDAsInt); err != nil { | 93 if err := cb(projectID+"/"+jobID, invIDAsInt); err != nil { |
93 panic(err) | 94 panic(err) |
94 } | 95 } |
95 http.Redirect(c.Writer, c.Request, fmt.Sprintf("/jobs/%s/%s/%s", project ID, jobID, invID), http.StatusFound) | 96 http.Redirect(c.Writer, c.Request, fmt.Sprintf("/jobs/%s/%s/%s", project ID, jobID, invID), http.StatusFound) |
96 } | 97 } |
OLD | NEW |