Пример #1
0
func ShowController(w http.ResponseWriter, r *http.Request) {
	// TODO if the job doesn't exist, return 404
	id := getId(r)
	d := make(map[string]interface{})
	d["job"] = job.Find(id, helpers.CurrentUser(r).Id)
	w.Write(util.JSON(d))
}
Пример #2
0
func UpdateController(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	j := job.Find(getId(r), helpers.CurrentUser(r).Id)
	updateAttributes(j, r)
	j.Save()
	d := make(map[string]interface{})
	if j.Save() {
		d["job"] = j
	}
	w.Write(util.JSON(d))
}
Пример #3
0
func DeleteController(w http.ResponseWriter, r *http.Request) {
	// TODO 404 if no job
	j := job.Find(getId(r), helpers.CurrentUser(r).Id)
	j.Delete()
	w.Write(util.JSON(make(map[string]interface{})))
}