From 7aa53635fe9a88fbd2d2e21bffc3888e2b4baa85 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 27 Jan 2017 22:36:45 -0500 Subject: Add 'Organizations' page to user settings (#3587) User is now able to view full list of organizations belongs to. --- routers/user/setting.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'routers/user/setting.go') 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 -- cgit v1.2.3