diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-06-13 17:37:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-13 17:37:59 +0800 |
commit | 1a9821f57a0293db3adc0eab8aff08ca5fa1026c (patch) | |
tree | 3c3d02813eb63c0d0827ef6d9745f6dcdd2636cb /routers/web/user | |
parent | 3708ca8e2849ca7e36e6bd15ec6935a2a2d81e55 (diff) | |
download | gitea-1a9821f57a0293db3adc0eab8aff08ca5fa1026c.tar.gz gitea-1a9821f57a0293db3adc0eab8aff08ca5fa1026c.zip |
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
Diffstat (limited to 'routers/web/user')
-rw-r--r-- | routers/web/user/home.go | 52 | ||||
-rw-r--r-- | routers/web/user/stop_watch.go | 6 |
2 files changed, 29 insertions, 29 deletions
diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 9b4fc652f1..7fe80a2a4b 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -385,17 +385,17 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { viewType = ctx.FormString("type") switch viewType { case "assigned": - filterMode = models.FilterModeAssign + filterMode = issues_model.FilterModeAssign case "created_by": - filterMode = models.FilterModeCreate + filterMode = issues_model.FilterModeCreate case "mentioned": - filterMode = models.FilterModeMention + filterMode = issues_model.FilterModeMention case "review_requested": - filterMode = models.FilterModeReviewRequested + filterMode = issues_model.FilterModeReviewRequested case "your_repositories": fallthrough default: - filterMode = models.FilterModeYourRepositories + filterMode = issues_model.FilterModeYourRepositories viewType = "your_repositories" } @@ -416,7 +416,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { } isPullList := unitType == unit.TypePullRequests - opts := &models.IssuesOptions{ + opts := &issues_model.IssuesOptions{ IsPull: util.OptionalBoolOf(isPullList), SortType: sortType, IsArchived: util.OptionalBoolFalse, @@ -450,15 +450,15 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { } switch filterMode { - case models.FilterModeAll: - case models.FilterModeYourRepositories: - case models.FilterModeAssign: + case issues_model.FilterModeAll: + case issues_model.FilterModeYourRepositories: + case issues_model.FilterModeAssign: opts.AssigneeID = ctx.Doer.ID - case models.FilterModeCreate: + case issues_model.FilterModeCreate: opts.PosterID = ctx.Doer.ID - case models.FilterModeMention: + case issues_model.FilterModeMention: opts.MentionedID = ctx.Doer.ID - case models.FilterModeReviewRequested: + case issues_model.FilterModeReviewRequested: opts.ReviewRequestedID = ctx.Doer.ID } @@ -491,7 +491,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { // USING NON-FINAL STATE OF opts FOR A QUERY. var issueCountByRepo map[int64]int64 if !forceEmpty { - issueCountByRepo, err = models.CountIssuesByRepo(opts) + issueCountByRepo, err = issues_model.CountIssuesByRepo(opts) if err != nil { ctx.ServerError("CountIssuesByRepo", err) return @@ -532,15 +532,15 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { // Slice of Issues that will be displayed on the overview page // USING FINAL STATE OF opts FOR A QUERY. - var issues []*models.Issue + var issues []*issues_model.Issue if !forceEmpty { - issues, err = models.Issues(opts) + issues, err = issues_model.Issues(opts) if err != nil { ctx.ServerError("Issues", err) return } } else { - issues = []*models.Issue{} + issues = []*issues_model.Issue{} } // ---------------------------------- @@ -578,9 +578,9 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { // ------------------------------- // Fill stats to post to ctx.Data. // ------------------------------- - var issueStats *models.IssueStats + var issueStats *issues_model.IssueStats if !forceEmpty { - statsOpts := models.UserIssueStatsOptions{ + statsOpts := issues_model.UserIssueStatsOptions{ UserID: ctx.Doer.ID, FilterMode: filterMode, IsPull: isPullList, @@ -592,13 +592,13 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { Team: team, } - issueStats, err = models.GetUserIssueStats(statsOpts) + issueStats, err = issues_model.GetUserIssueStats(statsOpts) if err != nil { ctx.ServerError("GetUserIssueStats Shown", err) return } } else { - issueStats = &models.IssueStats{} + issueStats = &issues_model.IssueStats{} } // Will be posted to ctx.Data. @@ -623,7 +623,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { ctx.Data["Issues"] = issues - approvalCounts, err := models.IssueList(issues).GetApprovalCounts(ctx) + approvalCounts, err := issues_model.IssueList(issues).GetApprovalCounts(ctx) if err != nil { ctx.ServerError("ApprovalCounts", err) return @@ -633,11 +633,11 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { if !ok || len(counts) == 0 { return 0 } - reviewTyp := models.ReviewTypeApprove + reviewTyp := issues_model.ReviewTypeApprove if typ == "reject" { - reviewTyp = models.ReviewTypeReject + reviewTyp = issues_model.ReviewTypeReject } else if typ == "waiting" { - reviewTyp = models.ReviewTypeRequest + reviewTyp = issues_model.ReviewTypeRequest } for _, count := range counts { if count.Type == reviewTyp { @@ -708,12 +708,12 @@ func getRepoIDs(reposQuery string) []int64 { return repoIDs } -func issueIDsFromSearch(ctx *context.Context, ctxUser *user_model.User, keyword string, opts *models.IssuesOptions) ([]int64, error) { +func issueIDsFromSearch(ctx *context.Context, ctxUser *user_model.User, keyword string, opts *issues_model.IssuesOptions) ([]int64, error) { if len(keyword) == 0 { return []int64{}, nil } - searchRepoIDs, err := models.GetRepoIDsForIssuesOptions(opts, ctxUser) + searchRepoIDs, err := issues_model.GetRepoIDsForIssuesOptions(opts, ctxUser) if err != nil { return nil, fmt.Errorf("GetRepoIDsForIssuesOptions: %v", err) } diff --git a/routers/web/user/stop_watch.go b/routers/web/user/stop_watch.go index 4b16c9aeda..f40d850fc1 100644 --- a/routers/web/user/stop_watch.go +++ b/routers/web/user/stop_watch.go @@ -7,15 +7,15 @@ package user import ( "net/http" - "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/convert" ) // GetStopwatches get all stopwatches func GetStopwatches(ctx *context.Context) { - sws, err := models.GetUserStopwatches(ctx.Doer.ID, db.ListOptions{ + sws, err := issues_model.GetUserStopwatches(ctx.Doer.ID, db.ListOptions{ Page: ctx.FormInt("page"), PageSize: convert.ToCorrectPageSize(ctx.FormInt("limit")), }) @@ -24,7 +24,7 @@ func GetStopwatches(ctx *context.Context) { return } - count, err := models.CountUserStopwatches(ctx.Doer.ID) + count, err := issues_model.CountUserStopwatches(ctx.Doer.ID) if err != nil { ctx.Error(http.StatusInternalServerError, err.Error()) return |