summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-05-08 17:17:45 -0400
committerUnknown <joe2010xtmf@163.com>2014-05-08 17:17:45 -0400
commita742ee543ef3faf6374625c9c6d065c0a46b5549 (patch)
tree4afdfdabfb284e32109190fd51f4ff7e8cce7969 /routers
parente86728340654b18a657a65920c16e28a1b00cca7 (diff)
downloadgitea-a742ee543ef3faf6374625c9c6d065c0a46b5549.tar.gz
gitea-a742ee543ef3faf6374625c9c6d065c0a46b5549.zip
Add change assignee back end
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/issue.go25
1 files changed, 22 insertions, 3 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 3d25f06ae5..1f681c39fd 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -141,6 +141,10 @@ func CreateIssuePost(ctx *middleware.Context, params martini.Params, form auth.C
return
}
+ // Only collaborators can assign.
+ if !ctx.Repo.IsOwner {
+ form.AssigneeId = 0
+ }
issue := &models.Issue{
Index: int64(ctx.Repo.Repository.NumIssues) + 1,
Name: form.IssueName,
@@ -220,13 +224,28 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx)
if err != nil {
if err == models.ErrIssueNotExist {
- ctx.Handle(404, "issue.ViewIssue", err)
+ ctx.Handle(404, "issue.ViewIssue(GetIssueByIndex)", err)
} else {
- ctx.Handle(200, "issue.ViewIssue", err)
+ ctx.Handle(500, "issue.ViewIssue(GetIssueByIndex)", err)
}
return
}
+ // Update assignee.
+ if ctx.Repo.IsOwner {
+ aid, _ := base.StrTo(ctx.Query("assignneid")).Int64()
+ if aid > 0 {
+ // Not check for invalid assignne id and give responsibility to owners.
+ issue.AssigneeId = aid
+ if err = models.UpdateIssueUserPairByAssignee(aid, issue.Id); err != nil {
+ ctx.Handle(500, "issue.ViewIssue(UpdateIssueUserPairByAssignee): %v", err)
+ return
+ }
+ ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index))
+ return
+ }
+ }
+
// Update issue-user.
if err = models.UpdateIssueUserPairByRead(ctx.User.Id, issue.Id); err != nil {
ctx.Handle(500, "issue.ViewIssue(UpdateIssueUserPairByRead): %v", err)
@@ -254,7 +273,7 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
for i := range comments {
u, err := models.GetUserById(comments[i].PosterId)
if err != nil {
- ctx.Handle(500, "issue.ViewIssue(get poster of comment): %v", err)
+ ctx.Handle(500, "issue.ViewIssue(GetUserById.2): %v", err)
return
}
comments[i].Poster = u