summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorGusted <gusted@noreply.codeberg.org>2024-04-06 14:23:54 +0200
committerGusted <gusted@noreply.codeberg.org>2024-04-06 14:23:54 +0200
commitd8eebe7698ab6f3eb28475ea471592939be3a30a (patch)
tree92591e75849e8ede90e35306aadbbed24fda622e /routers
parentMerge pull request 'feat: extend webfinger to respond to profile page URIs' (... (diff)
parentuse EqualValues in test of pronouns not being displayed when unspecified (diff)
downloadforgejo-d8eebe7698ab6f3eb28475ea471592939be3a30a.tar.xz
forgejo-d8eebe7698ab6f3eb28475ea471592939be3a30a.zip
Merge pull request 'Add optional pronoun field in user settings' (#1518) from hazy/forgejo:feat/pronoun-field into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/1518 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Gergely Nagy <algernon@noreply.codeberg.org>
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/admin/user.go1
-rw-r--r--routers/api/v1/user/settings.go1
-rw-r--r--routers/web/admin/users.go1
-rw-r--r--routers/web/user/setting/profile.go7
4 files changed, 10 insertions, 0 deletions
diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go
index 87a5b28fad..12da8a9597 100644
--- a/routers/api/v1/admin/user.go
+++ b/routers/api/v1/admin/user.go
@@ -236,6 +236,7 @@ func EditUser(ctx *context.APIContext) {
Website: optional.FromPtr(form.Website),
Location: optional.FromPtr(form.Location),
Description: optional.FromPtr(form.Description),
+ Pronouns: optional.FromPtr(form.Pronouns),
IsActive: optional.FromPtr(form.Active),
IsAdmin: optional.FromPtr(form.Admin),
Visibility: optional.FromNonDefault(api.VisibilityModes[form.Visibility]),
diff --git a/routers/api/v1/user/settings.go b/routers/api/v1/user/settings.go
index f594eb211c..bfd24013db 100644
--- a/routers/api/v1/user/settings.go
+++ b/routers/api/v1/user/settings.go
@@ -48,6 +48,7 @@ func UpdateUserSettings(ctx *context.APIContext) {
opts := &user_service.UpdateOptions{
FullName: optional.FromPtr(form.FullName),
Description: optional.FromPtr(form.Description),
+ Pronouns: optional.FromPtr(form.Pronouns),
Website: optional.FromPtr(form.Website),
Location: optional.FromPtr(form.Location),
Language: optional.FromPtr(form.Language),
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go
index b93668c5a2..3dcf0d2aa8 100644
--- a/routers/web/admin/users.go
+++ b/routers/web/admin/users.go
@@ -435,6 +435,7 @@ func EditUserPost(ctx *context.Context) {
FullName: optional.Some(form.FullName),
Website: optional.Some(form.Website),
Location: optional.Some(form.Location),
+ Pronouns: optional.Some(form.Pronouns),
IsActive: optional.Some(form.Active),
IsAdmin: optional.Some(form.Admin),
AllowGitHook: optional.Some(form.AllowGitHook),
diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go
index 4e5c380ed9..a39c118ddd 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,12 +41,16 @@ const (
tplSettingsRepositories base.TplName = "user/settings/repos"
)
+// must be kept in sync with `web_src/js/features/user-settings.js`
+var recognisedPronouns = []string{"", "he/him", "she/her", "they/them", "it/its", "any pronouns"}
+
// 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"] = !slices.Contains(recognisedPronouns, ctx.Doer.Pronouns)
ctx.HTML(http.StatusOK, tplSettingsProfile)
}
@@ -56,6 +61,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"] = !slices.Contains(recognisedPronouns, ctx.Doer.Pronouns)
if ctx.HasError() {
ctx.HTML(http.StatusOK, tplSettingsProfile)
@@ -90,6 +96,7 @@ func ProfilePost(ctx *context.Context) {
FullName: optional.Some(form.FullName),
KeepEmailPrivate: optional.Some(form.KeepEmailPrivate),
Description: optional.Some(form.Description),
+ Pronouns: optional.Some(form.Pronouns),
Website: optional.Some(form.Website),
Location: optional.Some(form.Location),
Visibility: optional.Some(form.Visibility),