Skip to content

Commit 71d253f

Browse files
wxiaoguangGiteaBot
andauthored
Remove unnecessary template helper DisableGravatar (#26386)
And one "AllowedUserVisibilityModes" was missing, add it. Co-authored-by: Giteabot <[email protected]>
1 parent 78b2a1c commit 71d253f

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

modules/templates/helper.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
package templates
66

77
import (
8-
"context"
98
"fmt"
109
"html"
1110
"html/template"
1211
"net/url"
1312
"strings"
1413
"time"
1514

16-
system_model "code.gitea.io/gitea/models/system"
1715
"code.gitea.io/gitea/modules/base"
1816
"code.gitea.io/gitea/modules/emoji"
1917
"code.gitea.io/gitea/modules/markup"
@@ -104,9 +102,6 @@ func NewFuncMap() template.FuncMap {
104102
"AssetVersion": func() string {
105103
return setting.AssetVersion
106104
},
107-
"DisableGravatar": func(ctx context.Context) bool {
108-
return system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
109-
},
110105
"DefaultShowFullName": func() bool {
111106
return setting.UI.DefaultShowFullName
112107
},

routers/web/admin/users.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"code.gitea.io/gitea/models"
1414
"code.gitea.io/gitea/models/auth"
1515
"code.gitea.io/gitea/models/db"
16+
system_model "code.gitea.io/gitea/models/system"
1617
user_model "code.gitea.io/gitea/models/user"
1718
"code.gitea.io/gitea/modules/auth/password"
1819
"code.gitea.io/gitea/modules/base"
@@ -255,6 +256,7 @@ func EditUser(ctx *context.Context) {
255256
ctx.Data["DisableRegularOrgCreation"] = setting.Admin.DisableRegularOrgCreation
256257
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
257258
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
259+
ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
258260

259261
prepareUserInfo(ctx)
260262
if ctx.Written() {
@@ -271,6 +273,7 @@ func EditUserPost(ctx *context.Context) {
271273
ctx.Data["PageIsAdminUsers"] = true
272274
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
273275
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
276+
ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
274277

275278
u := prepareUserInfo(ctx)
276279
if ctx.Written() {

routers/web/user/setting/profile.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"code.gitea.io/gitea/models/db"
1818
"code.gitea.io/gitea/models/organization"
1919
repo_model "code.gitea.io/gitea/models/repo"
20+
system_model "code.gitea.io/gitea/models/system"
2021
user_model "code.gitea.io/gitea/models/user"
2122
"code.gitea.io/gitea/modules/base"
2223
"code.gitea.io/gitea/modules/context"
@@ -43,6 +44,7 @@ func Profile(ctx *context.Context) {
4344
ctx.Data["Title"] = ctx.Tr("settings.profile")
4445
ctx.Data["PageIsSettingsProfile"] = true
4546
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
47+
ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
4648

4749
ctx.HTML(http.StatusOK, tplSettingsProfile)
4850
}
@@ -83,6 +85,8 @@ func ProfilePost(ctx *context.Context) {
8385
form := web.GetForm(ctx).(*forms.UpdateProfileForm)
8486
ctx.Data["Title"] = ctx.Tr("settings")
8587
ctx.Data["PageIsSettingsProfile"] = true
88+
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
89+
ctx.Data["DisableGravatar"] = system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
8690

8791
if ctx.HasError() {
8892
ctx.HTML(http.StatusOK, tplSettingsProfile)

templates/admin/user/edit.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
<div class="ui attached segment">
160160
<form class="ui form" action="{{.Link}}/avatar" method="post" enctype="multipart/form-data">
161161
{{.CsrfTokenHtml}}
162-
{{if not (DisableGravatar $.Context)}}
162+
{{if not .DisableGravatar}}
163163
<div class="inline field">
164164
<div class="ui radio checkbox">
165165
<input name="source" value="lookup" type="radio" {{if not .User.UseCustomAvatar}}checked{{end}}>

templates/user/settings/profile.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
<div class="ui attached segment">
100100
<form class="ui form" action="{{.Link}}/avatar" method="post" enctype="multipart/form-data">
101101
{{.CsrfTokenHtml}}
102-
{{if not (DisableGravatar $.Context)}}
102+
{{if not .DisableGravatar}}
103103
<div class="inline field">
104104
<div class="ui radio checkbox">
105105
<input name="source" value="lookup" type="radio" {{if not .SignedUser.UseCustomAvatar}}checked{{end}}>

0 commit comments

Comments
 (0)