Skip to content

Commit f189e84

Browse files
committed
fix
1 parent 98217b0 commit f189e84

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

models/issues/issue_project.go

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99

1010
"code.gitea.io/gitea/models/db"
11+
"code.gitea.io/gitea/models/organization"
1112
project_model "code.gitea.io/gitea/models/project"
1213
user_model "code.gitea.io/gitea/models/user"
1314
)
@@ -48,32 +49,35 @@ func (issue *Issue) ProjectBoardID(ctx context.Context) int64 {
4849
}
4950

5051
// LoadIssuesFromBoard load issues assigned to this board
51-
func LoadIssuesFromBoard(ctx context.Context, b *project_model.Board) (IssueList, error) {
52+
func LoadIssuesFromBoard(ctx context.Context, b *project_model.Board, doer *user_model.User, org *organization.Organization) (IssueList, error) {
5253
issueList := make(IssueList, 0, 10)
5354

55+
opts := &IssuesOptions{
56+
ProjectID: b.ProjectID,
57+
SortType: "project-column-sorting",
58+
}
59+
60+
if doer != nil {
61+
opts.User = doer
62+
opts.Org = org
63+
} else {
64+
// non-login user can only access public repos
65+
opts.AllPublic = true
66+
}
67+
5468
if b.ID > 0 {
55-
issues, err := Issues(ctx, &IssuesOptions{
56-
ProjectBoardID: b.ID,
57-
ProjectID: b.ProjectID,
58-
SortType: "project-column-sorting",
59-
})
60-
if err != nil {
61-
return nil, err
62-
}
63-
issueList = issues
69+
opts.ProjectBoardID = b.ID
70+
} else if b.Default {
71+
opts.ProjectBoardID = db.NoConditionID
72+
} else {
73+
return issueList, nil
6474
}
6575

66-
if b.Default {
67-
issues, err := Issues(ctx, &IssuesOptions{
68-
ProjectBoardID: db.NoConditionID,
69-
ProjectID: b.ProjectID,
70-
SortType: "project-column-sorting",
71-
})
72-
if err != nil {
73-
return nil, err
74-
}
75-
issueList = append(issueList, issues...)
76+
issues, err := Issues(ctx, opts)
77+
if err != nil {
78+
return nil, err
7679
}
80+
issueList = append(issueList, issues...)
7781

7882
if err := issueList.LoadComments(ctx); err != nil {
7983
return nil, err
@@ -83,10 +87,10 @@ func LoadIssuesFromBoard(ctx context.Context, b *project_model.Board) (IssueList
8387
}
8488

8589
// LoadIssuesFromBoardList load issues assigned to the boards
86-
func LoadIssuesFromBoardList(ctx context.Context, bs project_model.BoardList) (map[int64]IssueList, error) {
90+
func LoadIssuesFromBoardList(ctx context.Context, bs project_model.BoardList, doer *user_model.User, org *organization.Organization) (map[int64]IssueList, error) {
8791
issuesMap := make(map[int64]IssueList, len(bs))
8892
for i := range bs {
89-
il, err := LoadIssuesFromBoard(ctx, bs[i])
93+
il, err := LoadIssuesFromBoard(ctx, bs[i], doer, org)
9094
if err != nil {
9195
return nil, err
9296
}

routers/web/org/projects.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ func ViewProject(ctx *context.Context) {
357357
boards[0].Title = ctx.Locale.TrString("repo.projects.type.uncategorized")
358358
}
359359

360-
issuesMap, err := issues_model.LoadIssuesFromBoardList(ctx, boards)
360+
issuesMap, err := issues_model.LoadIssuesFromBoardList(ctx, boards, ctx.Doer, ctx.Org.Organization)
361361
if err != nil {
362362
ctx.ServerError("LoadIssuesOfBoards", err)
363363
return

routers/web/repo/projects.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func ViewProject(ctx *context.Context) {
319319
boards[0].Title = ctx.Locale.TrString("repo.projects.type.uncategorized")
320320
}
321321

322-
issuesMap, err := issues_model.LoadIssuesFromBoardList(ctx, boards)
322+
issuesMap, err := issues_model.LoadIssuesFromBoardList(ctx, boards, ctx.Doer, ctx.Org.Organization)
323323
if err != nil {
324324
ctx.ServerError("LoadIssuesOfBoards", err)
325325
return

0 commit comments

Comments
 (0)