summaryrefslogtreecommitdiffstats
path: root/routers/web/user/setting
diff options
context:
space:
mode:
authorhazycora <hazysu@riseup.net>2024-02-24 19:13:49 +0100
committerhazycora <hazysu@riseup.net>2024-04-03 22:15:53 +0200
commit20f96796d785603b01d173ef39a732d38790096a (patch)
tree83cf44a98ab58bec143cf8e752dcfa919be2e07c /routers/web/user/setting
parentAdd migration for pronouns (diff)
downloadforgejo-20f96796d785603b01d173ef39a732d38790096a.tar.xz
forgejo-20f96796d785603b01d173ef39a732d38790096a.zip
use recognisedPronouns variable
Diffstat (limited to 'routers/web/user/setting')
-rw-r--r--routers/web/user/setting/profile.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go
index 7a2f6ba46d..e5750e724d 100644
--- a/routers/web/user/setting/profile.go
+++ b/routers/web/user/setting/profile.go
@@ -12,6 +12,7 @@ import (
"net/http"
"os"
"path/filepath"
+ "slices"
"strings"
"code.gitea.io/gitea/models/avatars"
@@ -40,13 +41,17 @@ const (
tplSettingsRepositories base.TplName = "user/settings/repos"
)
+var (
+ recognisedPronouns = []string{"", "he/him", "she/her", "they/them", "it/its", "any/all"}
+)
+
// Profile render user's profile page
func Profile(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings.profile")
ctx.Data["PageIsSettingsProfile"] = true
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
ctx.Data["DisableGravatar"] = setting.Config().Picture.DisableGravatar.Value(ctx)
- ctx.Data["PronounsAreCustom"] = ctx.Doer.Pronouns != "" && ctx.Doer.Pronouns != "he/him" && ctx.Doer.Pronouns != "she/her" && ctx.Doer.Pronouns != "they/them" && ctx.Doer.Pronouns != "it/its" && ctx.Doer.Pronouns != "any/all"
+ ctx.Data["PronounsAreCustom"] = !slices.Contains(recognisedPronouns, ctx.Doer.Pronouns)
ctx.HTML(http.StatusOK, tplSettingsProfile)
}
@@ -57,7 +62,7 @@ func ProfilePost(ctx *context.Context) {
ctx.Data["PageIsSettingsProfile"] = true
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
ctx.Data["DisableGravatar"] = setting.Config().Picture.DisableGravatar.Value(ctx)
- ctx.Data["PronounsAreCustom"] = ctx.Doer.Pronouns != "" && ctx.Doer.Pronouns != "he/him" && ctx.Doer.Pronouns != "she/her" && ctx.Doer.Pronouns != "they/them" && ctx.Doer.Pronouns != "it/its" && ctx.Doer.Pronouns != "any/all"
+ ctx.Data["PronounsAreCustom"] = !slices.Contains(recognisedPronouns, ctx.Doer.Pronouns)
if ctx.HasError() {
ctx.HTML(http.StatusOK, tplSettingsProfile)