Skip to content

Commit d1c982c

Browse files
Add bio field for user (#6113)
Fix #4339
1 parent ba2f6a4 commit d1c982c

File tree

6 files changed

+19
-6
lines changed

6 files changed

+19
-6
lines changed

models/user.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ type User struct {
104104
Rands string `xorm:"VARCHAR(10)"`
105105
Salt string `xorm:"VARCHAR(10)"`
106106
Language string `xorm:"VARCHAR(5)"`
107+
Description string
107108

108109
CreatedUnix util.TimeStamp `xorm:"INDEX created"`
109110
UpdatedUnix util.TimeStamp `xorm:"INDEX updated"`
@@ -134,12 +135,11 @@ type User struct {
134135
NumRepos int
135136

136137
// For organization
137-
Description string
138-
NumTeams int
139-
NumMembers int
140-
Teams []*Team `xorm:"-"`
141-
Members []*User `xorm:"-"`
142-
Visibility structs.VisibleType `xorm:"NOT NULL DEFAULT 0"`
138+
NumTeams int
139+
NumMembers int
140+
Teams []*Team `xorm:"-"`
141+
Members []*User `xorm:"-"`
142+
Visibility structs.VisibleType `xorm:"NOT NULL DEFAULT 0"`
143143

144144
// Preferences
145145
DiffViewStyle string `xorm:"NOT NULL DEFAULT ''"`

modules/auth/user_form.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ type UpdateProfileForm struct {
201201
Website string `binding:"ValidUrl;MaxSize(255)"`
202202
Location string `binding:"MaxSize(50)"`
203203
Language string `binding:"Size(5)"`
204+
Description string `binding:"MaxSize(255)"`
204205
}
205206

206207
// Validate validates the fields

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ following = Following
334334
follow = Follow
335335
unfollow = Unfollow
336336
heatmap.loading = Loading Heatmap…
337+
user_bio = Biography
337338

338339
form.name_reserved = The username '%s' is reserved.
339340
form.name_pattern_not_allowed = The pattern '%s' is not allowed in a username.

routers/user/setting/profile.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func ProfilePost(ctx *context.Context, form auth.UpdateProfileForm) {
9292
ctx.User.Website = form.Website
9393
ctx.User.Location = form.Location
9494
ctx.User.Language = form.Language
95+
ctx.User.Description = form.Description
9596
if err := models.UpdateUserSetting(ctx.User); err != nil {
9697
if _, ok := err.(models.ErrEmailAlreadyUsed); ok {
9798
ctx.Flash.Error(ctx.Tr("form.email_been_used"))

templates/user/profile.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
<a target="_blank" rel="noopener noreferrer me" href="{{.Owner.Website}}">{{.Owner.Website}}</a>
3535
</li>
3636
{{end}}
37+
{{if .Owner.Description}}
38+
<li>
39+
<i class="octicon octicon-info"></i>
40+
<span>{{.Owner.Description}}</span>
41+
</li>
42+
{{end}}
3743
{{range .OpenIDs}}
3844
{{if .Show}}
3945
<li>

templates/user/settings/profile.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
<input name="keep_email_private" type="checkbox" {{if .SignedUser.KeepEmailPrivate}}checked{{end}}>
3232
</div>
3333
</div>
34+
<div class="field {{if .Err_Description}}error{{end}}">
35+
<label for="description">{{$.i18n.Tr "user.user_bio"}}</label>
36+
<textarea id="description" name="description" rows="2">{{.SignedUser.Description}}</textarea>
37+
</div>
3438
<div class="field {{if .Err_Website}}error{{end}}">
3539
<label for="website">{{.i18n.Tr "settings.website"}}</label>
3640
<input id="website" name="website" type="url" value="{{.SignedUser.Website}}">

0 commit comments

Comments
 (0)