(c *context.Context, orCtx *orgRepoContext, w *database.Webhook)
| 335 | } |
| 336 | |
| 337 | func validateAndUpdateWebhook(c *context.Context, orCtx *orgRepoContext, w *database.Webhook) { |
| 338 | c.Data["Webhook"] = w |
| 339 | |
| 340 | if c.HasError() { |
| 341 | c.HTML(http.StatusBadRequest, orCtx.TmplNew) |
| 342 | return |
| 343 | } |
| 344 | |
| 345 | field, msg, status := validateWebhook(c.Locale, w) |
| 346 | if status != http.StatusOK { |
| 347 | c.FormErr(field) |
| 348 | c.RenderWithErr(msg, status, orCtx.TmplNew, nil) |
| 349 | return |
| 350 | } |
| 351 | |
| 352 | if err := w.UpdateEvent(); err != nil { |
| 353 | c.Error(err, "update event") |
| 354 | return |
| 355 | } else if err := database.UpdateWebhook(w); err != nil { |
| 356 | c.Error(err, "update webhook") |
| 357 | return |
| 358 | } |
| 359 | |
| 360 | c.Flash.Success(c.Tr("repo.settings.update_hook_success")) |
| 361 | c.Redirect(fmt.Sprintf("%s/settings/hooks/%d", orCtx.Link, w.ID)) |
| 362 | } |
| 363 | |
| 364 | func WebhooksEditPost(c *context.Context, orCtx *orgRepoContext, f form.NewWebhook) { |
| 365 | c.Title("repo.settings.update_webhook") |
no test coverage detected