diff --git a/chellow/gas/views.py b/chellow/gas/views.py index 89397fbd2..98335f30d 100644 --- a/chellow/gas/views.py +++ b/chellow/gas/views.py @@ -13,6 +13,7 @@ flash, g, make_response, + redirect, render_template as rtemplate, request, ) @@ -60,11 +61,11 @@ utc_datetime, utc_datetime_now, ) -from chellow.views import chellow_redirect as credirect, hx_redirect as chx_redirect +from chellow.views import hx_redirect as chx_redirect def chellow_redirect(path, code=None): - return credirect(f"/g{path}", code) + return redirect(f"/g{path}", code) def hx_redirect(path, code=None): diff --git a/chellow/reports/report_109.py b/chellow/reports/report_109.py index 1f3440599..b9b707128 100644 --- a/chellow/reports/report_109.py +++ b/chellow/reports/report_109.py @@ -4,7 +4,7 @@ import traceback from datetime import datetime as Datetime -from flask import g +from flask import g, redirect from sqlalchemy import or_, text from sqlalchemy.sql.expression import null @@ -13,7 +13,6 @@ from chellow.e.computer import SiteSource, contract_func, displaced_era, forecast_date from chellow.models import Contract, Era, Session, Site, SiteEra, Source, Supply from chellow.utils import c_months_u, hh_format, hh_range, req_int -from chellow.views import chellow_redirect def to_val(v): @@ -274,4 +273,4 @@ def do_get(sess): contract_id = req_int("supplier_contract_id") args = contract_id, end_year, end_month, months, g.user threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_111.py b/chellow/reports/report_111.py index fac9072aa..fa1e8f0c1 100644 --- a/chellow/reports/report_111.py +++ b/chellow/reports/report_111.py @@ -9,7 +9,7 @@ from dateutil.relativedelta import relativedelta -from flask import g, request +from flask import g, redirect, request from sqlalchemy import or_, select from sqlalchemy.orm import joinedload, subqueryload @@ -49,7 +49,6 @@ req_str, to_utc, ) -from chellow.views import chellow_redirect def add_gap(caches, gaps, elem, start_date, finish_date, is_virtual, gbp): @@ -298,7 +297,7 @@ def do_post(sess): report_run.id, ) threading.Thread(target=content, args=args).start() - return chellow_redirect(f"/report_runs/{report_run.id}", 303) + return redirect(f"/report_runs/{report_run.id}", 303) def _process_supply( diff --git a/chellow/reports/report_169.py b/chellow/reports/report_169.py index 86489971f..969e2bc09 100644 --- a/chellow/reports/report_169.py +++ b/chellow/reports/report_169.py @@ -3,7 +3,7 @@ import traceback from io import StringIO -from flask import g, request +from flask import g, redirect, request from sqlalchemy import or_, select from sqlalchemy.sql.expression import null @@ -23,7 +23,6 @@ to_ct, to_utc, ) -from chellow.views import chellow_redirect def _write_row(writer, titles, vals, total): @@ -266,4 +265,4 @@ def handle_request(mpan_cores=None): user.id, ) threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_181.py b/chellow/reports/report_181.py index 09ff7de4c..84bc6f48f 100644 --- a/chellow/reports/report_181.py +++ b/chellow/reports/report_181.py @@ -2,7 +2,7 @@ import threading import traceback -from flask import g, request +from flask import g, redirect, request from sqlalchemy import or_ from sqlalchemy.sql.expression import null @@ -23,7 +23,6 @@ req_int, to_utc, ) -from chellow.views import chellow_redirect def _make_sites(sess, year_start, year_finish, site_id, source_codes): @@ -169,4 +168,4 @@ def do_get(sess): site_id = req_int("site_id") if "site_id" in request.values else None year = req_int("year") threading.Thread(target=content, args=(year, site_id, g.user.id)).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_183.py b/chellow/reports/report_183.py index 633dda89d..b397925a1 100644 --- a/chellow/reports/report_183.py +++ b/chellow/reports/report_183.py @@ -4,7 +4,7 @@ import traceback from io import StringIO -from flask import g, request +from flask import g, redirect, request from sqlalchemy import or_, select from sqlalchemy.orm import joinedload @@ -22,7 +22,6 @@ to_ct, to_utc, ) -from chellow.views import chellow_redirect def _write_row(writer, titles, vals, total): @@ -241,7 +240,7 @@ def do_post(sess): file_name = f"sites_hh_data_{site_id}_{finish_date_str}.csv" args = site_id, start_date, finish_date, g.user.id, file_name threading.Thread(target=site_content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) else: typ = req_str("type") site_codes_str = req_str("site_codes") @@ -252,4 +251,4 @@ def do_post(sess): file_name = f"sites_hh_data_{finish_date_str}_filter.zip" args = site_codes, typ, start_date, finish_date, g.user.id, file_name threading.Thread(target=none_content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_187.py b/chellow/reports/report_187.py index 524283221..35da613c1 100644 --- a/chellow/reports/report_187.py +++ b/chellow/reports/report_187.py @@ -2,7 +2,7 @@ import traceback from datetime import datetime as Datetime -from flask import g, request +from flask import g, redirect, request from sqlalchemy import null, or_, select, text, true @@ -20,7 +20,6 @@ req_str, to_ct, ) -from chellow.views import chellow_redirect def csv_str(row): @@ -267,4 +266,4 @@ def do_post(sess): args = start_date, finish_date, supply_id, mpan_cores, is_zipped, g.user.id threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_219.py b/chellow/reports/report_219.py index 2dba97ed1..03b8f68d6 100644 --- a/chellow/reports/report_219.py +++ b/chellow/reports/report_219.py @@ -2,7 +2,7 @@ import threading import traceback -from flask import g, request +from flask import g, redirect, request from sqlalchemy import and_, or_, select from sqlalchemy.orm import joinedload @@ -21,7 +21,6 @@ User, ) from chellow.utils import c_months_u, csv_make_val, req_int -from chellow.views import chellow_redirect def content(year, month, months, supply_id, user_id): @@ -189,4 +188,4 @@ def do_get(sess): supply_id = req_int("supply_id") if "supply_id" in request.values else None args = year, month, months, supply_id, g.user.id threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_231.py b/chellow/reports/report_231.py index 0ee256545..6553203bc 100644 --- a/chellow/reports/report_231.py +++ b/chellow/reports/report_231.py @@ -3,7 +3,7 @@ import threading import traceback -from flask import g +from flask import g, redirect from sqlalchemy import or_ from sqlalchemy.sql.expression import null @@ -14,7 +14,6 @@ from chellow.e.computer import SupplySource, contract_func, forecast_date from chellow.models import Contract, Era, Session, User from chellow.utils import csv_make_val, hh_format, hh_max, hh_min, req_date, req_int -from chellow.views import chellow_redirect def content(user_id, start_date, finish_date, contract_id): @@ -134,4 +133,4 @@ def do_get(sess): args = g.user.id, start_date, finish_date, contract_id threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_233.py b/chellow/reports/report_233.py index 247083cef..4540634c2 100644 --- a/chellow/reports/report_233.py +++ b/chellow/reports/report_233.py @@ -5,7 +5,7 @@ from dateutil.relativedelta import relativedelta -from flask import g +from flask import g, redirect from sqlalchemy.orm import joinedload from sqlalchemy.sql.expression import false, select, true @@ -30,7 +30,6 @@ req_int_none, utc_datetime_now, ) -from chellow.views import chellow_redirect def content(contract_id, days_hidden, is_ignored, user_id): @@ -148,4 +147,4 @@ def do_get(sess): args = contract_id, days_hidden, is_ignored, g.user.id threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_241.py b/chellow/reports/report_241.py index 063f5568a..d5fab6691 100644 --- a/chellow/reports/report_241.py +++ b/chellow/reports/report_241.py @@ -5,7 +5,7 @@ from dateutil.relativedelta import relativedelta -from flask import g +from flask import g, redirect import pytz @@ -17,7 +17,6 @@ from chellow.e.computer import SupplySource, contract_func, forecast_date from chellow.models import Era, Session, Site, SiteEra, Supply, User from chellow.utils import HH, csv_make_val, hh_format, hh_max, hh_min, req_bool, req_int -from chellow.views import chellow_redirect def content( @@ -164,4 +163,4 @@ def do_get(sess): g.user.id, ) threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_247.py b/chellow/reports/report_247.py index e83bca94d..e219a715f 100644 --- a/chellow/reports/report_247.py +++ b/chellow/reports/report_247.py @@ -6,7 +6,7 @@ from dateutil.relativedelta import relativedelta -from flask import flash, g, make_response, render_template, request +from flask import flash, g, make_response, redirect, render_template, request import odio @@ -48,7 +48,6 @@ to_utc, utc_datetime_now, ) -from chellow.views import chellow_redirect CATEGORY_ORDER = {None: 0, "unmetered": 1, "nhh": 2, "amr": 3, "hh": 4} @@ -1129,7 +1128,7 @@ def do_post(sess): args = (scenario_props, base_name, user.id, compression, now) threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) except BadRequest as e: flash(e.description) if "scenario_id" in request.values: diff --git a/chellow/reports/report_29.py b/chellow/reports/report_29.py index b832946c3..259dc5807 100644 --- a/chellow/reports/report_29.py +++ b/chellow/reports/report_29.py @@ -3,12 +3,11 @@ import threading import traceback -from flask import g +from flask import g, redirect from chellow.dloads import open_file from chellow.models import Session, Site, User from chellow.utils import c_months_u, csv_make_val, req_int, req_str, to_ct -from chellow.views import chellow_redirect def _write_row(writer, total, values, titles): @@ -78,4 +77,4 @@ def do_get(sess): site_id = req_int("site_id") args = start_date, finish_date, site_id, typ, g.user.id threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_291.py b/chellow/reports/report_291.py index f605451eb..a74284030 100644 --- a/chellow/reports/report_291.py +++ b/chellow/reports/report_291.py @@ -2,7 +2,7 @@ import threading import traceback -from flask import g +from flask import g, redirect from sqlalchemy import or_ from sqlalchemy.sql.expression import null, true @@ -23,7 +23,6 @@ User, ) from chellow.utils import csv_make_val, hh_format, hh_max, hh_min, req_date, req_int -from chellow.views import chellow_redirect def content(supply_id, start_date, finish_date, user_id): @@ -209,4 +208,4 @@ def do_get(sess): args = supply_id, start_date, finish_date, g.user.id threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_33.py b/chellow/reports/report_33.py index 39f681a41..d736446f2 100644 --- a/chellow/reports/report_33.py +++ b/chellow/reports/report_33.py @@ -5,7 +5,7 @@ from dateutil.relativedelta import relativedelta -from flask import g, request +from flask import g, redirect, request from sqlalchemy import or_, text from sqlalchemy.orm import joinedload @@ -42,7 +42,6 @@ req_int, req_str, ) -from chellow.views import chellow_redirect def content(user_id, date, supply_id, mpan_cores): @@ -528,4 +527,4 @@ def do_get(session): args = user.id, date, supply_id, mpan_cores threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_387.py b/chellow/reports/report_387.py index 51e829286..facce95a7 100644 --- a/chellow/reports/report_387.py +++ b/chellow/reports/report_387.py @@ -3,7 +3,7 @@ import threading import traceback -from flask import g +from flask import g, redirect from sqlalchemy import or_, select from sqlalchemy.sql.expression import null, true @@ -18,7 +18,6 @@ req_date, req_int, ) -from chellow.views import chellow_redirect def content(supply_id, start_date, finish_date, user): @@ -162,4 +161,4 @@ def do_get(sess): args = supply_id, start_date, finish_date, g.user threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_41.py b/chellow/reports/report_41.py index b809154e1..608006ef5 100644 --- a/chellow/reports/report_41.py +++ b/chellow/reports/report_41.py @@ -4,7 +4,7 @@ import traceback from datetime import datetime as Datetime -from flask import g, request +from flask import g, redirect, request from sqlalchemy import or_ from sqlalchemy.sql.expression import null, true @@ -23,7 +23,6 @@ req_int, to_utc, ) -from chellow.views import chellow_redirect def _make_eras(sess, nov_start, year_finish, supply_id): @@ -211,4 +210,4 @@ def do_get(sess): year = req_int("year") supply_id = req_int("supply_id") if "supply_id" in request.values else None threading.Thread(target=content, args=(year, supply_id, g.user.id)).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_429.py b/chellow/reports/report_429.py index 89d613d62..e95fb22ce 100644 --- a/chellow/reports/report_429.py +++ b/chellow/reports/report_429.py @@ -7,7 +7,7 @@ from decimal import Decimal from itertools import combinations -from flask import g, request +from flask import g, redirect, request from sqlalchemy import null, or_, select, true from sqlalchemy.orm import joinedload @@ -18,7 +18,6 @@ from chellow.dloads import open_file from chellow.models import GBatch, GBill, GContract, GEra, Session, Site, SiteGEra, User from chellow.utils import csv_make_val, hh_max, hh_min, req_date, req_int, to_utc -from chellow.views import chellow_redirect def content(g_batch_id, g_bill_id, g_contract_id, start_date, finish_date, user_id): @@ -361,4 +360,4 @@ def do_get(sess): args = g_batch_id, g_bill_id, g_contract_id, start_date, finish_date, g.user.id threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_59.py b/chellow/reports/report_59.py index 6b873b2ab..ead914e27 100644 --- a/chellow/reports/report_59.py +++ b/chellow/reports/report_59.py @@ -5,7 +5,7 @@ from dateutil.relativedelta import relativedelta -from flask import flash, g, make_response, render_template, request +from flask import flash, g, make_response, redirect, render_template, request import odio @@ -50,7 +50,6 @@ to_utc, utc_datetime_now, ) -from chellow.views import chellow_redirect CATEGORY_ORDER = {None: 0, "unmetered": 1, "nhh": 2, "amr": 3, "hh": 4} @@ -1072,7 +1071,7 @@ def do_post(sess): sess.rollback() thread = threading.Thread(target=content, args=args) thread.start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) except BadRequest as e: flash(e.description) if "scenario_id" in request.values: diff --git a/chellow/reports/report_81.py b/chellow/reports/report_81.py index 187905cec..22ff3ca33 100644 --- a/chellow/reports/report_81.py +++ b/chellow/reports/report_81.py @@ -2,7 +2,7 @@ import threading import traceback -from flask import g +from flask import g, redirect from sqlalchemy import or_ from sqlalchemy.orm import joinedload @@ -14,7 +14,6 @@ from chellow.e.computer import SupplySource, contract_func, forecast_date from chellow.models import Contract, Era, RSession, User from chellow.utils import c_months_u, csv_make_val, hh_format, hh_max, hh_min, req_int -from chellow.views import chellow_redirect def content(user_id, contract_id, end_year, end_month, months): @@ -147,4 +146,4 @@ def do_get(sess): args = g.user.id, contract_id, end_year, end_month, months threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_87.py b/chellow/reports/report_87.py index f64e2174c..78b95dae5 100644 --- a/chellow/reports/report_87.py +++ b/chellow/reports/report_87.py @@ -2,7 +2,7 @@ import threading import traceback -from flask import g +from flask import g, redirect from sqlalchemy import or_, select from sqlalchemy.sql.expression import null, true @@ -32,7 +32,6 @@ req_int, to_ct, ) -from chellow.views import chellow_redirect def _process_era( @@ -240,4 +239,4 @@ def do_get(sess): threading.Thread( target=content, args=(start_date, finish_date, contract_id, g.user.id) ).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_asset_comparison.py b/chellow/reports/report_asset_comparison.py index f3a27433e..98c94fb34 100644 --- a/chellow/reports/report_asset_comparison.py +++ b/chellow/reports/report_asset_comparison.py @@ -4,7 +4,7 @@ import traceback from io import StringIO -from flask import g, request +from flask import g, redirect, request from sqlalchemy import select from sqlalchemy.orm import joinedload @@ -14,7 +14,6 @@ from chellow.dloads import open_file from chellow.models import Contract, Era, ReportRun, Session, Site, SiteEra, User -from chellow.views import chellow_redirect STATUSES_ACTIVE = ("IN USE / IN SERVICE", "STORED SPARE") STATUSES_INACTIVE = ("DEMOLISHED", "SOLD", "ABANDONED") @@ -194,4 +193,4 @@ def do_post(sess): sess.commit() args = user.id, StringIO(file_item.read().decode("utf8")), report_run.id threading.Thread(target=content, args=args).start() - return chellow_redirect(f"/report_runs/{report_run.id}", 303) + return redirect(f"/report_runs/{report_run.id}", 303) diff --git a/chellow/reports/report_batches.py b/chellow/reports/report_batches.py index b6ef6a4c8..e212e69c3 100644 --- a/chellow/reports/report_batches.py +++ b/chellow/reports/report_batches.py @@ -2,7 +2,7 @@ import threading import traceback -from flask import g +from flask import g, redirect from sqlalchemy.sql import func, select @@ -16,7 +16,6 @@ User, ) from chellow.utils import csv_make_val -from chellow.views import chellow_redirect def content(user_id): @@ -142,4 +141,4 @@ def content(user_id): def do_get(sess): threading.Thread(target=content, args=(g.user.id,)).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_bills.py b/chellow/reports/report_bills.py index 62e4b7848..574256ede 100644 --- a/chellow/reports/report_bills.py +++ b/chellow/reports/report_bills.py @@ -3,7 +3,7 @@ import traceback from collections import defaultdict -from flask import g +from flask import g, redirect from sqlalchemy import select from sqlalchemy.orm import joinedload @@ -11,7 +11,6 @@ from chellow.dloads import open_file from chellow.models import Batch, Bill, Session, User from chellow.utils import csv_make_val, req_int -from chellow.views import chellow_redirect def _content(sess, writer, batch_id): @@ -111,4 +110,4 @@ def do_get(sess): batch_id = req_int("batch_id") args = g.user.id, batch_id threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_csv_llfcs.py b/chellow/reports/report_csv_llfcs.py index 456f58b12..33e10e256 100644 --- a/chellow/reports/report_csv_llfcs.py +++ b/chellow/reports/report_csv_llfcs.py @@ -2,14 +2,13 @@ import threading import traceback -from flask import g +from flask import g, redirect from sqlalchemy.orm import joinedload from chellow.dloads import open_file from chellow.models import Llfc, Session, User from chellow.utils import hh_format -from chellow.views import chellow_redirect def content(user_id): @@ -64,4 +63,4 @@ def content(user_id): def do_get(sess): args = (g.user.id,) threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_csv_site_hh_data.py b/chellow/reports/report_csv_site_hh_data.py index 5d39f5f2b..83a9c02c9 100644 --- a/chellow/reports/report_csv_site_hh_data.py +++ b/chellow/reports/report_csv_site_hh_data.py @@ -3,7 +3,7 @@ import threading import traceback -from flask import g, request +from flask import g, redirect, request from sqlalchemy import null, or_, select, true from sqlalchemy.orm import joinedload @@ -11,7 +11,6 @@ from chellow.dloads import open_file from chellow.models import Era, Session, Site, SiteEra, Source, Supply, User from chellow.utils import req_date, req_int, write_row -from chellow.views import chellow_redirect TYPE_ORDER = {"hh": 0, "amr": 1, "nhh": 2, "unmetered": 3} @@ -122,4 +121,4 @@ def do_get(sess): args = start_date, finish_date, site_id, g.user.id threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_csv_site_snags.py b/chellow/reports/report_csv_site_snags.py index da024816b..2a929ae71 100644 --- a/chellow/reports/report_csv_site_snags.py +++ b/chellow/reports/report_csv_site_snags.py @@ -3,7 +3,7 @@ import traceback from datetime import datetime as Datetime, timedelta as Timedelta -from flask import g +from flask import g, redirect import pytz @@ -13,7 +13,6 @@ from chellow.dloads import open_file from chellow.models import Session, Site, Snag, User from chellow.utils import hh_format -from chellow.views import chellow_redirect def content(user_id): @@ -81,4 +80,4 @@ def content(user_id): def do_get(sess): args = (g.user.id,) threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_ecoes_comparison.py b/chellow/reports/report_ecoes_comparison.py index b9454be05..7cce6da50 100644 --- a/chellow/reports/report_ecoes_comparison.py +++ b/chellow/reports/report_ecoes_comparison.py @@ -3,7 +3,7 @@ import threading import traceback -from flask import g +from flask import g, redirect import requests @@ -26,7 +26,6 @@ User, ) from chellow.utils import csv_make_val, req_bool -from chellow.views import chellow_redirect FNAME = "ecoes_comparison" @@ -615,4 +614,4 @@ def do_get(sess): sess.commit() args = g.user.id, show_ignored, report_run.id threading.Thread(target=content, args=args).start() - return chellow_redirect(f"/report_runs/{report_run.id}", 303) + return redirect(f"/report_runs/{report_run.id}", 303) diff --git a/chellow/reports/report_g_monthly_duration.py b/chellow/reports/report_g_monthly_duration.py index 4aa4ab5ac..e1c502631 100644 --- a/chellow/reports/report_g_monthly_duration.py +++ b/chellow/reports/report_g_monthly_duration.py @@ -1,7 +1,7 @@ import threading import traceback -from flask import g, request +from flask import g, redirect, request import odio @@ -42,7 +42,6 @@ to_utc, utc_datetime_now, ) -from chellow.views import chellow_redirect def write_spreadsheet(fl, compressed, site_rows, era_rows): @@ -535,4 +534,4 @@ def do_get(sess): args = scenario_props, g.user.id, compression, now, base_name threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_g_supplies_snapshot.py b/chellow/reports/report_g_supplies_snapshot.py index e9ac5aa09..131075ddf 100644 --- a/chellow/reports/report_g_supplies_snapshot.py +++ b/chellow/reports/report_g_supplies_snapshot.py @@ -3,7 +3,7 @@ import threading import traceback -from flask import g, request +from flask import g, redirect, request from sqlalchemy import or_ from sqlalchemy.orm import joinedload @@ -16,7 +16,6 @@ from chellow.gas.engine import GDataSource, forecast_date from chellow.models import GEra, GSupply, Session from chellow.utils import csv_make_val, req_date, req_int -from chellow.views import chellow_redirect def content(date, g_supply_id, user): @@ -136,4 +135,4 @@ def do_get(session): args = (date, g_supply_id, user) threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_g_supply_virtual_bill.py b/chellow/reports/report_g_supply_virtual_bill.py index 06d401f17..170378ea6 100644 --- a/chellow/reports/report_g_supply_virtual_bill.py +++ b/chellow/reports/report_g_supply_virtual_bill.py @@ -2,7 +2,7 @@ import threading import traceback -from flask import g +from flask import g, redirect from sqlalchemy import or_ from sqlalchemy.sql.expression import null, true @@ -14,7 +14,6 @@ from chellow.gas.engine import GDataSource, g_contract_func from chellow.models import GEra, GSupply, Session, Site, SiteGEra from chellow.utils import csv_make_val, hh_format, hh_max, hh_min, req_date, req_int -from chellow.views import chellow_redirect def content(g_supply_id, file_name, start_date, finish_date, user): @@ -107,4 +106,4 @@ def do_get(sess): args = (g_supply_id, file_name, start_date, finish_date, g.user) threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_g_virtual_bills.py b/chellow/reports/report_g_virtual_bills.py index f1230334f..54d8fd08e 100644 --- a/chellow/reports/report_g_virtual_bills.py +++ b/chellow/reports/report_g_virtual_bills.py @@ -4,7 +4,7 @@ import traceback -from flask import g +from flask import g, redirect from sqlalchemy import or_ from sqlalchemy.sql.expression import null, true @@ -25,7 +25,6 @@ req_int, to_ct, ) -from chellow.views import chellow_redirect def content(start_date, finish_date, g_contract_id, user_id): @@ -137,4 +136,4 @@ def do_get(sess): args = start_date, finish_date, g_contract_id, g.user.id threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_g_virtual_bills_hh.py b/chellow/reports/report_g_virtual_bills_hh.py index ac849f953..c7fd15820 100644 --- a/chellow/reports/report_g_virtual_bills_hh.py +++ b/chellow/reports/report_g_virtual_bills_hh.py @@ -3,7 +3,7 @@ import threading import traceback -from flask import g +from flask import g, redirect from sqlalchemy import or_ from sqlalchemy.sql.expression import null, true @@ -14,7 +14,6 @@ from chellow.gas.engine import GDataSource from chellow.models import GEra, GSupply, Session, Site, SiteGEra from chellow.utils import csv_make_val, hh_format, hh_range, req_date, req_int -from chellow.views import chellow_redirect def content(g_supply_id, start_date, finish_date, user): @@ -105,4 +104,4 @@ def do_get(sess): args = g_supply_id, start_date, finish_date, g.user threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_sscs.py b/chellow/reports/report_sscs.py index 86f8628cf..84fc477eb 100644 --- a/chellow/reports/report_sscs.py +++ b/chellow/reports/report_sscs.py @@ -3,7 +3,7 @@ import traceback -from flask import g, request +from flask import g, redirect, request import odio @@ -15,7 +15,6 @@ from chellow.dloads import open_file from chellow.models import MeasurementRequirement, Session, Ssc, Tpr, User from chellow.utils import req_bool -from chellow.views import chellow_redirect def write_spreadsheet( @@ -114,4 +113,4 @@ def do_get(sess): args = (user.id, compression) threading.Thread(target=content, args=args).start() - return chellow_redirect("/downloads", 303) + return redirect("/downloads", 303) diff --git a/chellow/reports/report_supply_contacts.py b/chellow/reports/report_supply_contacts.py index 6a13d1c10..91782dd8d 100644 --- a/chellow/reports/report_supply_contacts.py +++ b/chellow/reports/report_supply_contacts.py @@ -3,7 +3,7 @@ import threading import traceback -from flask import g +from flask import g, redirect from sqlalchemy import select from sqlalchemy.orm import joinedload @@ -21,7 +21,6 @@ Supply, User, ) -from chellow.views import chellow_redirect FNAME = "supply_contacts" @@ -127,4 +126,4 @@ def do_get(sess): report_run = ReportRun.insert(sess, FNAME, g.user, FNAME, {}) sess.commit() threading.Thread(target=content, args=(g.user.id, report_run.id)).start() - return chellow_redirect(f"/report_runs/{report_run.id}", 303) + return redirect(f"/report_runs/{report_run.id}", 303)