func notifyInterestedUsersHandler(w io.Writer, r *http.Request) error { ctx := appengine.NewContext(r) conf, err := conf.LoadConference(ctx, r.FormValue("conf_id")) if err != nil { return fmt.Errorf("load conf: %v", err) } var body, subject bytes.Buffer if err := emailSubjectTmpl.Execute(&subject, conf); err != nil { return err } if err := emailBodyTmpl.Execute(&body, conf); err != nil { return err } return conf.MailNotifications(ctx, emailSender, subject.String(), body.String()) }
func reviewConfsHandler(w io.Writer, r *http.Request) error { data := struct { Message string Confs map[string]*conf.Conference }{Confs: make(map[string]*conf.Conference)} ctx := appengine.NewContext(r) if taskName := r.FormValue("task_name"); len(taskName) > 0 { err := &taskqueue.Task{Name: taskName} if err != nil { data.Message = fmt.Sprintf("Conference %v was not reviewed and approved. "+ "Perhaps someone else already approved it?", r.FormValue("conf_name")) } else { data.Message = fmt.Sprintf("Conference %v has been reviewed and approved.", r.FormValue("conf_name")) } } if len(r.FormValue("reviewconference")) > 0 { ts, err := leaseConfs(ctx) if err != nil { return fmt.Errorf("retrieve conferences to review: %v", err) } for _, t := range ts { id := string(t.Payload) c, err := conf.LoadConference(ctx, id) if err != nil { ctx.Errorf("load conf %v to review: %v", id, err) continue } data.Confs[t.Name] = c } } p, err := NewPage(ctx, "reviewconfs", data) if err != nil { return fmt.Errorf("create reviewconfs page: %v", err) } return p.Render(w) }
func showTicketsHandler(w io.Writer, r *http.Request) error { ctx := appengine.NewContext(r) c, err := conf.LoadConference(ctx, r.FormValue("conf_id")) if err != nil { return fmt.Errorf("load conference: %v", err) } ts, err := c.AvailableTickets(ctx) if err != nil { return fmt.Errorf("available tickets: %v", err) } data := struct { ConfName string Tickets []conf.Ticket }{c.Name, ts} p, err := NewPage(ctx, "tickets", data) if err != nil { return fmt.Errorf("create tickets page: %v", err) } return p.Render(w) }