summaryrefslogtreecommitdiffstats
path: root/routers/routes
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2017-10-16 10:55:43 +0300
committerGitHub <noreply@github.com>2017-10-16 10:55:43 +0300
commitc1b0c9e7c4bbb669ea03694c30c9ff66a109ef17 (patch)
tree06c50be163dfa85264a72b54393eb29aa0f4128c /routers/routes
parenta75d5c72bb9d85b2344ee98b4425290423b6e6b2 (diff)
downloadgitea-c1b0c9e7c4bbb669ea03694c30c9ff66a109ef17.tar.gz
gitea-c1b0c9e7c4bbb669ea03694c30c9ff66a109ef17.zip
Fix PR, milestone and label functionality if issue unit is disabled (#2710)
* Fix PR, milestone and label functionality if issue unit is disabled or not assigned to user * Fix multi-actions in PR page * Change error message * Fix comment update and delete functionality in PR
Diffstat (limited to 'routers/routes')
-rw-r--r--routers/routes/routes.go33
1 files changed, 14 insertions, 19 deletions
diff --git a/routers/routes/routes.go b/routers/routes/routes.go
index 9d9e656433..a6f73aaedd 100644
--- a/routers/routes/routes.go
+++ b/routers/routes/routes.go
@@ -474,12 +474,13 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), repo.Action)
m.Group("/:username/:reponame", func() {
- // FIXME: should use different URLs but mostly same logic for comments of issue and pull reuqest.
- // So they can apply their own enable/disable logic on routers.
m.Group("/issues", func() {
m.Combo("/new").Get(context.RepoRef(), repo.NewIssue).
Post(bindIgnErr(auth.CreateIssueForm{}), repo.NewIssuePost)
-
+ }, context.CheckUnit(models.UnitTypeIssues))
+ // FIXME: should use different URLs but mostly same logic for comments of issue and pull reuqest.
+ // So they can apply their own enable/disable logic on routers.
+ m.Group("/issues", func() {
m.Group("/:index", func() {
m.Post("/title", repo.UpdateIssueTitle)
m.Post("/content", repo.UpdateIssueContent)
@@ -491,30 +492,24 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/toggle", repo.IssueStopwatch)
m.Post("/cancel", repo.CancelStopwatch)
})
-
- }, func(ctx *context.Context) {
- if !ctx.Repo.CanUseTimetracker(repo.GetActionIssue(ctx), ctx.User) {
- ctx.Handle(404, ctx.Req.RequestURI, nil)
- return
- }
})
})
- m.Post("/labels", repo.UpdateIssueLabel, reqRepoWriter)
- m.Post("/milestone", repo.UpdateIssueMilestone, reqRepoWriter)
- m.Post("/assignee", repo.UpdateIssueAssignee, reqRepoWriter)
- m.Post("/status", repo.UpdateIssueStatus, reqRepoWriter)
- }, context.CheckUnit(models.UnitTypeIssues))
+ m.Post("/labels", reqRepoWriter, repo.UpdateIssueLabel)
+ m.Post("/milestone", reqRepoWriter, repo.UpdateIssueMilestone)
+ m.Post("/assignee", reqRepoWriter, repo.UpdateIssueAssignee)
+ m.Post("/status", reqRepoWriter, repo.UpdateIssueStatus)
+ })
m.Group("/comments/:id", func() {
m.Post("", repo.UpdateCommentContent)
m.Post("/delete", repo.DeleteComment)
- }, context.CheckUnit(models.UnitTypeIssues))
+ }, context.CheckAnyUnit(models.UnitTypeIssues, models.UnitTypePullRequests))
m.Group("/labels", func() {
m.Post("/new", bindIgnErr(auth.CreateLabelForm{}), repo.NewLabel)
m.Post("/edit", bindIgnErr(auth.CreateLabelForm{}), repo.UpdateLabel)
m.Post("/delete", repo.DeleteLabel)
m.Post("/initialize", bindIgnErr(auth.InitializeLabelsForm{}), repo.InitializeLabels)
- }, reqRepoWriter, context.RepoRef(), context.CheckUnit(models.UnitTypeIssues))
+ }, reqRepoWriter, context.RepoRef(), context.CheckAnyUnit(models.UnitTypeIssues, models.UnitTypePullRequests))
m.Group("/milestones", func() {
m.Combo("/new").Get(repo.NewMilestone).
Post(bindIgnErr(auth.CreateMilestoneForm{}), repo.NewMilestonePost)
@@ -522,7 +517,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/:id/edit", bindIgnErr(auth.CreateMilestoneForm{}), repo.EditMilestonePost)
m.Get("/:id/:action", repo.ChangeMilestonStatus)
m.Post("/delete", repo.DeleteMilestone)
- }, reqRepoWriter, context.RepoRef(), context.CheckUnit(models.UnitTypeIssues))
+ }, reqRepoWriter, context.RepoRef(), context.CheckAnyUnit(models.UnitTypeIssues, models.UnitTypePullRequests))
m.Combo("/compare/*", repo.MustAllowPulls, repo.SetEditorconfigIfExists).
Get(repo.CompareAndPullRequest).
@@ -593,8 +588,8 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("", func() {
m.Get("/^:type(issues|pulls)$", repo.RetrieveLabels, repo.Issues)
m.Get("/^:type(issues|pulls)$/:index", repo.ViewIssue)
- m.Get("/labels/", repo.RetrieveLabels, repo.Labels)
- m.Get("/milestones", repo.Milestones)
+ m.Get("/labels/", context.CheckAnyUnit(models.UnitTypeIssues, models.UnitTypePullRequests), repo.RetrieveLabels, repo.Labels)
+ m.Get("/milestones", context.CheckAnyUnit(models.UnitTypeIssues, models.UnitTypePullRequests), repo.Milestones)
}, context.RepoRef())
m.Group("/wiki", func() {