mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-14 04:09:29 +02:00
Move user related model into models/user (#17781)
* Move user related model into models/user * Fix lint for windows * Fix windows lint * Fix windows lint * Move some tests in models * Merge
This commit is contained in:
parent
4e7ca946da
commit
a666829a37
345 changed files with 4230 additions and 3813 deletions
|
@ -17,6 +17,7 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
issue_indexer "code.gitea.io/gitea/modules/indexer/issues"
|
||||
|
@ -43,7 +44,7 @@ const (
|
|||
)
|
||||
|
||||
// getDashboardContextUser finds out which context user dashboard is being viewed as .
|
||||
func getDashboardContextUser(ctx *context.Context) *models.User {
|
||||
func getDashboardContextUser(ctx *context.Context) *user_model.User {
|
||||
ctxUser := ctx.User
|
||||
orgName := ctx.Params(":org")
|
||||
if len(orgName) > 0 {
|
||||
|
@ -727,7 +728,7 @@ func getRepoIDs(reposQuery string) []int64 {
|
|||
return repoIDs
|
||||
}
|
||||
|
||||
func getActiveUserRepoIDs(ctxUser *models.User, team *models.Team, unitType unit.Type) ([]int64, error) {
|
||||
func getActiveUserRepoIDs(ctxUser *user_model.User, team *models.Team, unitType unit.Type) ([]int64, error) {
|
||||
var userRepoIDs []int64
|
||||
var err error
|
||||
|
||||
|
@ -737,7 +738,7 @@ func getActiveUserRepoIDs(ctxUser *models.User, team *models.Team, unitType unit
|
|||
return nil, fmt.Errorf("orgRepoIds: %v", err)
|
||||
}
|
||||
} else {
|
||||
userRepoIDs, err = ctxUser.GetActiveAccessRepoIDs(unitType)
|
||||
userRepoIDs, err = models.GetActiveAccessRepoIDs(ctxUser, unitType)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ctxUser.GetAccessRepoIDs: %v", err)
|
||||
}
|
||||
|
@ -752,7 +753,7 @@ func getActiveUserRepoIDs(ctxUser *models.User, team *models.Team, unitType unit
|
|||
|
||||
// getActiveTeamOrOrgRepoIds gets RepoIDs for ctxUser as Organization.
|
||||
// Should be called if and only if ctxUser.IsOrganization == true.
|
||||
func getActiveTeamOrOrgRepoIds(ctxUser *models.User, team *models.Team, unitType unit.Type) ([]int64, error) {
|
||||
func getActiveTeamOrOrgRepoIds(ctxUser *user_model.User, team *models.Team, unitType unit.Type) ([]int64, error) {
|
||||
var orgRepoIDs []int64
|
||||
var err error
|
||||
var env models.AccessibleReposEnvironment
|
||||
|
@ -777,7 +778,7 @@ func getActiveTeamOrOrgRepoIds(ctxUser *models.User, team *models.Team, unitType
|
|||
return orgRepoIDs, nil
|
||||
}
|
||||
|
||||
func issueIDsFromSearch(ctxUser *models.User, keyword string, opts *models.IssuesOptions) ([]int64, error) {
|
||||
func issueIDsFromSearch(ctxUser *user_model.User, keyword string, opts *models.IssuesOptions) ([]int64, error) {
|
||||
if len(keyword) == 0 {
|
||||
return []int64{}, nil
|
||||
}
|
||||
|
@ -794,7 +795,7 @@ func issueIDsFromSearch(ctxUser *models.User, keyword string, opts *models.Issue
|
|||
return issueIDsFromSearch, nil
|
||||
}
|
||||
|
||||
func repoIDMap(ctxUser *models.User, issueCountByRepo map[int64]int64, unitType unit.Type) (map[int64]*models.Repository, error) {
|
||||
func repoIDMap(ctxUser *user_model.User, issueCountByRepo map[int64]int64, unitType unit.Type) (map[int64]*models.Repository, error) {
|
||||
repoByID := make(map[int64]*models.Repository, len(issueCountByRepo))
|
||||
for id := range issueCountByRepo {
|
||||
if id <= 0 {
|
||||
|
@ -880,9 +881,9 @@ func ShowGPGKeys(ctx *context.Context, uid int64) {
|
|||
|
||||
// Email2User show user page via email
|
||||
func Email2User(ctx *context.Context) {
|
||||
u, err := models.GetUserByEmail(ctx.FormString("email"))
|
||||
u, err := user_model.GetUserByEmail(ctx.FormString("email"))
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
if user_model.IsErrUserNotExist(err) {
|
||||
ctx.NotFound("GetUserByEmail", err)
|
||||
} else {
|
||||
ctx.ServerError("GetUserByEmail", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue