From d1c982cb731a0744e2a8e0863b46ff9e99c99b63 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Mon, 18 Mar 2019 22:28:10 -0400 Subject: [PATCH] Add bio field for user (#6113) Fix #4339 --- models/user.go | 12 ++++++------ modules/auth/user_form.go | 1 + options/locale/locale_en-US.ini | 1 + routers/user/setting/profile.go | 1 + templates/user/profile.tmpl | 6 ++++++ templates/user/settings/profile.tmpl | 4 ++++ 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/models/user.go b/models/user.go index 1ed949355..8fc15848c 100644 --- a/models/user.go +++ b/models/user.go @@ -104,6 +104,7 @@ type User struct { Rands string `xorm:"VARCHAR(10)"` Salt string `xorm:"VARCHAR(10)"` Language string `xorm:"VARCHAR(5)"` + Description string CreatedUnix util.TimeStamp `xorm:"INDEX created"` UpdatedUnix util.TimeStamp `xorm:"INDEX updated"` @@ -134,12 +135,11 @@ type User struct { NumRepos int // For organization - Description string - NumTeams int - NumMembers int - Teams []*Team `xorm:"-"` - Members []*User `xorm:"-"` - Visibility structs.VisibleType `xorm:"NOT NULL DEFAULT 0"` + NumTeams int + NumMembers int + Teams []*Team `xorm:"-"` + Members []*User `xorm:"-"` + Visibility structs.VisibleType `xorm:"NOT NULL DEFAULT 0"` // Preferences DiffViewStyle string `xorm:"NOT NULL DEFAULT ''"` diff --git a/modules/auth/user_form.go b/modules/auth/user_form.go index be0f9bf1b..78dd75fa1 100644 --- a/modules/auth/user_form.go +++ b/modules/auth/user_form.go @@ -201,6 +201,7 @@ type UpdateProfileForm struct { Website string `binding:"ValidUrl;MaxSize(255)"` Location string `binding:"MaxSize(50)"` Language string `binding:"Size(5)"` + Description string `binding:"MaxSize(255)"` } // Validate validates the fields diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 6662400ad..06e4e2c55 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -334,6 +334,7 @@ following = Following follow = Follow unfollow = Unfollow heatmap.loading = Loading Heatmap… +user_bio = Biography form.name_reserved = The username '%s' is reserved. form.name_pattern_not_allowed = The pattern '%s' is not allowed in a username. diff --git a/routers/user/setting/profile.go b/routers/user/setting/profile.go index 09073498f..96210b79f 100644 --- a/routers/user/setting/profile.go +++ b/routers/user/setting/profile.go @@ -92,6 +92,7 @@ func ProfilePost(ctx *context.Context, form auth.UpdateProfileForm) { ctx.User.Website = form.Website ctx.User.Location = form.Location ctx.User.Language = form.Language + ctx.User.Description = form.Description if err := models.UpdateUserSetting(ctx.User); err != nil { if _, ok := err.(models.ErrEmailAlreadyUsed); ok { ctx.Flash.Error(ctx.Tr("form.email_been_used")) diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index f65776bdf..6170c6d13 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -34,6 +34,12 @@ {{.Owner.Website}} {{end}} + {{if .Owner.Description}} +
  • + + {{.Owner.Description}} +
  • + {{end}} {{range .OpenIDs}} {{if .Show}}
  • diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index 6a654fda7..995bdfd63 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -31,6 +31,10 @@ +
    + + +