1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00: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:
Lunny Xiao
2021-11-24 17:49:20 +08:00
committed by GitHub
parent 4e7ca946da
commit a666829a37
345 changed files with 4230 additions and 3813 deletions

View File

@@ -7,6 +7,7 @@ package issue
import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/util"
@@ -41,7 +42,7 @@ func NewIssue(repo *models.Repository, issue *models.Issue, labelIDs []int64, uu
}
// ChangeTitle changes the title of this issue, as the given user.
func ChangeTitle(issue *models.Issue, doer *models.User, title string) (err error) {
func ChangeTitle(issue *models.Issue, doer *user_model.User, title string) (err error) {
oldTitle := issue.Title
issue.Title = title
@@ -55,7 +56,7 @@ func ChangeTitle(issue *models.Issue, doer *models.User, title string) (err erro
}
// ChangeIssueRef changes the branch of this issue, as the given user.
func ChangeIssueRef(issue *models.Issue, doer *models.User, ref string) error {
func ChangeIssueRef(issue *models.Issue, doer *user_model.User, ref string) error {
oldRef := issue.Ref
issue.Ref = ref
@@ -74,8 +75,8 @@ func ChangeIssueRef(issue *models.Issue, doer *models.User, ref string) error {
// "assignees" (array): Logins for Users to assign to this issue.
// Pass one or more user logins to replace the set of assignees on this Issue.
// Send an empty array ([]) to clear all assignees from the Issue.
func UpdateAssignees(issue *models.Issue, oneAssignee string, multipleAssignees []string, doer *models.User) (err error) {
var allNewAssignees []*models.User
func UpdateAssignees(issue *models.Issue, oneAssignee string, multipleAssignees []string, doer *user_model.User) (err error) {
var allNewAssignees []*user_model.User
// Keep the old assignee thingy for compatibility reasons
if oneAssignee != "" {
@@ -95,7 +96,7 @@ func UpdateAssignees(issue *models.Issue, oneAssignee string, multipleAssignees
// Loop through all assignees to add them
for _, assigneeName := range multipleAssignees {
assignee, err := models.GetUserByName(assigneeName)
assignee, err := user_model.GetUserByName(assigneeName)
if err != nil {
return err
}
@@ -125,8 +126,8 @@ func UpdateAssignees(issue *models.Issue, oneAssignee string, multipleAssignees
// AddAssigneeIfNotAssigned adds an assignee only if he isn't already assigned to the issue.
// Also checks for access of assigned user
func AddAssigneeIfNotAssigned(issue *models.Issue, doer *models.User, assigneeID int64) (err error) {
assignee, err := models.GetUserByID(assigneeID)
func AddAssigneeIfNotAssigned(issue *models.Issue, doer *user_model.User, assigneeID int64) (err error) {
assignee, err := user_model.GetUserByID(assigneeID)
if err != nil {
return err
}