func (ctl *AlertController) postEditAlertsGroupAction(c *gin.Context) { var form models.AlertGroupUpdateForm if err := c.Bind(&form); err != nil { c.AbortWithStatus(http.StatusBadRequest) return } ag, err := models.AlertGroupMapper.FetchOne(c.Param("id")) if err != nil { panic(err) } if ag == nil { c.Redirect(http.StatusFound, "/alerts-groups") return } if err := form.Validate(ag); err != nil { c.HTML(http.StatusOK, "alert_group_edit.html", map[string]interface{}{ "errors": err.Errors, "form": form, "ag": ag, }) return } ag.Update(&form) if err := models.AlertGroupMapper.Update(ag); err != nil { panic(err) } c.Redirect(http.StatusFound, "/alerts-groups") }
func (ctl *AlertController) getEditAlertsGroupAction(c *gin.Context) { ag, err := models.AlertGroupMapper.FetchOne(c.Param("id")) if err != nil { panic(err) } if ag == nil { c.Redirect(http.StatusFound, "/alerts-groups") return } var form models.AlertGroupUpdateForm form.Hydrate(ag) c.HTML(http.StatusOK, "alert_group_edit.html", map[string]interface{}{ "form": form, "ag": ag, }) }