Finish issue assignee
This commit is contained in:
parent
a196245a87
commit
68fb62347f
|
@ -177,7 +177,6 @@ func runServ(k *cli.Context) {
|
|||
models.SetRepoEnvs(user.Id, user.Name, repoName, repoUserName)
|
||||
|
||||
gitcmd := exec.Command(verb, repoPath)
|
||||
println(base.RepoRootPath)
|
||||
gitcmd.Dir = base.RepoRootPath
|
||||
gitcmd.Stdout = os.Stdout
|
||||
gitcmd.Stdin = os.Stdin
|
||||
|
|
|
@ -184,6 +184,7 @@ func runWeb(*cli.Context) {
|
|||
r.Get("/issues/new", repo.CreateIssue)
|
||||
r.Post("/issues/new", bindIgnErr(auth.CreateIssueForm{}), repo.CreateIssuePost)
|
||||
r.Post("/issues/:index", bindIgnErr(auth.CreateIssueForm{}), repo.UpdateIssue)
|
||||
r.Post("/issues/:index/assignee", repo.UpdateAssignee)
|
||||
r.Get("/issues/milestones", repo.Milestones)
|
||||
r.Get("/issues/milestones/new", repo.NewMilestones)
|
||||
r.Post("/comment/:action", repo.Comment)
|
||||
|
|
|
@ -349,8 +349,12 @@ func UpdateIssueUserPairByAssignee(aid, iid int64) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Assignee ID equals to 0 means clear assignee.
|
||||
if aid == 0 {
|
||||
return nil
|
||||
}
|
||||
rawSql = "UPDATE `issue_user` SET is_assigned = true WHERE uid = ? AND issue_id = ?"
|
||||
_, err := orm.Exec(rawSql, true, aid, iid)
|
||||
_, err := orm.Exec(rawSql, aid, iid)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -547,7 +547,7 @@ function initIssue() {
|
|||
if(uid != assignee){
|
||||
$.post($a.data("ajax"), {
|
||||
issue: $('#issue').data("id"),
|
||||
assign: assignee
|
||||
assigneeid: uid
|
||||
}, function (json) {
|
||||
if (json.ok) {
|
||||
window.location.reload();
|
||||
|
|
|
@ -239,20 +239,12 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
|
|||
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
|
||||
}
|
||||
us, err := models.GetCollaborators(strings.TrimPrefix(ctx.Repo.RepoLink, "/"))
|
||||
if err != nil {
|
||||
ctx.Handle(500, "issue.CreateIssue(GetCollaborators)", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Collaborators"] = us
|
||||
|
||||
if ctx.IsSigned {
|
||||
// Update issue-user.
|
||||
|
@ -300,18 +292,18 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
|
|||
}
|
||||
|
||||
func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) {
|
||||
index, err := base.StrTo(params["index"]).Int()
|
||||
idx, err := base.StrTo(params["index"]).Int()
|
||||
if err != nil {
|
||||
ctx.Handle(404, "issue.UpdateIssue", err)
|
||||
ctx.Error(404)
|
||||
return
|
||||
}
|
||||
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index))
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(idx))
|
||||
if err != nil {
|
||||
if err == models.ErrIssueNotExist {
|
||||
ctx.Handle(404, "issue.UpdateIssue", err)
|
||||
} else {
|
||||
ctx.Handle(200, "issue.UpdateIssue(get issue)", err)
|
||||
ctx.Handle(500, "issue.UpdateIssue(GetIssueByIndex)", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -327,7 +319,7 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
|
|||
issue.Labels = form.Labels
|
||||
issue.Content = form.Content
|
||||
if err = models.UpdateIssue(issue); err != nil {
|
||||
ctx.Handle(200, "issue.UpdateIssue(update issue)", err)
|
||||
ctx.Handle(500, "issue.UpdateIssue(UpdateIssue)", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -338,6 +330,44 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
|
|||
})
|
||||
}
|
||||
|
||||
func UpdateAssignee(ctx *middleware.Context) {
|
||||
if !ctx.Repo.IsOwner {
|
||||
ctx.Error(403)
|
||||
return
|
||||
}
|
||||
|
||||
idx, err := base.StrTo(ctx.Query("issue")).Int64()
|
||||
if err != nil {
|
||||
ctx.Error(404)
|
||||
return
|
||||
}
|
||||
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx)
|
||||
if err != nil {
|
||||
if err == models.ErrIssueNotExist {
|
||||
ctx.Handle(404, "issue.UpdateAssignee", err)
|
||||
} else {
|
||||
ctx.Handle(500, "issue.UpdateAssignee(GetIssueByIndex)", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
aid, _ := base.StrTo(ctx.Query("assigneeid")).Int64()
|
||||
// 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.UpdateAssignee(UpdateIssueUserPairByAssignee): %v", err)
|
||||
return
|
||||
} else if err = models.UpdateIssue(issue); err != nil {
|
||||
ctx.Handle(500, "issue.UpdateAssignee(UpdateIssue)", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
||||
func Comment(ctx *middleware.Context, params martini.Params) {
|
||||
index, err := base.StrTo(ctx.Query("issueIndex")).Int64()
|
||||
if err != nil {
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
</div>
|
||||
|
||||
<div class="issue-bar col-md-2">
|
||||
<div class="assignee" data-assigned="{{if .Issue.Assignee}}{{.Issue.Assignee.Id}}{{else}}0{{end}}" data-ajax="{url}">{{if .IsRepositoryOwner}}
|
||||
<div class="assignee" data-assigned="{{if .Issue.Assignee}}{{.Issue.Assignee.Id}}{{else}}0{{end}}" data-ajax="{{.Issue.Index}}/assignee">{{if .IsRepositoryOwner}}
|
||||
<div class="pull-right action">
|
||||
<button type="button" class="dropdown-toggle btn btn-default btn-sm" data-toggle="dropdown">
|
||||
<i class="fa fa-group"></i>
|
||||
|
@ -112,7 +112,6 @@
|
|||
{{range .Collaborators}}
|
||||
<li data-uid="{{.Id}}"><img src="{{.AvatarLink}}"><strong>{{.Name}}</strong> {{.FullName}}</li>
|
||||
{{end}}
|
||||
<li data-uid="1"><img src="//1.gravatar.com/avatar/f72f7454ce9d710baa506394f68f4132"><strong>fuxiaohei</strong></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>{{end}}
|
||||
|
|
Loading…
Reference in a new issue