Esempio n. 1
0
func (ce *classEndpoint) updateClass(req *restful.Request, res *restful.Response) {
	err := validateUpdateRequest(req)
	if err != nil {
		res.WriteError(http.StatusBadRequest, err)
		return
	}

	newclass := new(model.Class)
	err = req.ReadEntity(newclass)
	if err != nil {
		res.WriteErrorString(http.StatusInternalServerError, err.Error())
		return
	}

	filterClass(newclass)

	newclass.Uuid = req.PathParameter(param_name)

	ce.Model.StoreClass(newclass)
	res.WriteHeader(http.StatusAccepted)
	res.WriteEntity(newclass)
}
Esempio n. 2
0
// this function removes data from the Class object
// before saving (fields which can never be set by
// the user...uuid, created, modified...)
func filterClass(c *model.Class) {
	_newclass := new(model.Class)
	c.Created = _newclass.Created
	c.Modified = _newclass.Modified
	c.Uuid = _newclass.Uuid
}