Esempio n. 1
0
func updateAttributes(p *plan.Plan, r *http.Request) {
	// TODO this needs to be changed.  Not a good place to put this.
	if name := r.PostForm.Get("plan[name]"); name != "" {
		p.Name = name
	}
	if num := getFormInt("plan[num]", r); num > 0 {
		p.Num = num
	}
	if jobId := getFormInt("plan[job_id]", r); jobId > 0 {
		p.JobId = jobId
	}
}
Esempio n. 2
0
func CreateController(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	p := plan.Plan{
		Name:  r.PostForm.Get("plan[name]"),
		Num:   getFormInt("plan[num]", r),
		JobId: getFormInt("plan[job_id]", r),
	}
	d := make(map[string]interface{})
	if p.Save() {
		d["plan"] = p
	}
	w.Write(util.JSON(d))
}