Exemplo n.º 1
0
func NewApplicationPost(ctx *context.Context, form NewApplicationForm) {
	ctx.Data["Title"] = "New Application"
	ctx.Data["PageIsApplication"] = true

	if ctx.HasError() {
		ctx.HTML(200, "application/new")
		return
	}

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

	ctx.Redirect(fmt.Sprintf("/applications/%d", app.ID))
}
Exemplo n.º 2
0
func NewCollectorPost(ctx *context.Context, form NewCollectorForm) {
	ctx.Data["Title"] = "New Collector"
	ctx.Data["PageIsCollector"] = true

	if ctx.HasError() {
		ctx.HTML(200, "collector/new")
		return
	}

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

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