aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/org
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-09-14 19:09:32 +0200
committerGitHub <noreply@github.com>2023-09-14 17:09:32 +0000
commit76659b1114153603050de810006e04a938e9dcb7 (patch)
treeed180213ca459bca51c44dbcc55fd3f9bc2d0460 /routers/web/org
parent0de09d3afcb5394cbd97e4a1c5609eb8b2acb6cf (diff)
downloadgitea-76659b1114153603050de810006e04a938e9dcb7.tar.gz
gitea-76659b1114153603050de810006e04a938e9dcb7.zip
Reduce usage of `db.DefaultContext` (#27073)
Part of #27065 This reduces the usage of `db.DefaultContext`. I think I've got enough files for the first PR. When this is merged, I will continue working on this. Considering how many files this PR affect, I hope it won't take to long to merge, so I don't end up in the merge conflict hell. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/web/org')
-rw-r--r--routers/web/org/home.go2
-rw-r--r--routers/web/org/members.go4
-rw-r--r--routers/web/org/teams.go20
3 files changed, 13 insertions, 13 deletions
diff --git a/routers/web/org/home.go b/routers/web/org/home.go
index a69fdedba4..15386393e9 100644
--- a/routers/web/org/home.go
+++ b/routers/web/org/home.go
@@ -123,7 +123,7 @@ func Home(ctx *context.Context) {
PublicOnly: ctx.Org.PublicMemberOnly,
ListOptions: db.ListOptions{Page: 1, PageSize: 25},
}
- members, _, err := organization.FindOrgMembers(opts)
+ members, _, err := organization.FindOrgMembers(ctx, opts)
if err != nil {
ctx.ServerError("FindOrgMembers", err)
return
diff --git a/routers/web/org/members.go b/routers/web/org/members.go
index f963ad55ef..34cff05ea0 100644
--- a/routers/web/org/members.go
+++ b/routers/web/org/members.go
@@ -62,7 +62,7 @@ func Members(ctx *context.Context) {
pager := context.NewPagination(int(total), setting.UI.MembersPagingNum, page, 5)
opts.ListOptions.Page = page
opts.ListOptions.PageSize = setting.UI.MembersPagingNum
- members, membersIsPublic, err := organization.FindOrgMembers(opts)
+ members, membersIsPublic, err := organization.FindOrgMembers(ctx, opts)
if err != nil {
ctx.ServerError("GetMembers", err)
return
@@ -71,7 +71,7 @@ func Members(ctx *context.Context) {
ctx.Data["Members"] = members
ctx.Data["MembersIsPublicMember"] = membersIsPublic
ctx.Data["MembersIsUserOrgOwner"] = organization.IsUserOrgOwner(members, org.ID)
- ctx.Data["MembersTwoFaStatus"] = members.GetTwoFaStatus()
+ ctx.Data["MembersTwoFaStatus"] = members.GetTwoFaStatus(ctx)
ctx.HTML(http.StatusOK, tplMembers)
}
diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go
index 2fd2a681af..46ca68b612 100644
--- a/routers/web/org/teams.go
+++ b/routers/web/org/teams.go
@@ -78,9 +78,9 @@ func TeamsAction(ctx *context.Context) {
ctx.Error(http.StatusNotFound)
return
}
- err = models.AddTeamMember(ctx.Org.Team, ctx.Doer.ID)
+ err = models.AddTeamMember(ctx, ctx.Org.Team, ctx.Doer.ID)
case "leave":
- err = models.RemoveTeamMember(ctx.Org.Team, ctx.Doer.ID)
+ err = models.RemoveTeamMember(ctx, ctx.Org.Team, ctx.Doer.ID)
if err != nil {
if org_model.IsErrLastOrgOwner(err) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
@@ -107,7 +107,7 @@ func TeamsAction(ctx *context.Context) {
return
}
- err = models.RemoveTeamMember(ctx.Org.Team, uid)
+ err = models.RemoveTeamMember(ctx, ctx.Org.Team, uid)
if err != nil {
if org_model.IsErrLastOrgOwner(err) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
@@ -162,7 +162,7 @@ func TeamsAction(ctx *context.Context) {
if ctx.Org.Team.IsMember(u.ID) {
ctx.Flash.Error(ctx.Tr("org.teams.add_duplicate_users"))
} else {
- err = models.AddTeamMember(ctx.Org.Team, u.ID)
+ err = models.AddTeamMember(ctx, ctx.Org.Team, u.ID)
}
page = "team"
@@ -251,9 +251,9 @@ func TeamsRepoAction(ctx *context.Context) {
case "remove":
err = repo_service.RemoveRepositoryFromTeam(ctx, ctx.Org.Team, ctx.FormInt64("repoid"))
case "addall":
- err = models.AddAllRepositories(ctx.Org.Team)
+ err = models.AddAllRepositories(ctx, ctx.Org.Team)
case "removeall":
- err = models.RemoveAllRepositories(ctx.Org.Team)
+ err = models.RemoveAllRepositories(ctx, ctx.Org.Team)
}
if err != nil {
@@ -352,7 +352,7 @@ func NewTeamPost(ctx *context.Context) {
return
}
- if err := models.NewTeam(t); err != nil {
+ if err := models.NewTeam(ctx, t); err != nil {
ctx.Data["Err_TeamName"] = true
switch {
case org_model.IsErrTeamAlreadyExist(err):
@@ -526,7 +526,7 @@ func EditTeamPost(ctx *context.Context) {
return
}
- if err := models.UpdateTeam(t, isAuthChanged, isIncludeAllChanged); err != nil {
+ if err := models.UpdateTeam(ctx, t, isAuthChanged, isIncludeAllChanged); err != nil {
ctx.Data["Err_TeamName"] = true
switch {
case org_model.IsErrTeamAlreadyExist(err):
@@ -541,7 +541,7 @@ func EditTeamPost(ctx *context.Context) {
// DeleteTeam response for the delete team request
func DeleteTeam(ctx *context.Context) {
- if err := models.DeleteTeam(ctx.Org.Team); err != nil {
+ if err := models.DeleteTeam(ctx, ctx.Org.Team); err != nil {
ctx.Flash.Error("DeleteTeam: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("org.teams.delete_team_success"))
@@ -583,7 +583,7 @@ func TeamInvitePost(ctx *context.Context) {
return
}
- if err := models.AddTeamMember(team, ctx.Doer.ID); err != nil {
+ if err := models.AddTeamMember(ctx, team, ctx.Doer.ID); err != nil {
ctx.ServerError("AddTeamMember", err)
return
}