summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorTamás Molnár <moltam@gmail.com>2016-03-06 17:36:30 +0100
committerTamás Molnár <moltam@gmail.com>2016-03-06 17:36:30 +0100
commit9c91e279338f4d8bf09e1f7f5904d34cd525b102 (patch)
tree32882aa197724e0f75608c9bfd16a24650b7be22 /routers
parentc2ca103d30b0f47b5ad0fa544ab5a07263894ea3 (diff)
downloadgitea-9c91e279338f4d8bf09e1f7f5904d34cd525b102.tar.gz
gitea-9c91e279338f4d8bf09e1f7f5904d34cd525b102.zip
Added: Ability to delete org avatar.
Diffstat (limited to 'routers')
-rw-r--r--routers/org/setting.go8
-rw-r--r--routers/user/setting.go9
2 files changed, 11 insertions, 6 deletions
diff --git a/routers/org/setting.go b/routers/org/setting.go
index 0b1b512d34..29ce34f5d9 100644
--- a/routers/org/setting.go
+++ b/routers/org/setting.go
@@ -96,6 +96,14 @@ func SettingsAvatar(ctx *middleware.Context, form auth.UploadAvatarForm) {
ctx.Redirect(ctx.Org.OrgLink + "/settings")
}
+func SettingsDeleteAvatar(ctx *middleware.Context) {
+ if err := ctx.Org.Organization.DeleteAvatar(); err != nil {
+ ctx.Flash.Error(err.Error())
+ }
+
+ ctx.Redirect(ctx.Org.OrgLink + "/settings")
+}
+
func SettingsDelete(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("org.settings")
ctx.Data["PageIsSettingsDelete"] = true
diff --git a/routers/user/setting.go b/routers/user/setting.go
index 8d1b24dd8c..c704b67ce0 100644
--- a/routers/user/setting.go
+++ b/routers/user/setting.go
@@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"io/ioutil"
- "os"
"strings"
"github.com/Unknwon/com"
@@ -156,12 +155,10 @@ func SettingsAvatar(ctx *middleware.Context, form auth.UploadAvatarForm) {
}
func SettingsDeleteAvatar(ctx *middleware.Context) {
- os.Remove(ctx.User.CustomAvatarPath())
-
- ctx.User.UseCustomAvatar = false
- if err := models.UpdateUser(ctx.User); err != nil {
- ctx.Flash.Error(fmt.Sprintf("UpdateUser: %v", err))
+ if err := ctx.User.DeleteAvatar(); err != nil {
+ ctx.Flash.Error(err.Error())
}
+
ctx.Redirect(setting.AppSubUrl + "/user/settings")
}