|
|
@ -270,23 +270,17 @@ func ViewProject(ctx *context.Context) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uncategorizedBoard, err := models.GetUncategorizedBoard(project.ID) |
|
|
|
|
|
|
|
uncategorizedBoard.Title = ctx.Tr("repo.projects.type.uncategorized") |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.ServerError("GetUncategorizedBoard", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boards, err := models.GetProjectBoards(project.ID) |
|
|
|
boards, err := models.GetProjectBoards(project.ID) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("GetProjectBoards", err) |
|
|
|
ctx.ServerError("GetProjectBoards", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
allBoards := models.ProjectBoardList{uncategorizedBoard} |
|
|
|
if boards[0].ID == 0 { |
|
|
|
allBoards = append(allBoards, boards...) |
|
|
|
boards[0].Title = ctx.Tr("repo.projects.type.uncategorized") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ctx.Data["Issues"], err = allBoards.LoadIssues(); err != nil { |
|
|
|
if ctx.Data["Issues"], err = boards.LoadIssues(); err != nil { |
|
|
|
ctx.ServerError("LoadIssuesOfBoards", err) |
|
|
|
ctx.ServerError("LoadIssuesOfBoards", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -295,7 +289,7 @@ func ViewProject(ctx *context.Context) { |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects) |
|
|
|
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects) |
|
|
|
ctx.Data["Project"] = project |
|
|
|
ctx.Data["Project"] = project |
|
|
|
ctx.Data["Boards"] = allBoards |
|
|
|
ctx.Data["Boards"] = boards |
|
|
|
ctx.Data["PageIsProjects"] = true |
|
|
|
ctx.Data["PageIsProjects"] = true |
|
|
|
ctx.Data["RequiresDraggable"] = true |
|
|
|
ctx.Data["RequiresDraggable"] = true |
|
|
|
|
|
|
|
|
|
|
@ -416,21 +410,19 @@ func AddBoardToProjectPost(ctx *context.Context, form auth.EditProjectBoardTitle |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// EditProjectBoardTitle allows a project board's title to be updated
|
|
|
|
func checkProjectBoardChangePermissions(ctx *context.Context) (*models.Project, *models.ProjectBoard) { |
|
|
|
func EditProjectBoardTitle(ctx *context.Context, form auth.EditProjectBoardTitleForm) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ctx.User == nil { |
|
|
|
if ctx.User == nil { |
|
|
|
ctx.JSON(403, map[string]string{ |
|
|
|
ctx.JSON(403, map[string]string{ |
|
|
|
"message": "Only signed in users are allowed to perform this action.", |
|
|
|
"message": "Only signed in users are allowed to perform this action.", |
|
|
|
}) |
|
|
|
}) |
|
|
|
return |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !ctx.Repo.IsOwner() && !ctx.Repo.IsAdmin() && !ctx.Repo.CanAccess(models.AccessModeWrite, models.UnitTypeProjects) { |
|
|
|
if !ctx.Repo.IsOwner() && !ctx.Repo.IsAdmin() && !ctx.Repo.CanAccess(models.AccessModeWrite, models.UnitTypeProjects) { |
|
|
|
ctx.JSON(403, map[string]string{ |
|
|
|
ctx.JSON(403, map[string]string{ |
|
|
|
"message": "Only authorized users are allowed to perform this action.", |
|
|
|
"message": "Only authorized users are allowed to perform this action.", |
|
|
|
}) |
|
|
|
}) |
|
|
|
return |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
project, err := models.GetProjectByID(ctx.ParamsInt64(":id")) |
|
|
|
project, err := models.GetProjectByID(ctx.ParamsInt64(":id")) |
|
|
@ -440,25 +432,35 @@ func EditProjectBoardTitle(ctx *context.Context, form auth.EditProjectBoardTitle |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ctx.ServerError("GetProjectByID", err) |
|
|
|
ctx.ServerError("GetProjectByID", err) |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
board, err := models.GetProjectBoard(ctx.ParamsInt64(":boardID")) |
|
|
|
board, err := models.GetProjectBoard(ctx.ParamsInt64(":boardID")) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("GetProjectBoard", err) |
|
|
|
ctx.ServerError("GetProjectBoard", err) |
|
|
|
return |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
} |
|
|
|
if board.ProjectID != ctx.ParamsInt64(":id") { |
|
|
|
if board.ProjectID != ctx.ParamsInt64(":id") { |
|
|
|
ctx.JSON(422, map[string]string{ |
|
|
|
ctx.JSON(422, map[string]string{ |
|
|
|
"message": fmt.Sprintf("ProjectBoard[%d] is not in Project[%d] as expected", board.ID, project.ID), |
|
|
|
"message": fmt.Sprintf("ProjectBoard[%d] is not in Project[%d] as expected", board.ID, project.ID), |
|
|
|
}) |
|
|
|
}) |
|
|
|
return |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if project.RepoID != ctx.Repo.Repository.ID { |
|
|
|
if project.RepoID != ctx.Repo.Repository.ID { |
|
|
|
ctx.JSON(422, map[string]string{ |
|
|
|
ctx.JSON(422, map[string]string{ |
|
|
|
"message": fmt.Sprintf("ProjectBoard[%d] is not in Repository[%d] as expected", board.ID, ctx.Repo.Repository.ID), |
|
|
|
"message": fmt.Sprintf("ProjectBoard[%d] is not in Repository[%d] as expected", board.ID, ctx.Repo.Repository.ID), |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
return nil, nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return project, board |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// EditProjectBoardTitle allows a project board's title to be updated
|
|
|
|
|
|
|
|
func EditProjectBoardTitle(ctx *context.Context, form auth.EditProjectBoardTitleForm) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_, board := checkProjectBoardChangePermissions(ctx) |
|
|
|
|
|
|
|
if ctx.Written() { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -476,6 +478,24 @@ func EditProjectBoardTitle(ctx *context.Context, form auth.EditProjectBoardTitle |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SetDefaultProjectBoard set default board for uncategorized issues/pulls
|
|
|
|
|
|
|
|
func SetDefaultProjectBoard(ctx *context.Context) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
project, board := checkProjectBoardChangePermissions(ctx) |
|
|
|
|
|
|
|
if ctx.Written() { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err := models.SetDefaultBoard(project.ID, board.ID); err != nil { |
|
|
|
|
|
|
|
ctx.ServerError("SetDefaultBoard", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.JSON(200, map[string]interface{}{ |
|
|
|
|
|
|
|
"ok": true, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// MoveIssueAcrossBoards move a card from one board to another in a project
|
|
|
|
// MoveIssueAcrossBoards move a card from one board to another in a project
|
|
|
|
func MoveIssueAcrossBoards(ctx *context.Context) { |
|
|
|
func MoveIssueAcrossBoards(ctx *context.Context) { |
|
|
|
|
|
|
|
|
|
|
|