diff options
author | Christopher Brickley <brickley@gmail.com> | 2014-09-04 07:17:00 -0400 |
---|---|---|
committer | Christopher Brickley <brickley@gmail.com> | 2014-09-05 07:19:34 -0400 |
commit | 85c35a6b8bb7430568d375d1e792e1417bbd7f4b (patch) | |
tree | d269e4a890036a76d8f8cd60f8d65e7a0c80d865 /routers/org | |
parent | 7269b06fd5992776c07ae0303f85e0d05b1e62e9 (diff) | |
download | gitea-85c35a6b8bb7430568d375d1e792e1417bbd7f4b.tar.gz gitea-85c35a6b8bb7430568d375d1e792e1417bbd7f4b.zip |
add organization-level webhooks
Diffstat (limited to 'routers/org')
-rw-r--r-- | routers/org/setting.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/routers/org/setting.go b/routers/org/setting.go index 0ddf0065cc..f853ef0e8e 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -5,6 +5,7 @@ package org import ( + "github.com/Unknwon/com" "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" @@ -15,6 +16,7 @@ import ( const ( SETTINGS_OPTIONS base.TplName = "org/settings/options" SETTINGS_DELETE base.TplName = "org/settings/delete" + SETTINGS_HOOKS base.TplName = "org/settings/hooks" ) func Settings(ctx *middleware.Context) { @@ -97,3 +99,29 @@ func SettingsDelete(ctx *middleware.Context) { ctx.HTML(200, SETTINGS_DELETE) } + +func SettingsHooks(ctx *middleware.Context) { + ctx.Data["Title"] = ctx.Tr("org.settings") + ctx.Data["PageIsSettingsHooks"] = true + + // Delete web hook. + remove := com.StrTo(ctx.Query("remove")).MustInt64() + if remove > 0 { + if err := models.DeleteWebhook(remove); err != nil { + ctx.Handle(500, "DeleteWebhook", err) + return + } + ctx.Flash.Success(ctx.Tr("repo.settings.remove_hook_success")) + ctx.Redirect(ctx.Org.OrgLink + "/settings/hooks") + return + } + + ws, err := models.GetWebhooksByOrgId(ctx.Org.Organization.Id) + if err != nil { + ctx.Handle(500, "GetWebhooksByOrgId", err) + return + } + + ctx.Data["Webhooks"] = ws + ctx.HTML(200, SETTINGS_HOOKS) +} |