Skip to content

Commit

Permalink
Fix 500 when sorting the default project board
Browse files Browse the repository at this point in the history
  • Loading branch information
lng2020 committed Mar 17, 2024
1 parent ed02d1f commit 7ec532c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 20 deletions.
32 changes: 22 additions & 10 deletions routers/web/org/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,16 +574,28 @@ func CheckProjectBoardChangePermissions(ctx *context.Context) (*project_model.Pr
return nil, nil
}

board, err := project_model.GetBoard(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
ctx.ServerError("GetProjectBoard", err)
return nil, nil
}
if board.ProjectID != ctx.ParamsInt64(":id") {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectBoard[%d] is not in Project[%d] as expected", board.ID, project.ID),
})
return nil, nil
var board *project_model.Board

if ctx.ParamsInt64(":boardID") == 0 {
board = &project_model.Board{
ID: 0,
ProjectID: project.ID,
Title: ctx.Locale.TrString("repo.projects.type.uncategorized"),
}
} else {
board, err = project_model.GetBoard(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
if project_model.IsErrProjectBoardNotExist(err) {
ctx.NotFound("ProjectBoardNotExist", nil)
} else {
ctx.ServerError("GetProjectBoard", err)
}
return nil, nil
}
if board.ProjectID != project.ID {
ctx.NotFound("BoardNotInProject", nil)
return nil, nil
}
}

if project.OwnerID != ctx.ContextUser.ID {
Expand Down
32 changes: 22 additions & 10 deletions routers/web/repo/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,16 +521,28 @@ func checkProjectBoardChangePermissions(ctx *context.Context) (*project_model.Pr
return nil, nil
}

board, err := project_model.GetBoard(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
ctx.ServerError("GetProjectBoard", err)
return nil, nil
}
if board.ProjectID != ctx.ParamsInt64(":id") {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectBoard[%d] is not in Project[%d] as expected", board.ID, project.ID),
})
return nil, nil
var board *project_model.Board

if ctx.ParamsInt64(":boardID") == 0 {
board = &project_model.Board{
ID: 0,
ProjectID: project.ID,
Title: ctx.Locale.TrString("repo.projects.type.uncategorized"),
}
} else {
board, err = project_model.GetBoard(ctx, ctx.ParamsInt64(":boardID"))
if err != nil {
if project_model.IsErrProjectBoardNotExist(err) {
ctx.NotFound("ProjectBoardNotExist", nil)
} else {
ctx.ServerError("GetProjectBoard", err)
}
return nil, nil
}
if board.ProjectID != project.ID {
ctx.NotFound("BoardNotInProject", nil)
return nil, nil
}
}

if project.RepoID != ctx.Repo.Repository.ID {
Expand Down

0 comments on commit 7ec532c

Please sign in to comment.