示例#1
0
//Presentation handles showing page with details about a presentation.
func Presentation(c util.Context) (err error) {
	pk, err := datastore.DecodeKey(c.Vars["id"])
	if err != nil {
		return
	}

	p, err := presentation.GetByKey(pk, c)
	if err != nil {
		return
	}
	as, err := action.GetFor(p, c)
	if err != nil {
		return
	}

	a := prepareActions(as)

	desc := blackfriday.MarkdownCommon(p.Description)

	acts, err := activation.GetForPresentation(pk, c)
	if err != nil {
		return
	}

	util.RenderLayout("presentation.html", "Info o prezentácií", struct {
		P           *presentation.Presentation
		A           map[string][]time.Time
		Desc        template.HTML
		ZeroTime    time.Time
		Domain      string
		Activations []*activation.Activation
		Tz          *time.Location
	}{p, a, template.HTML(desc), time.Date(0001, 01, 01, 00, 00, 00, 00, utc), appengine.DefaultVersionHostname(c), acts, util.Tz}, c, "/static/js/underscore-min.js", "/static/js/presentation.js")
	return
}
示例#2
0
//ShowConfig handles showing the page where user can see and edit
//the central configuration for clients.
func ShowConfig(c util.Context) (err error) {
	conf, err := config.Get(c)
	if err != nil {
		if err == datastore.Done {
			conf, err = mkConfig(c)
			if err != nil {
				c.Errorf("Error when creating new config: %v", err)
			}
			http.Redirect(c.W, c.R, "/admin/config", 303)
			err = nil
			return
		} else {
			return
		}
	}

	as, err := action.GetFor(conf, c)
	if err != nil {
		return
	}

	tcs, err := timeConfig.GetAll(c)
	if err != nil {
		return
	}

	a := prepareActions(as)

	util.RenderLayout("config.html", "Všeobecné nastavenia", struct {
		Conf     *config.Config
		A        map[string][]time.Time
		ZeroTime time.Time
		Tz       *time.Location
		Tcs      []*timeConfig.TimeConfig
	}{conf, a, time.Date(0001, 01, 01, 00, 00, 00, 00, utc), util.Tz, tcs}, c, "/static/js/config.js")
	return
}