Move issues related files into models/issues (#19931)

* Move access and repo permission to models/perm/access

* fix test

* fix git test

* Move functions sequence

* Some improvements per @KN4CK3R and @delvh

* Move issues related code to models/issues

* Move some issues related sub package

* Merge

* Fix test

* Fix test

* Fix test

* Fix test

* Rename some files
This commit is contained in:
Lunny Xiao 2022-06-13 17:37:59 +08:00 committed by GitHub
parent 3708ca8e28
commit 1a9821f57a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
180 changed files with 3667 additions and 3677 deletions

View file

@ -8,8 +8,8 @@ import (
"net/http"
"strings"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
issues_model "code.gitea.io/gitea/models/issues"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/eventsource"
)
@ -23,7 +23,7 @@ func IssueStopwatch(c *context.Context) {
var showSuccessMessage bool
if !models.StopwatchExists(c.Doer.ID, issue.ID) {
if !issues_model.StopwatchExists(c.Doer.ID, issue.ID) {
showSuccessMessage = true
}
@ -32,7 +32,7 @@ func IssueStopwatch(c *context.Context) {
return
}
if err := models.CreateOrStopIssueStopwatch(c.Doer, issue); err != nil {
if err := issues_model.CreateOrStopIssueStopwatch(c.Doer, issue); err != nil {
c.ServerError("CreateOrStopIssueStopwatch", err)
return
}
@ -56,12 +56,12 @@ func CancelStopwatch(c *context.Context) {
return
}
if err := models.CancelStopwatch(c.Doer, issue); err != nil {
if err := issues_model.CancelStopwatch(c.Doer, issue); err != nil {
c.ServerError("CancelStopwatch", err)
return
}
stopwatches, err := models.GetUserStopwatches(c.Doer.ID, db.ListOptions{})
stopwatches, err := issues_model.GetUserStopwatches(c.Doer.ID, db.ListOptions{})
if err != nil {
c.ServerError("GetUserStopwatches", err)
return
@ -87,7 +87,7 @@ func GetActiveStopwatch(ctx *context.Context) {
return
}
_, sw, err := models.HasUserStopwatch(ctx, ctx.Doer.ID)
_, sw, err := issues_model.HasUserStopwatch(ctx, ctx.Doer.ID)
if err != nil {
ctx.ServerError("HasUserStopwatch", err)
return
@ -97,7 +97,7 @@ func GetActiveStopwatch(ctx *context.Context) {
return
}
issue, err := models.GetIssueByID(sw.IssueID)
issue, err := issues_model.GetIssueByID(ctx, sw.IssueID)
if err != nil || issue == nil {
ctx.ServerError("GetIssueByID", err)
return