def test_create_series_entry(self, session): series_schema = SeriesSchema() series_obj, error = series_schema.load( dict(name="example series", date_start=str(datetime.today()), date_end=str(datetime.today() + timedelta(days=30)))) assert not error session.add(series_obj) session.commit() assert series_obj.id > 0
def create_series(): series_schema = SeriesSchema() if request.method == "POST": form_data = request.form data_validation(form_data, ['name', 'date_start', 'date_end']) series_obj, error = series_schema.load( dict(name=form_data.get("name"), date_start=form_data.get("date_start"), date_end=form_data.get("date_end"))) try: session.add(series_obj) session.commit() except Exception as exc: session.rollback() logger.error("Failed to process request {}".format(str(exc))) raise HTTPError(500, {"error": str(exc)}) return redirect(url_for("create_series")) flash("Series successfully created") return render_template('create_series.html')