Example #1
0
func EditApplication(ctx *context.Context) {
	ctx.Data["Title"] = "Edit Application"
	ctx.Data["PageIsApplication"] = true

	parseApplicationByID(ctx)
	if ctx.Written() {
		return
	}

	ctx.HTML(200, "application/edit")
}
Example #2
0
func EditCollector(ctx *context.Context) {
	ctx.Data["Title"] = "Edit Collector"
	ctx.Data["PageIsCollector"] = true

	parseCollectorByID(ctx)
	if ctx.Written() {
		return
	}

	ctx.HTML(200, "collector/edit")
}
Example #3
0
func EditApplicationPost(ctx *context.Context, form NewApplicationForm) {
	ctx.Data["Title"] = "Edit Application"
	ctx.Data["PageIsApplication"] = true

	app := parseApplicationByID(ctx)
	if ctx.Written() {
		return
	}

	app.Name = form.Name
	if err := models.UpdateApplication(app); err != nil {
		if errors.IsApplicationExists(err) {
			ctx.Data["Err_Name"] = true
			ctx.RenderWithErr("Application name has been used.", "application/edit", form)
		} else {
			ctx.Error(500, err.Error())
		}
		return
	}

	ctx.Redirect(fmt.Sprintf("/applications/%d", app.ID))
}
Example #4
0
func EditCollectorPost(ctx *context.Context, form NewCollectorForm) {
	ctx.Data["Title"] = "Edit Collector"
	ctx.Data["PageIsCollector"] = true

	collector := parseCollectorByID(ctx)
	if ctx.Written() {
		return
	}

	collector.Name = form.Name
	if err := models.UpdateCollector(collector); err != nil {
		if errors.IsCollectorExists(err) {
			ctx.Data["Err_Name"] = true
			ctx.RenderWithErr("Collector name has been used.", "collector/edit", form)
		} else {
			ctx.Error(500, err.Error())
		}
		return
	}

	ctx.Redirect(fmt.Sprintf("/collectors/%d", collector.ID))
}