Exemplo n.º 1
0
// RenderWithErr used for page has form validation but need to prompt error to users.
func (ctx *Context) RenderWithErr(msg string, tpl base.TplName, form interface{}) {
	if form != nil {
		auth.AssignForm(form, ctx.Data)
	}
	ctx.Flash.ErrorMsg = msg
	ctx.Data["Flash"] = ctx.Flash
	ctx.HTML(200, tpl)
}
Exemplo n.º 2
0
// @router /install [get]
func Install(ctx *middleware.Context, form auth.InstallForm) {
	if setting.InstallLock {
		ctx.Handle(404, "Install", errors.New("Installation is prohibited"))
		return
	}

	ctx.Data["Title"] = ctx.Tr("install.install")
	ctx.Data["PageIsInstall"] = true

	// Get and assign values to install form.
	if len(form.DbHost) == 0 {
		form.DbHost = models.DbCfg.Host
	}
	if len(form.DbUser) == 0 {
		form.DbUser = models.DbCfg.User
	}
	if len(form.DbPasswd) == 0 {
		form.DbPasswd = models.DbCfg.Pwd
	}
	if len(form.DatabaseName) == 0 {
		form.DatabaseName = models.DbCfg.Name
	}
	if len(form.DatabasePath) == 0 {
		form.DatabasePath = models.DbCfg.Path
	}

	if len(form.RepoRootPath) == 0 {
		form.RepoRootPath = setting.RepoRootPath
	}
	if len(form.RunUser) == 0 {
		form.RunUser = setting.RunUser
	}
	if len(form.Domain) == 0 {
		form.Domain = setting.Domain
	}
	if len(form.AppUrl) == 0 {
		form.AppUrl = setting.AppUrl
	}

	renderDbOption(ctx)
	curDbOp := "MongoDB"
	ctx.Data["CurDbOption"] = curDbOp

	auth.AssignForm(form, ctx.Data)
	ctx.HTML(200, INSTALL)
}