summaryrefslogtreecommitdiffstats
path: root/models/issues
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-01-20 19:42:33 +0800
committerGitHub <noreply@github.com>2023-01-20 19:42:33 +0800
commit6fe3c8b3980f850c9789f9fa62bdfee7b2708ff0 (patch)
tree5e11864dd63c60564080506291ca93e465c19940 /models/issues
parent0c048e554ba42d99bd66c07447de5f35cf6c981b (diff)
downloadgitea-6fe3c8b3980f850c9789f9fa62bdfee7b2708ff0.tar.gz
gitea-6fe3c8b3980f850c9789f9fa62bdfee7b2708ff0.zip
Support org/user level projects (#22235)
Fix #13405 <img width="1151" alt="image" src="https://user-images.githubusercontent.com/81045/209442911-7baa3924-c389-47b6-b63b-a740803e640e.png"> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'models/issues')
-rw-r--r--models/issues/issue.go2
-rw-r--r--models/issues/issue_project.go10
2 files changed, 6 insertions, 6 deletions
diff --git a/models/issues/issue.go b/models/issues/issue.go
index 4a8ab06824..dc9e5c5acd 100644
--- a/models/issues/issue.go
+++ b/models/issues/issue.go
@@ -1098,7 +1098,7 @@ func GetIssueWithAttrsByID(id int64) (*Issue, error) {
}
// GetIssuesByIDs return issues with the given IDs.
-func GetIssuesByIDs(ctx context.Context, issueIDs []int64) ([]*Issue, error) {
+func GetIssuesByIDs(ctx context.Context, issueIDs []int64) (IssueList, error) {
issues := make([]*Issue, 0, 10)
return issues, db.GetEngine(ctx).In("id", issueIDs).Find(&issues)
}
diff --git a/models/issues/issue_project.go b/models/issues/issue_project.go
index 8e559f13c9..c9f4c9f533 100644
--- a/models/issues/issue_project.go
+++ b/models/issues/issue_project.go
@@ -125,13 +125,17 @@ func ChangeProjectAssign(issue *Issue, doer *user_model.User, newProjectID int64
func addUpdateIssueProject(ctx context.Context, issue *Issue, doer *user_model.User, newProjectID int64) error {
oldProjectID := issue.projectID(ctx)
+ if err := issue.LoadRepo(ctx); err != nil {
+ return err
+ }
+
// Only check if we add a new project and not remove it.
if newProjectID > 0 {
newProject, err := project_model.GetProjectByID(ctx, newProjectID)
if err != nil {
return err
}
- if newProject.RepoID != issue.RepoID {
+ if newProject.RepoID != issue.RepoID && newProject.OwnerID != issue.Repo.OwnerID {
return fmt.Errorf("issue's repository is not the same as project's repository")
}
}
@@ -140,10 +144,6 @@ func addUpdateIssueProject(ctx context.Context, issue *Issue, doer *user_model.U
return err
}
- if err := issue.LoadRepo(ctx); err != nil {
- return err
- }
-
if oldProjectID > 0 || newProjectID > 0 {
if _, err := CreateComment(ctx, &CreateCommentOptions{
Type: CommentTypeProject,