def post(self): form = EffortCreateForm() if not form.validate_on_submit(): return form.errors, 422 effort = Effort(form.name.data, form.description.data) db.session.add(effort) db.session.commit() return EffortSerializer(effort).data, 201
def put(self, id): form = EffortCreateForm() if not form.validate_on_submit(): return form.errors, 422 effort = Effort.query.filter_by(id=id).first() effort.name = form.name.data effort.description = form.description.data db.session.commit() return EffortSerializer(effort).data, 201