本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 satır
1.3KB

  1. // Copyright 2018 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package admin
  5. import (
  6. "code.gitea.io/gitea/models"
  7. "code.gitea.io/gitea/modules/base"
  8. "code.gitea.io/gitea/modules/context"
  9. "code.gitea.io/gitea/modules/setting"
  10. )
  11. const (
  12. // tplAdminHooks template path for render hook settings
  13. tplAdminHooks base.TplName = "admin/hooks"
  14. )
  15. // DefaultWebhooks render admin-default webhook list page
  16. func DefaultWebhooks(ctx *context.Context) {
  17. ctx.Data["Title"] = ctx.Tr("admin.hooks")
  18. ctx.Data["PageIsAdminHooks"] = true
  19. ctx.Data["BaseLink"] = setting.AppSubURL + "/admin/hooks"
  20. ctx.Data["Description"] = ctx.Tr("admin.hooks.desc")
  21. ws, err := models.GetDefaultWebhooks()
  22. if err != nil {
  23. ctx.ServerError("GetWebhooksDefaults", err)
  24. return
  25. }
  26. ctx.Data["Webhooks"] = ws
  27. ctx.HTML(200, tplAdminHooks)
  28. }
  29. // DeleteDefaultWebhook response for delete admin-default webhook
  30. func DeleteDefaultWebhook(ctx *context.Context) {
  31. if err := models.DeleteDefaultWebhook(ctx.QueryInt64("id")); err != nil {
  32. ctx.Flash.Error("DeleteDefaultWebhook: " + err.Error())
  33. } else {
  34. ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
  35. }
  36. ctx.JSON(200, map[string]interface{}{
  37. "redirect": setting.AppSubURL + "/admin/hooks",
  38. })
  39. }
上海开阖软件有限公司 沪ICP备12045867号-1