示例#1
0
func AboutHandler(ctx *middleware.Context) {
	settings := model.GetSettings()
	about := ctx.R.FormValue("about")
	settings.About = about
	err := settings.Update()
	PanicIf(err)
	dbSettings := model.GetSettings()
	ctx.S.Set("Settings", dbSettings)

	ctx.Redirect("/about")
}
示例#2
0
func SettingsHandler(ctx *middleware.Context, settings model.Settings) {
	if ctx.R.Method == "POST" {
		err := settings.Update()
		PanicIf(err)
		dbSettings := model.GetSettings()
		ctx.AddMessage(Translate(ctx.S.Get("Lang").(string), "message.change.success"))
		ctx.S.Set("Settings", dbSettings)
	}
	user := &model.User{}
	users, err := user.SelectAll()
	PanicIf(err)
	ctx.Set("Users", users)

	ctx.HTML(200, "admin/settings", ctx)
}
示例#3
0
func InitContext() martini.Handler {
	return func(c martini.Context, s sessions.Session, rnd render.Render, r *http.Request, w http.ResponseWriter) {
		ctx := &Context{
			Render: rnd,
			W:      w,
			R:      r,
			C:      c,
			S:      s,
			DbUtil: &model.DbUtil{},
		}

		lang := s.Get("Lang")
		if lang == nil {
			s.Set("Lang", Cfg.MustValue("", "locale", "en"))
		}

		s.Set("Settings", model.GetSettings())
		c.Map(ctx)
	}
}