aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/collaborators.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-10 09:27:50 +0800
committerGitHub <noreply@github.com>2021-12-10 09:27:50 +0800
commit719bddcd76610a63dadc8555760072957a11cf30 (patch)
tree0df26092fba7e3e21444fe493e6b349473b6b0cb /routers/api/v1/repo/collaborators.go
parentfb8166c6c6b652a0e6fa98681780a6a71090faf3 (diff)
downloadgitea-719bddcd76610a63dadc8555760072957a11cf30.tar.gz
gitea-719bddcd76610a63dadc8555760072957a11cf30.zip
Move repository model into models/repo (#17933)
* Some refactors related repository model * Move more methods out of repository * Move repository into models/repo * Fix test * Fix test * some improvements * Remove unnecessary function
Diffstat (limited to 'routers/api/v1/repo/collaborators.go')
-rw-r--r--routers/api/v1/repo/collaborators.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/routers/api/v1/repo/collaborators.go b/routers/api/v1/repo/collaborators.go
index 80794fa444..d49b6357bd 100644
--- a/routers/api/v1/repo/collaborators.go
+++ b/routers/api/v1/repo/collaborators.go
@@ -9,6 +9,7 @@ import (
"errors"
"net/http"
+ "code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/perm"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/context"
@@ -48,13 +49,13 @@ func ListCollaborators(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/UserList"
- count, err := ctx.Repo.Repository.CountCollaborators()
+ count, err := models.CountCollaborators(ctx.Repo.Repository.ID)
if err != nil {
ctx.InternalServerError(err)
return
}
- collaborators, err := ctx.Repo.Repository.GetCollaborators(utils.GetListOptions(ctx))
+ collaborators, err := models.GetCollaborators(ctx.Repo.Repository.ID, utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "ListCollaborators", err)
return
@@ -109,7 +110,7 @@ func IsCollaborator(ctx *context.APIContext) {
}
return
}
- isColab, err := ctx.Repo.Repository.IsCollaborator(user.ID)
+ isColab, err := models.IsCollaborator(ctx.Repo.Repository.ID, user.ID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "IsCollaborator", err)
return
@@ -171,13 +172,13 @@ func AddCollaborator(ctx *context.APIContext) {
return
}
- if err := ctx.Repo.Repository.AddCollaborator(collaborator); err != nil {
+ if err := models.AddCollaborator(ctx.Repo.Repository, collaborator); err != nil {
ctx.Error(http.StatusInternalServerError, "AddCollaborator", err)
return
}
if form.Permission != nil {
- if err := ctx.Repo.Repository.ChangeCollaborationAccessMode(collaborator.ID, perm.ParseAccessMode(*form.Permission)); err != nil {
+ if err := models.ChangeCollaborationAccessMode(ctx.Repo.Repository, collaborator.ID, perm.ParseAccessMode(*form.Permission)); err != nil {
ctx.Error(http.StatusInternalServerError, "ChangeCollaborationAccessMode", err)
return
}
@@ -225,7 +226,7 @@ func DeleteCollaborator(ctx *context.APIContext) {
return
}
- if err := ctx.Repo.Repository.DeleteCollaboration(collaborator.ID); err != nil {
+ if err := models.DeleteCollaboration(ctx.Repo.Repository, collaborator.ID); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteCollaboration", err)
return
}
@@ -254,7 +255,7 @@ func GetReviewers(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/UserList"
- reviewers, err := ctx.Repo.Repository.GetReviewers(ctx.User.ID, 0)
+ reviewers, err := models.GetReviewers(ctx.Repo.Repository, ctx.User.ID, 0)
if err != nil {
ctx.Error(http.StatusInternalServerError, "ListCollaborators", err)
return
@@ -284,7 +285,7 @@ func GetAssignees(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/UserList"
- assignees, err := ctx.Repo.Repository.GetAssignees()
+ assignees, err := models.GetRepoAssignees(ctx.Repo.Repository)
if err != nil {
ctx.Error(http.StatusInternalServerError, "ListCollaborators", err)
return