File tree 4 files changed +72
-0
lines changed
4 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -545,6 +545,7 @@ delete_current_avatar = Delete Current Avatar
545
545
uploaded_avatar_not_a_image = The uploaded file is not an image.
546
546
uploaded_avatar_is_too_big = The uploaded file has exceeded the maximum size.
547
547
update_avatar_success = Your avatar has been updated.
548
+ update_user_avatar_success = The user' s avatar has been updated.
548
549
549
550
change_password = Update Password
550
551
old_password = Current Password
Original file line number Diff line number Diff line change @@ -401,3 +401,34 @@ func DeleteUser(ctx *context.Context) {
401
401
"redirect" : setting .AppSubURL + "/admin/users" ,
402
402
})
403
403
}
404
+
405
+ // AvatarPost response for change user's avatar request
406
+ func AvatarPost (ctx * context.Context ) {
407
+ u := prepareUserInfo (ctx )
408
+ if ctx .Written () {
409
+ return
410
+ }
411
+
412
+ form := web .GetForm (ctx ).(* forms.AvatarForm )
413
+ if err := router_user_setting .UpdateAvatarSetting (ctx , form , u ); err != nil {
414
+ ctx .Flash .Error (err .Error ())
415
+ } else {
416
+ ctx .Flash .Success (ctx .Tr ("settings.update_user_avatar_success" ))
417
+ }
418
+
419
+ ctx .Redirect (setting .AppSubURL + "/admin/users/" + strconv .FormatInt (u .ID , 10 ))
420
+ }
421
+
422
+ // DeleteAvatar render delete avatar page
423
+ func DeleteAvatar (ctx * context.Context ) {
424
+ u := prepareUserInfo (ctx )
425
+ if ctx .Written () {
426
+ return
427
+ }
428
+
429
+ if err := u .DeleteAvatar (); err != nil {
430
+ ctx .Flash .Error (err .Error ())
431
+ }
432
+
433
+ ctx .Redirect (setting .AppSubURL + "/admin/users/" + strconv .FormatInt (u .ID , 10 ))
434
+ }
Original file line number Diff line number Diff line change @@ -408,6 +408,8 @@ func RegisterRoutes(m *web.Route) {
408
408
m .Combo ("/new" ).Get (admin .NewUser ).Post (bindIgnErr (forms.AdminCreateUserForm {}), admin .NewUserPost )
409
409
m .Combo ("/{userid}" ).Get (admin .EditUser ).Post (bindIgnErr (forms.AdminEditUserForm {}), admin .EditUserPost )
410
410
m .Post ("/{userid}/delete" , admin .DeleteUser )
411
+ m .Post ("/{userid}/avatar" , bindIgnErr (forms.AvatarForm {}), admin .AvatarPost )
412
+ m .Post ("/{userid}/avatar/delete" , admin .DeleteAvatar )
411
413
})
412
414
413
415
m .Group ("/emails" , func () {
Original file line number Diff line number Diff line change 155
155
</div>
156
156
</form>
157
157
</div>
158
+
159
+ <h4 class="ui top attached header">
160
+ {{.i18n.Tr "settings.avatar"}}
161
+ </h4>
162
+ <div class="ui attached segment">
163
+ <form class="ui form" action="{{.Link}}/avatar" method="post" enctype="multipart/form-data">
164
+ {{.CsrfTokenHtml}}
165
+ {{if not DisableGravatar}}
166
+ <div class="inline field">
167
+ <div class="ui radio checkbox">
168
+ <input name="source" value="lookup" type="radio" {{if not .User.UseCustomAvatar}}checked{{end}}>
169
+ <label>{{.i18n.Tr "settings.lookup_avatar_by_mail"}}</label>
170
+ </div>
171
+ </div>
172
+ <div class="field {{if .Err_Gravatar}}error{{end}}">
173
+ <label for="gravatar">Avatar {{.i18n.Tr "email"}}</label>
174
+ <input id="gravatar" name="gravatar" value="{{.User.AvatarEmail}}" />
175
+ </div>
176
+ {{end}}
177
+
178
+ <div class="inline field">
179
+ <div class="ui radio checkbox">
180
+ <input name="source" value="local" type="radio" {{if .User.UseCustomAvatar}}checked{{end}}>
181
+ <label>{{.i18n.Tr "settings.enable_custom_avatar"}}</label>
182
+ </div>
183
+ </div>
184
+
185
+ <div class="inline field">
186
+ <label for="avatar">{{.i18n.Tr "settings.choose_new_avatar"}}</label>
187
+ <input name="avatar" type="file" >
188
+ </div>
189
+
190
+ <div class="field">
191
+ <button class="ui green button">{{$.i18n.Tr "settings.update_avatar"}}</button>
192
+ <a class="ui red button delete-post" data-request-url="{{.Link}}/avatar/delete" data-done-url="{{.Link}}">{{$.i18n.Tr "settings.delete_current_avatar"}}</a>
193
+ </div>
194
+ </form>
195
+ </div>
158
196
</div>
159
197
</div>
160
198
You can’t perform that action at this time.
0 commit comments