diff options
author | Unknwon <u@gogs.io> | 2017-01-27 22:36:45 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-01-27 22:36:45 -0500 |
commit | 7aa53635fe9a88fbd2d2e21bffc3888e2b4baa85 (patch) | |
tree | 959347f460bbc97971f1df9deec5e912dd627da0 /routers/user/setting.go | |
parent | 2ee0c61e62a47a620bf0e8f55c896616062008c1 (diff) |
Add 'Organizations' page to user settings (#3587)
User is now able to view full list of organizations belongs to.
Diffstat (limited to 'routers/user/setting.go')
-rw-r--r-- | routers/user/setting.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/routers/user/setting.go b/routers/user/setting.go index 14136e9e..ade5967c 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -428,7 +428,7 @@ func SettingsOrganizations(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsOrganizations"] = true - orgs, err := models.GetOrgsByUserID(ctx.User.ID, ctx.IsSigned && ctx.User.IsAdmin) + orgs, err := models.GetOrgsByUserID(ctx.User.ID, true) if err != nil { ctx.Handle(500, "GetOrgsByUserID", err) return @@ -438,6 +438,17 @@ func SettingsOrganizations(ctx *context.Context) { ctx.HTML(200, SETTINGS_ORGANIZATIONS) } +func SettingsLeaveOrganization(ctx *context.Context) { + err := models.RemoveOrgUser(ctx.QueryInt64("id"), ctx.User.ID) + if models.IsErrLastOrgOwner(err) { + ctx.Flash.Error(ctx.Tr("form.last_org_owner")) + } + + ctx.JSON(200, map[string]interface{}{ + "redirect": setting.AppSubUrl + "/user/settings/organizations", + }) +} + func SettingsDelete(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsDelete"] = true |