aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues/milestone.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-06-30 23:55:08 +0800
committerGitHub <noreply@github.com>2022-06-30 23:55:08 +0800
commit184a7d4195baffb169f24f4e9a4524f8d4045e91 (patch)
treeb7d620626be91e789115d41d9829518e4119c4a1 /models/issues/milestone.go
parentdb3355cb1aa206fc9f1cf786543607204f628218 (diff)
downloadgitea-184a7d4195baffb169f24f4e9a4524f8d4045e91.tar.gz
gitea-184a7d4195baffb169f24f4e9a4524f8d4045e91.zip
Check if project has the same repository id with issue when assign project to issue (#20133)
* Check if project has the same repository id with issue when assign project to issue * Check if issue's repository id match project's repository id * Add more permission checking * Remove invalid argument * Fix errors * Add generic check * Remove duplicated check * Return error + add check for new issues * Apply suggestions from code review Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'models/issues/milestone.go')
-rw-r--r--models/issues/milestone.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/models/issues/milestone.go b/models/issues/milestone.go
index 6c10959108..fba599e6ec 100644
--- a/models/issues/milestone.go
+++ b/models/issues/milestone.go
@@ -124,6 +124,11 @@ func NewMilestone(m *Milestone) (err error) {
return committer.Commit()
}
+// HasMilestoneByRepoID returns if the milestone exists in the repository.
+func HasMilestoneByRepoID(ctx context.Context, repoID, id int64) (bool, error) {
+ return db.GetEngine(ctx).ID(id).Where("repo_id=?", repoID).Exist(new(Milestone))
+}
+
// GetMilestoneByRepoID returns the milestone in a repository.
func GetMilestoneByRepoID(ctx context.Context, repoID, id int64) (*Milestone, error) {
m := new(Milestone)