mirror of
https://github.com/go-gitea/gitea.git
synced 2024-10-29 08:17:31 -04:00
Add change assignee back end
This commit is contained in:
parent
e867283406
commit
a742ee543e
@ -338,6 +338,18 @@ func UpdateIssueUserPairsByStatus(iid int64, isClosed bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateIssueUserPairByAssignee updates issue-user pair for assigning.
|
||||||
|
func UpdateIssueUserPairByAssignee(aid, iid int64) error {
|
||||||
|
rawSql := "UPDATE `issue_user` SET is_assigned = ? WHERE issue_id = ?"
|
||||||
|
if _, err := orm.Exec(rawSql, false, iid); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
rawSql = "UPDATE `issue_user` SET is_assigned = true WHERE uid = ? AND issue_id = ?"
|
||||||
|
_, err := orm.Exec(rawSql, true, aid, iid)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// UpdateIssueUserPairByRead updates issue-user pair for reading.
|
// UpdateIssueUserPairByRead updates issue-user pair for reading.
|
||||||
func UpdateIssueUserPairByRead(uid, iid int64) error {
|
func UpdateIssueUserPairByRead(uid, iid int64) error {
|
||||||
rawSql := "UPDATE `issue_user` SET is_read = ? WHERE uid = ? AND issue_id = ?"
|
rawSql := "UPDATE `issue_user` SET is_read = ? WHERE uid = ? AND issue_id = ?"
|
||||||
|
@ -141,6 +141,10 @@ func CreateIssuePost(ctx *middleware.Context, params martini.Params, form auth.C
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only collaborators can assign.
|
||||||
|
if !ctx.Repo.IsOwner {
|
||||||
|
form.AssigneeId = 0
|
||||||
|
}
|
||||||
issue := &models.Issue{
|
issue := &models.Issue{
|
||||||
Index: int64(ctx.Repo.Repository.NumIssues) + 1,
|
Index: int64(ctx.Repo.Repository.NumIssues) + 1,
|
||||||
Name: form.IssueName,
|
Name: form.IssueName,
|
||||||
@ -220,13 +224,28 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
|
|||||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx)
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrIssueNotExist {
|
if err == models.ErrIssueNotExist {
|
||||||
ctx.Handle(404, "issue.ViewIssue", err)
|
ctx.Handle(404, "issue.ViewIssue(GetIssueByIndex)", err)
|
||||||
} else {
|
} else {
|
||||||
ctx.Handle(200, "issue.ViewIssue", err)
|
ctx.Handle(500, "issue.ViewIssue(GetIssueByIndex)", err)
|
||||||
}
|
}
|
||||||
return
|
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.
|
// Update issue-user.
|
||||||
if err = models.UpdateIssueUserPairByRead(ctx.User.Id, issue.Id); err != nil {
|
if err = models.UpdateIssueUserPairByRead(ctx.User.Id, issue.Id); err != nil {
|
||||||
ctx.Handle(500, "issue.ViewIssue(UpdateIssueUserPairByRead): %v", err)
|
ctx.Handle(500, "issue.ViewIssue(UpdateIssueUserPairByRead): %v", err)
|
||||||
@ -254,7 +273,7 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
|
|||||||
for i := range comments {
|
for i := range comments {
|
||||||
u, err := models.GetUserById(comments[i].PosterId)
|
u, err := models.GetUserById(comments[i].PosterId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Handle(500, "issue.ViewIssue(get poster of comment): %v", err)
|
ctx.Handle(500, "issue.ViewIssue(GetUserById.2): %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
comments[i].Poster = u
|
comments[i].Poster = u
|
||||||
|
Loading…
Reference in New Issue
Block a user