add pronoun field to user profiles

This commit is contained in:
hazycora 2023-09-25 21:39:12 -05:00
parent efd0f0f224
commit f8e48e066a
No known key found for this signature in database
GPG key ID: 215AF1F81F86940E
11 changed files with 19 additions and 1 deletions

View file

@ -95,6 +95,7 @@ type User struct {
Type UserType
Location string
Website string
Pronouns string
Rands string `xorm:"VARCHAR(32)"`
Salt string `xorm:"VARCHAR(32)"`
Language string `xorm:"VARCHAR(5)"`

View file

@ -41,6 +41,7 @@ type EditUserOption struct {
MustChangePassword *bool `json:"must_change_password"`
Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
Location *string `json:"location" binding:"MaxSize(50)"`
Pronouns *string `json:"pronouns" binding:"MaxSize(50)"`
Description *string `json:"description" binding:"MaxSize(255)"`
Active *bool `json:"active"`
Admin *bool `json:"admin"`

View file

@ -87,6 +87,7 @@ type UserSettingsOptions struct {
Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
Description *string `json:"description" binding:"MaxSize(255)"`
Location *string `json:"location" binding:"MaxSize(50)"`
Pronouns *string `json:"pronouns" binding:"MaxSize(50)"`
Language *string `json:"language"`
Theme *string `json:"theme"`
DiffViewStyle *string `json:"diff_view_style"`

View file

@ -701,6 +701,7 @@ password_username_disabled = Non-local users are not allowed to change their use
full_name = Full name
website = Website
location = Location
pronouns = Pronouns
update_theme = Change theme
update_profile = Update profile
update_language = Change language

View file

@ -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]),

View file

@ -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),

View file

@ -90,6 +90,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),

View file

@ -218,6 +218,7 @@ type UpdateProfileForm struct {
KeepEmailPrivate bool
Website string `binding:"ValidSiteUrl;MaxSize(255)"`
Location string `binding:"MaxSize(50)"`
Pronouns string `binding:"MaxSize(50)"`
Description string `binding:"MaxSize(255)"`
Visibility structs.VisibleType
KeepActivityPrivate bool

View file

@ -22,6 +22,7 @@ type UpdateOptions struct {
Website optional.Option[string]
Location optional.Option[string]
Description optional.Option[string]
Pronouns optional.Option[string]
AllowGitHook optional.Option[bool]
AllowImportLocal optional.Option[bool]
MaxRepoCreation optional.Option[int]
@ -54,6 +55,11 @@ func UpdateUser(ctx context.Context, u *user_model.User, opts *UpdateOptions) er
cols = append(cols, "full_name")
}
if opts.Pronouns.Has() {
u.Pronouns = opts.Pronouns.Value()
cols = append(cols, "pronouns")
}
if opts.Website.Has() {
u.Website = opts.Website.Value()

View file

@ -13,7 +13,7 @@
</div>
<div class="content gt-word-break profile-avatar-name">
{{if .ContextUser.FullName}}<span class="header text center">{{.ContextUser.FullName}}</span>{{end}}
<span class="username text center">{{.ContextUser.Name}} {{if .IsAdmin}}
<span class="username text center">{{.ContextUser.Name}}{{if .ContextUser.Pronouns}} · {{.ContextUser.Pronouns}}{{end}} {{if .IsAdmin}}
<a class="muted" href="{{AppSubUrl}}/admin/users/{{.ContextUser.ID}}" data-tooltip-content="{{ctx.Locale.Tr "admin.users.details"}}">
{{svg "octicon-gear" 18}}
</a>

View file

@ -37,6 +37,10 @@
<label for="location">{{ctx.Locale.Tr "settings.location"}}</label>
<input id="location" name="location" placeholder="{{ctx.Locale.Tr "settings.location_placeholder"}}" value="{{.SignedUser.Location}}" maxlength="50">
</div>
<div class="field">
<label for="pronouns">{{.locale.Tr "settings.pronouns"}}</label>
<input id="pronouns" name="pronouns" value="{{.SignedUser.Pronouns}}" maxlength="50">
</div>
<div class="divider"></div>
<!-- private block -->