summaryrefslogtreecommitdiffstats
path: root/routers/web/admin
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-05-20 22:08:52 +0800
committerGitHub <noreply@github.com>2022-05-20 22:08:52 +0800
commitfd7d83ace60258acf7139c4c787aa8af75b7ba8c (patch)
tree50038348ec10485f72344f3ac80324e04abc1283 /routers/web/admin
parentd81e31ad7826a81fc7139f329f250594610a274b (diff)
downloadgitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.tar.gz
gitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.zip
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
Diffstat (limited to 'routers/web/admin')
-rw-r--r--routers/web/admin/hooks.go4
-rw-r--r--routers/web/admin/repos.go4
-rw-r--r--routers/web/admin/users.go2
-rw-r--r--routers/web/admin/users_test.go8
4 files changed, 9 insertions, 9 deletions
diff --git a/routers/web/admin/hooks.go b/routers/web/admin/hooks.go
index 1483d0959d..bf71cb5595 100644
--- a/routers/web/admin/hooks.go
+++ b/routers/web/admin/hooks.go
@@ -35,7 +35,7 @@ func DefaultOrSystemWebhooks(ctx *context.Context) {
sys["Title"] = ctx.Tr("admin.systemhooks")
sys["Description"] = ctx.Tr("admin.systemhooks.desc")
- sys["Webhooks"], err = webhook.GetSystemWebhooks(util.OptionalBoolNone)
+ sys["Webhooks"], err = webhook.GetSystemWebhooks(ctx, util.OptionalBoolNone)
sys["BaseLink"] = setting.AppSubURL + "/admin/hooks"
sys["BaseLinkNew"] = setting.AppSubURL + "/admin/system-hooks"
if err != nil {
@@ -45,7 +45,7 @@ func DefaultOrSystemWebhooks(ctx *context.Context) {
def["Title"] = ctx.Tr("admin.defaulthooks")
def["Description"] = ctx.Tr("admin.defaulthooks.desc")
- def["Webhooks"], err = webhook.GetDefaultWebhooks()
+ def["Webhooks"], err = webhook.GetDefaultWebhooks(ctx)
def["BaseLink"] = setting.AppSubURL + "/admin/hooks"
def["BaseLinkNew"] = setting.AppSubURL + "/admin/default-hooks"
if err != nil {
diff --git a/routers/web/admin/repos.go b/routers/web/admin/repos.go
index fb7be12c35..809d1de74b 100644
--- a/routers/web/admin/repos.go
+++ b/routers/web/admin/repos.go
@@ -121,7 +121,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
return
}
- ctxUser, err := user_model.GetUserByName(dirSplit[0])
+ ctxUser, err := user_model.GetUserByName(ctx, dirSplit[0])
if err != nil {
if user_model.IsErrUserNotExist(err) {
log.Debug("User does not exist: %s", dirSplit[0])
@@ -135,7 +135,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
repoName := dirSplit[1]
// check not a repo
- has, err := repo_model.IsRepositoryExist(ctxUser, repoName)
+ has, err := repo_model.IsRepositoryExist(ctx, ctxUser, repoName)
if err != nil {
ctx.ServerError("IsRepositoryExist", err)
return
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go
index 7841ac569f..c37ecfd71e 100644
--- a/routers/web/admin/users.go
+++ b/routers/web/admin/users.go
@@ -389,7 +389,7 @@ func EditUserPost(ctx *context.Context) {
u.ProhibitLogin = form.ProhibitLogin
}
- if err := user_model.UpdateUser(u, emailChanged); err != nil {
+ if err := user_model.UpdateUser(ctx, u, emailChanged); err != nil {
if user_model.IsErrEmailAlreadyUsed(err) {
ctx.Data["Err_Email"] = true
ctx.RenderWithErr(ctx.Tr("form.email_been_used"), tplUserEdit, &form)
diff --git a/routers/web/admin/users_test.go b/routers/web/admin/users_test.go
index 9de548685c..e63367ccf2 100644
--- a/routers/web/admin/users_test.go
+++ b/routers/web/admin/users_test.go
@@ -47,7 +47,7 @@ func TestNewUserPost_MustChangePassword(t *testing.T) {
assert.NotEmpty(t, ctx.Flash.SuccessMsg)
- u, err := user_model.GetUserByName(username)
+ u, err := user_model.GetUserByName(ctx, username)
assert.NoError(t, err)
assert.Equal(t, username, u.Name)
@@ -84,7 +84,7 @@ func TestNewUserPost_MustChangePasswordFalse(t *testing.T) {
assert.NotEmpty(t, ctx.Flash.SuccessMsg)
- u, err := user_model.GetUserByName(username)
+ u, err := user_model.GetUserByName(ctx, username)
assert.NoError(t, err)
assert.Equal(t, username, u.Name)
@@ -151,7 +151,7 @@ func TestNewUserPost_VisibilityDefaultPublic(t *testing.T) {
assert.NotEmpty(t, ctx.Flash.SuccessMsg)
- u, err := user_model.GetUserByName(username)
+ u, err := user_model.GetUserByName(ctx, username)
assert.NoError(t, err)
assert.Equal(t, username, u.Name)
@@ -190,7 +190,7 @@ func TestNewUserPost_VisibilityPrivate(t *testing.T) {
assert.NotEmpty(t, ctx.Flash.SuccessMsg)
- u, err := user_model.GetUserByName(username)
+ u, err := user_model.GetUserByName(ctx, username)
assert.NoError(t, err)
assert.Equal(t, username, u.Name)