def new_class(): form = ClassForm() if form.validate_on_submit(): name = form.name.data description = form.description.data created_class = Class.create(name, current_user, description=description) return redirect(url_for('pages.home')) return render_template('new_class.html', form=form)
def post(self): json_data = request.get_json() if not json_data: raise RequestException("No input data", 400) try: data = class_schema.load(json_data) except ValidationError as err: raise RequestException("Invalid input data", 400, err.messages) _class = Class.create(**data) result = class_schema.dump(_class) response = jsonify( {APIConst.MESSAGE: 'created new class', APIConst.DATA: result}) return response