chellow 1733390302.0.0__py3-none-any.whl → 1734005435.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chellow might be problematic. Click here for more details.
- chellow/__init__.py +0 -1
- chellow/e/bill_parsers/mm.py +27 -5
- chellow/e/computer.py +1 -7
- chellow/e/views.py +126 -10
- chellow/gas/engine.py +1 -3
- chellow/gas/views.py +3 -2
- chellow/reports/report_109.py +2 -3
- chellow/reports/report_111.py +2 -3
- chellow/reports/report_169.py +2 -3
- chellow/reports/report_181.py +2 -3
- chellow/reports/report_183.py +3 -4
- chellow/reports/report_187.py +2 -3
- chellow/reports/report_219.py +2 -3
- chellow/reports/report_231.py +2 -3
- chellow/reports/report_233.py +2 -3
- chellow/reports/report_241.py +2 -3
- chellow/reports/report_247.py +2 -3
- chellow/reports/report_29.py +2 -3
- chellow/reports/report_291.py +2 -3
- chellow/reports/report_33.py +2 -3
- chellow/reports/report_387.py +2 -3
- chellow/reports/report_41.py +2 -3
- chellow/reports/report_429.py +2 -3
- chellow/reports/report_59.py +2 -3
- chellow/reports/report_81.py +2 -3
- chellow/reports/report_87.py +3 -7
- chellow/reports/report_asset_comparison.py +2 -3
- chellow/reports/report_batches.py +2 -3
- chellow/reports/report_bills.py +4 -3
- chellow/reports/report_csv_llfcs.py +2 -3
- chellow/reports/report_csv_site_hh_data.py +2 -3
- chellow/reports/report_csv_site_snags.py +2 -3
- chellow/reports/report_ecoes_comparison.py +2 -3
- chellow/reports/report_g_monthly_duration.py +2 -3
- chellow/reports/report_g_supplies_snapshot.py +2 -3
- chellow/reports/report_g_supply_virtual_bill.py +2 -3
- chellow/reports/report_g_virtual_bills.py +2 -3
- chellow/reports/report_g_virtual_bills_hh.py +2 -3
- chellow/reports/report_sscs.py +2 -3
- chellow/reports/report_supply_contacts.py +2 -3
- chellow/templates/e/dc_contract_properties_edit.html +10 -10
- chellow/templates/e/site_hh_data.html +73 -49
- chellow/templates/site.html +1 -1
- chellow/utils.py +0 -2
- chellow/views.py +33 -167
- {chellow-1733390302.0.0.dist-info → chellow-1734005435.0.0.dist-info}/METADATA +1 -1
- {chellow-1733390302.0.0.dist-info → chellow-1734005435.0.0.dist-info}/RECORD +48 -49
- chellow/templates/site_hh_data.html +0 -75
- {chellow-1733390302.0.0.dist-info → chellow-1734005435.0.0.dist-info}/WHEEL +0 -0
chellow/__init__.py
CHANGED
|
@@ -89,7 +89,6 @@ def create_app(testing=False, instance_path=None):
|
|
|
89
89
|
props = configuration.make_properties()
|
|
90
90
|
api_props = props.get("api", {})
|
|
91
91
|
api.description = api_props.get("description", "Access Chellow data")
|
|
92
|
-
chellow.utils.url_root = props.get("url_root", "")
|
|
93
92
|
|
|
94
93
|
chellow.dloads.startup(Path(app.instance_path), run_deleter=(not testing))
|
|
95
94
|
|
chellow/e/bill_parsers/mm.py
CHANGED
|
@@ -36,7 +36,16 @@ def _handle_0000(headers, pre_record, record):
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
def _handle_0050(headers, pre_record, record):
|
|
39
|
-
|
|
39
|
+
parts = _chop_record(
|
|
40
|
+
record,
|
|
41
|
+
issue_date=DATE_LENGTH,
|
|
42
|
+
unknown_1=12,
|
|
43
|
+
unknown_2=12,
|
|
44
|
+
unknown_3=12,
|
|
45
|
+
unknown_4=12,
|
|
46
|
+
late_payment=12,
|
|
47
|
+
)
|
|
48
|
+
headers["late_payment"] = Decimal(parts["late_payment"]) / Decimal(100)
|
|
40
49
|
|
|
41
50
|
|
|
42
51
|
def _handle_0051(headers, pre_record, record):
|
|
@@ -45,8 +54,11 @@ def _handle_0051(headers, pre_record, record):
|
|
|
45
54
|
|
|
46
55
|
def _handle_0100(headers, pre_record, record):
|
|
47
56
|
issue_date = headers["issue_date"]
|
|
57
|
+
late_payment = headers.get("late_payment")
|
|
48
58
|
headers.clear()
|
|
49
59
|
headers["issue_date"] = issue_date
|
|
60
|
+
if late_payment is not None:
|
|
61
|
+
headers["late_payment"] = late_payment
|
|
50
62
|
headers["account"] = pre_record[33:41]
|
|
51
63
|
headers["reference"] = pre_record[41:46]
|
|
52
64
|
headers["kwh"] = Decimal("0")
|
|
@@ -263,6 +275,16 @@ def _handle_1500(headers, pre_record, record):
|
|
|
263
275
|
net=12,
|
|
264
276
|
vat=12,
|
|
265
277
|
)
|
|
278
|
+
breakdown = headers["breakdown"]
|
|
279
|
+
net = Decimal("0.00") + Decimal(parts["net"]) / Decimal("100")
|
|
280
|
+
gross = Decimal("0.00") + Decimal(parts["gross"]) / Decimal("100")
|
|
281
|
+
if "late_payment" in headers:
|
|
282
|
+
late_payment_gbp = headers["late_payment"]
|
|
283
|
+
net += late_payment_gbp
|
|
284
|
+
gross += late_payment_gbp
|
|
285
|
+
breakdown["late-payment-gbp"] += late_payment_gbp
|
|
286
|
+
del headers["late_payment"]
|
|
287
|
+
|
|
266
288
|
return {
|
|
267
289
|
"bill_type_code": "N",
|
|
268
290
|
"mpan_core": headers["mpan_core"],
|
|
@@ -272,10 +294,10 @@ def _handle_1500(headers, pre_record, record):
|
|
|
272
294
|
"start_date": headers["start_date"],
|
|
273
295
|
"finish_date": headers["finish_date"],
|
|
274
296
|
"kwh": headers["kwh"],
|
|
275
|
-
"net":
|
|
297
|
+
"net": net,
|
|
276
298
|
"vat": Decimal("0.00") + Decimal(parts["vat"]) / Decimal("100"),
|
|
277
|
-
"gross":
|
|
278
|
-
"breakdown":
|
|
299
|
+
"gross": gross,
|
|
300
|
+
"breakdown": breakdown,
|
|
279
301
|
"reads": headers["reads"],
|
|
280
302
|
}
|
|
281
303
|
|
|
@@ -291,7 +313,7 @@ def _handle_1600(headers, pre_record, record):
|
|
|
291
313
|
)
|
|
292
314
|
late_payment_gbp = Decimal(parts["late_payment_fee"]) / Decimal(100)
|
|
293
315
|
|
|
294
|
-
headers["breakdown"]["
|
|
316
|
+
headers["breakdown"]["late-payment-gbp"] += late_payment_gbp
|
|
295
317
|
|
|
296
318
|
|
|
297
319
|
def _handle_1700(headers, pre_record, record):
|
chellow/e/computer.py
CHANGED
|
@@ -16,8 +16,6 @@ from werkzeug.exceptions import BadRequest
|
|
|
16
16
|
|
|
17
17
|
from zish import dumps
|
|
18
18
|
|
|
19
|
-
import chellow.bank_holidays
|
|
20
|
-
import chellow.utils
|
|
21
19
|
from chellow.models import (
|
|
22
20
|
Bill,
|
|
23
21
|
BillType,
|
|
@@ -218,11 +216,7 @@ def hh_rate(sess, caches, contract_id_or_name, date, market_role_code=None):
|
|
|
218
216
|
f"The market role code {market_role_code} isn't recognized."
|
|
219
217
|
)
|
|
220
218
|
|
|
221
|
-
vals = PropDict(
|
|
222
|
-
f"the rate script {chellow.utils.url_root}{seg}{rs.id} ",
|
|
223
|
-
loads(rs.script),
|
|
224
|
-
[],
|
|
225
|
-
)
|
|
219
|
+
vals = PropDict(f"the rate script {seg}{rs.id} ", loads(rs.script), [])
|
|
226
220
|
for dt in hh_range(caches, cstart, cfinish):
|
|
227
221
|
if dt not in cont_cache:
|
|
228
222
|
cont_cache[dt] = vals
|
chellow/e/views.py
CHANGED
|
@@ -3,6 +3,7 @@ import os
|
|
|
3
3
|
import threading
|
|
4
4
|
from collections import defaultdict
|
|
5
5
|
from datetime import datetime as Datetime
|
|
6
|
+
from decimal import Decimal
|
|
6
7
|
from io import BytesIO, StringIO
|
|
7
8
|
from itertools import chain, islice
|
|
8
9
|
from random import random
|
|
@@ -16,6 +17,7 @@ from flask import (
|
|
|
16
17
|
flash,
|
|
17
18
|
g,
|
|
18
19
|
make_response,
|
|
20
|
+
redirect,
|
|
19
21
|
render_template as rtemplate,
|
|
20
22
|
request,
|
|
21
23
|
)
|
|
@@ -105,14 +107,13 @@ from chellow.utils import (
|
|
|
105
107
|
utc_datetime_now,
|
|
106
108
|
)
|
|
107
109
|
from chellow.views import (
|
|
108
|
-
chellow_redirect as credirect,
|
|
109
110
|
hx_redirect as chx_redirect,
|
|
110
111
|
requires_editor,
|
|
111
112
|
)
|
|
112
113
|
|
|
113
114
|
|
|
114
115
|
def chellow_redirect(path, code=None):
|
|
115
|
-
return
|
|
116
|
+
return redirect(f"/e{path}", code)
|
|
116
117
|
|
|
117
118
|
|
|
118
119
|
def hx_redirect(path, code=None):
|
|
@@ -1421,9 +1422,7 @@ def dno_rate_script_edit_delete(dno_rate_script_id):
|
|
|
1421
1422
|
dno = Party.get_dno_by_code(g.sess, contract.name, rate_script.start_date)
|
|
1422
1423
|
contract.delete_rate_script(g.sess, rate_script)
|
|
1423
1424
|
g.sess.commit()
|
|
1424
|
-
|
|
1425
|
-
res.headers["HX-Redirect"] = f"{chellow.utils.url_root}/e/dnos/{dno.id}"
|
|
1426
|
-
return res
|
|
1425
|
+
return hx_redirect(f"/dnos/{dno.id}")
|
|
1427
1426
|
except BadRequest as e:
|
|
1428
1427
|
flash(e.description)
|
|
1429
1428
|
return render_template(
|
|
@@ -4731,6 +4730,127 @@ def site_add_e_supply_post(site_id):
|
|
|
4731
4730
|
)
|
|
4732
4731
|
|
|
4733
4732
|
|
|
4733
|
+
@e.route("/sites/<int:site_id>/hh_data")
|
|
4734
|
+
def site_hh_data_get(site_id):
|
|
4735
|
+
caches = {}
|
|
4736
|
+
site = Site.get_by_id(g.sess, site_id)
|
|
4737
|
+
|
|
4738
|
+
start_year = req_int("start_year")
|
|
4739
|
+
start_month = req_int("start_month")
|
|
4740
|
+
start_date, finish_date = next(
|
|
4741
|
+
c_months_u(start_year=start_year, start_month=start_month, months=1)
|
|
4742
|
+
)
|
|
4743
|
+
|
|
4744
|
+
supplies = (
|
|
4745
|
+
g.sess.query(Supply)
|
|
4746
|
+
.join(Era)
|
|
4747
|
+
.join(SiteEra)
|
|
4748
|
+
.join(Source)
|
|
4749
|
+
.filter(
|
|
4750
|
+
SiteEra.site == site,
|
|
4751
|
+
SiteEra.is_physical == true(),
|
|
4752
|
+
Era.start_date <= finish_date,
|
|
4753
|
+
or_(Era.finish_date == null(), Era.finish_date >= start_date),
|
|
4754
|
+
Source.code != "sub",
|
|
4755
|
+
)
|
|
4756
|
+
.order_by(Supply.id)
|
|
4757
|
+
.distinct()
|
|
4758
|
+
.options(joinedload(Supply.source), joinedload(Supply.generator_type))
|
|
4759
|
+
.all()
|
|
4760
|
+
)
|
|
4761
|
+
|
|
4762
|
+
data = iter(
|
|
4763
|
+
g.sess.query(HhDatum)
|
|
4764
|
+
.join(Channel)
|
|
4765
|
+
.join(Era)
|
|
4766
|
+
.filter(
|
|
4767
|
+
Channel.channel_type == "ACTIVE",
|
|
4768
|
+
Era.supply_id.in_([s.id for s in supplies]),
|
|
4769
|
+
HhDatum.start_date >= start_date,
|
|
4770
|
+
HhDatum.start_date <= finish_date,
|
|
4771
|
+
)
|
|
4772
|
+
.order_by(HhDatum.start_date, Era.supply_id)
|
|
4773
|
+
.options(
|
|
4774
|
+
joinedload(HhDatum.channel)
|
|
4775
|
+
.joinedload(Channel.era)
|
|
4776
|
+
.joinedload(Era.supply)
|
|
4777
|
+
.joinedload(Supply.source)
|
|
4778
|
+
)
|
|
4779
|
+
)
|
|
4780
|
+
datum = next(data, None)
|
|
4781
|
+
|
|
4782
|
+
hh_data = []
|
|
4783
|
+
for hh_date in hh_range(caches, start_date, finish_date):
|
|
4784
|
+
sups = []
|
|
4785
|
+
hh_dict = {
|
|
4786
|
+
"start_date": hh_date,
|
|
4787
|
+
"supplies": sups,
|
|
4788
|
+
"export_kwh": Decimal(0),
|
|
4789
|
+
"import_kwh": Decimal(0),
|
|
4790
|
+
"parasitic_kwh": Decimal(0),
|
|
4791
|
+
"generated_kwh": Decimal(0),
|
|
4792
|
+
"third_party_import_kwh": Decimal(0),
|
|
4793
|
+
"third_party_export_kwh": Decimal(0),
|
|
4794
|
+
}
|
|
4795
|
+
hh_data.append(hh_dict)
|
|
4796
|
+
for supply in supplies:
|
|
4797
|
+
sup_hh = {}
|
|
4798
|
+
sups.append(sup_hh)
|
|
4799
|
+
while (
|
|
4800
|
+
datum is not None
|
|
4801
|
+
and datum.start_date == hh_date
|
|
4802
|
+
and datum.channel.era.supply_id == supply.id
|
|
4803
|
+
):
|
|
4804
|
+
channel = datum.channel
|
|
4805
|
+
imp_related = channel.imp_related
|
|
4806
|
+
source_code = channel.era.supply.source.code
|
|
4807
|
+
|
|
4808
|
+
prefix = "import_" if imp_related else "export_"
|
|
4809
|
+
sup_hh[f"{prefix}kwh"] = datum.value
|
|
4810
|
+
sup_hh[f"{prefix}status"] = datum.status
|
|
4811
|
+
|
|
4812
|
+
if not imp_related and source_code in ("grid", "gen-grid"):
|
|
4813
|
+
hh_dict["export_kwh"] += datum.value
|
|
4814
|
+
if imp_related and source_code in ("grid", "gen-grid"):
|
|
4815
|
+
hh_dict["import_kwh"] += datum.value
|
|
4816
|
+
if (imp_related and source_code == "gen") or (
|
|
4817
|
+
not imp_related and source_code == "gen-grid"
|
|
4818
|
+
):
|
|
4819
|
+
hh_dict["generated_kwh"] += datum.value
|
|
4820
|
+
if (not imp_related and source_code == "gen") or (
|
|
4821
|
+
imp_related and source_code == "gen-grid"
|
|
4822
|
+
):
|
|
4823
|
+
hh_dict["parasitic_kwh"] += datum.value
|
|
4824
|
+
if (imp_related and source_code == "3rd-party") or (
|
|
4825
|
+
not imp_related and source_code == "3rd-party-reverse"
|
|
4826
|
+
):
|
|
4827
|
+
hh_dict["third_party_import_kwh"] += datum.value
|
|
4828
|
+
if (not imp_related and source_code == "3rd-party") or (
|
|
4829
|
+
imp_related and source_code == "3rd-party-reverse"
|
|
4830
|
+
):
|
|
4831
|
+
hh_dict["third_party_export_kwh"] += datum.value
|
|
4832
|
+
datum = next(data, None)
|
|
4833
|
+
|
|
4834
|
+
hh_dict["displaced_kwh"] = (
|
|
4835
|
+
hh_dict["generated_kwh"] - hh_dict["export_kwh"] - hh_dict["parasitic_kwh"]
|
|
4836
|
+
)
|
|
4837
|
+
hh_dict["used_kwh"] = sum(
|
|
4838
|
+
(
|
|
4839
|
+
hh_dict["import_kwh"],
|
|
4840
|
+
hh_dict["displaced_kwh"],
|
|
4841
|
+
hh_dict["third_party_import_kwh"] - hh_dict["third_party_export_kwh"],
|
|
4842
|
+
)
|
|
4843
|
+
)
|
|
4844
|
+
|
|
4845
|
+
return render_template(
|
|
4846
|
+
"site_hh_data.html",
|
|
4847
|
+
site=site,
|
|
4848
|
+
supplies=supplies,
|
|
4849
|
+
hh_data=hh_data,
|
|
4850
|
+
start_date=start_date,
|
|
4851
|
+
)
|
|
4852
|
+
|
|
4853
|
+
|
|
4734
4854
|
@e.route("/sources")
|
|
4735
4855
|
def sources_get():
|
|
4736
4856
|
sources = g.sess.query(Source).order_by(Source.code)
|
|
@@ -6020,11 +6140,7 @@ def supply_note_edit_delete(supply_id, index):
|
|
|
6020
6140
|
del supply_note["notes"][index]
|
|
6021
6141
|
supply.note = dumps(supply_note)
|
|
6022
6142
|
g.sess.commit()
|
|
6023
|
-
|
|
6024
|
-
res.headers["HX-Redirect"] = (
|
|
6025
|
-
f"{chellow.utils.url_root}/e/supplies/{supply_id}/notes"
|
|
6026
|
-
)
|
|
6027
|
-
return res
|
|
6143
|
+
return hx_redirect(f"/supplies/{supply_id}/notes")
|
|
6028
6144
|
except BadRequest as e:
|
|
6029
6145
|
flash(e.description)
|
|
6030
6146
|
supply_note = loads(supply.note)
|
chellow/gas/engine.py
CHANGED
|
@@ -13,7 +13,6 @@ from werkzeug.exceptions import BadRequest
|
|
|
13
13
|
|
|
14
14
|
from zish import dumps, loads
|
|
15
15
|
|
|
16
|
-
import chellow.bank_holidays
|
|
17
16
|
from chellow.e.computer import hh_rate
|
|
18
17
|
from chellow.models import (
|
|
19
18
|
BillType,
|
|
@@ -323,8 +322,7 @@ def g_rates(sess, caches, g_contract_id_or_name, date, is_industry):
|
|
|
323
322
|
prefix = "industry" if g_contract.is_industry else "supplier"
|
|
324
323
|
|
|
325
324
|
vals = PropDict(
|
|
326
|
-
f"the rate script
|
|
327
|
-
f"{rs.id} ",
|
|
325
|
+
f"the rate script /g/{prefix}_rate_scripts/{rs.id} ",
|
|
328
326
|
loads(rs.script),
|
|
329
327
|
[],
|
|
330
328
|
)
|
chellow/gas/views.py
CHANGED
|
@@ -13,6 +13,7 @@ from flask import (
|
|
|
13
13
|
flash,
|
|
14
14
|
g,
|
|
15
15
|
make_response,
|
|
16
|
+
redirect,
|
|
16
17
|
render_template as rtemplate,
|
|
17
18
|
request,
|
|
18
19
|
)
|
|
@@ -60,11 +61,11 @@ from chellow.utils import (
|
|
|
60
61
|
utc_datetime,
|
|
61
62
|
utc_datetime_now,
|
|
62
63
|
)
|
|
63
|
-
from chellow.views import
|
|
64
|
+
from chellow.views import hx_redirect as chx_redirect
|
|
64
65
|
|
|
65
66
|
|
|
66
67
|
def chellow_redirect(path, code=None):
|
|
67
|
-
return
|
|
68
|
+
return redirect(f"/g{path}", code)
|
|
68
69
|
|
|
69
70
|
|
|
70
71
|
def hx_redirect(path, code=None):
|
chellow/reports/report_109.py
CHANGED
|
@@ -4,7 +4,7 @@ import threading
|
|
|
4
4
|
import traceback
|
|
5
5
|
from datetime import datetime as Datetime
|
|
6
6
|
|
|
7
|
-
from flask import g
|
|
7
|
+
from flask import g, redirect
|
|
8
8
|
|
|
9
9
|
from sqlalchemy import or_, text
|
|
10
10
|
from sqlalchemy.sql.expression import null
|
|
@@ -13,7 +13,6 @@ from chellow.dloads import open_file
|
|
|
13
13
|
from chellow.e.computer import SiteSource, contract_func, displaced_era, forecast_date
|
|
14
14
|
from chellow.models import Contract, Era, Session, Site, SiteEra, Source, Supply
|
|
15
15
|
from chellow.utils import c_months_u, hh_format, hh_range, req_int
|
|
16
|
-
from chellow.views import chellow_redirect
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
def to_val(v):
|
|
@@ -274,4 +273,4 @@ def do_get(sess):
|
|
|
274
273
|
contract_id = req_int("supplier_contract_id")
|
|
275
274
|
args = contract_id, end_year, end_month, months, g.user
|
|
276
275
|
threading.Thread(target=content, args=args).start()
|
|
277
|
-
return
|
|
276
|
+
return redirect("/downloads", 303)
|
chellow/reports/report_111.py
CHANGED
|
@@ -9,7 +9,7 @@ from itertools import combinations
|
|
|
9
9
|
|
|
10
10
|
from dateutil.relativedelta import relativedelta
|
|
11
11
|
|
|
12
|
-
from flask import g, request
|
|
12
|
+
from flask import g, redirect, request
|
|
13
13
|
|
|
14
14
|
from sqlalchemy import or_, select
|
|
15
15
|
from sqlalchemy.orm import joinedload, subqueryload
|
|
@@ -49,7 +49,6 @@ from chellow.utils import (
|
|
|
49
49
|
req_str,
|
|
50
50
|
to_utc,
|
|
51
51
|
)
|
|
52
|
-
from chellow.views import chellow_redirect
|
|
53
52
|
|
|
54
53
|
|
|
55
54
|
def add_gap(caches, gaps, elem, start_date, finish_date, is_virtual, gbp):
|
|
@@ -298,7 +297,7 @@ def do_post(sess):
|
|
|
298
297
|
report_run.id,
|
|
299
298
|
)
|
|
300
299
|
threading.Thread(target=content, args=args).start()
|
|
301
|
-
return
|
|
300
|
+
return redirect(f"/report_runs/{report_run.id}", 303)
|
|
302
301
|
|
|
303
302
|
|
|
304
303
|
def _process_supply(
|
chellow/reports/report_169.py
CHANGED
|
@@ -3,7 +3,7 @@ import threading
|
|
|
3
3
|
import traceback
|
|
4
4
|
from io import StringIO
|
|
5
5
|
|
|
6
|
-
from flask import g, request
|
|
6
|
+
from flask import g, redirect, request
|
|
7
7
|
|
|
8
8
|
from sqlalchemy import or_, select
|
|
9
9
|
from sqlalchemy.sql.expression import null
|
|
@@ -23,7 +23,6 @@ from chellow.utils import (
|
|
|
23
23
|
to_ct,
|
|
24
24
|
to_utc,
|
|
25
25
|
)
|
|
26
|
-
from chellow.views import chellow_redirect
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
def _write_row(writer, titles, vals, total):
|
|
@@ -266,4 +265,4 @@ def handle_request(mpan_cores=None):
|
|
|
266
265
|
user.id,
|
|
267
266
|
)
|
|
268
267
|
threading.Thread(target=content, args=args).start()
|
|
269
|
-
return
|
|
268
|
+
return redirect("/downloads", 303)
|
chellow/reports/report_181.py
CHANGED
|
@@ -2,7 +2,7 @@ import csv
|
|
|
2
2
|
import threading
|
|
3
3
|
import traceback
|
|
4
4
|
|
|
5
|
-
from flask import g, request
|
|
5
|
+
from flask import g, redirect, request
|
|
6
6
|
|
|
7
7
|
from sqlalchemy import or_
|
|
8
8
|
from sqlalchemy.sql.expression import null
|
|
@@ -23,7 +23,6 @@ from chellow.utils import (
|
|
|
23
23
|
req_int,
|
|
24
24
|
to_utc,
|
|
25
25
|
)
|
|
26
|
-
from chellow.views import chellow_redirect
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
def _make_sites(sess, year_start, year_finish, site_id, source_codes):
|
|
@@ -169,4 +168,4 @@ def do_get(sess):
|
|
|
169
168
|
site_id = req_int("site_id") if "site_id" in request.values else None
|
|
170
169
|
year = req_int("year")
|
|
171
170
|
threading.Thread(target=content, args=(year, site_id, g.user.id)).start()
|
|
172
|
-
return
|
|
171
|
+
return redirect("/downloads", 303)
|
chellow/reports/report_183.py
CHANGED
|
@@ -4,7 +4,7 @@ import threading
|
|
|
4
4
|
import traceback
|
|
5
5
|
from io import StringIO
|
|
6
6
|
|
|
7
|
-
from flask import g, request
|
|
7
|
+
from flask import g, redirect, request
|
|
8
8
|
|
|
9
9
|
from sqlalchemy import or_, select
|
|
10
10
|
from sqlalchemy.orm import joinedload
|
|
@@ -22,7 +22,6 @@ from chellow.utils import (
|
|
|
22
22
|
to_ct,
|
|
23
23
|
to_utc,
|
|
24
24
|
)
|
|
25
|
-
from chellow.views import chellow_redirect
|
|
26
25
|
|
|
27
26
|
|
|
28
27
|
def _write_row(writer, titles, vals, total):
|
|
@@ -241,7 +240,7 @@ def do_post(sess):
|
|
|
241
240
|
file_name = f"sites_hh_data_{site_id}_{finish_date_str}.csv"
|
|
242
241
|
args = site_id, start_date, finish_date, g.user.id, file_name
|
|
243
242
|
threading.Thread(target=site_content, args=args).start()
|
|
244
|
-
return
|
|
243
|
+
return redirect("/downloads", 303)
|
|
245
244
|
else:
|
|
246
245
|
typ = req_str("type")
|
|
247
246
|
site_codes_str = req_str("site_codes")
|
|
@@ -252,4 +251,4 @@ def do_post(sess):
|
|
|
252
251
|
file_name = f"sites_hh_data_{finish_date_str}_filter.zip"
|
|
253
252
|
args = site_codes, typ, start_date, finish_date, g.user.id, file_name
|
|
254
253
|
threading.Thread(target=none_content, args=args).start()
|
|
255
|
-
return
|
|
254
|
+
return redirect("/downloads", 303)
|
chellow/reports/report_187.py
CHANGED
|
@@ -2,7 +2,7 @@ import threading
|
|
|
2
2
|
import traceback
|
|
3
3
|
from datetime import datetime as Datetime
|
|
4
4
|
|
|
5
|
-
from flask import g, request
|
|
5
|
+
from flask import g, redirect, request
|
|
6
6
|
|
|
7
7
|
from sqlalchemy import null, or_, select, text, true
|
|
8
8
|
|
|
@@ -20,7 +20,6 @@ from chellow.utils import (
|
|
|
20
20
|
req_str,
|
|
21
21
|
to_ct,
|
|
22
22
|
)
|
|
23
|
-
from chellow.views import chellow_redirect
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
def csv_str(row):
|
|
@@ -267,4 +266,4 @@ def do_post(sess):
|
|
|
267
266
|
args = start_date, finish_date, supply_id, mpan_cores, is_zipped, g.user.id
|
|
268
267
|
|
|
269
268
|
threading.Thread(target=content, args=args).start()
|
|
270
|
-
return
|
|
269
|
+
return redirect("/downloads", 303)
|
chellow/reports/report_219.py
CHANGED
|
@@ -2,7 +2,7 @@ import csv
|
|
|
2
2
|
import threading
|
|
3
3
|
import traceback
|
|
4
4
|
|
|
5
|
-
from flask import g, request
|
|
5
|
+
from flask import g, redirect, request
|
|
6
6
|
|
|
7
7
|
from sqlalchemy import and_, or_, select
|
|
8
8
|
from sqlalchemy.orm import joinedload
|
|
@@ -21,7 +21,6 @@ from chellow.models import (
|
|
|
21
21
|
User,
|
|
22
22
|
)
|
|
23
23
|
from chellow.utils import c_months_u, csv_make_val, req_int
|
|
24
|
-
from chellow.views import chellow_redirect
|
|
25
24
|
|
|
26
25
|
|
|
27
26
|
def content(year, month, months, supply_id, user_id):
|
|
@@ -189,4 +188,4 @@ def do_get(sess):
|
|
|
189
188
|
supply_id = req_int("supply_id") if "supply_id" in request.values else None
|
|
190
189
|
args = year, month, months, supply_id, g.user.id
|
|
191
190
|
threading.Thread(target=content, args=args).start()
|
|
192
|
-
return
|
|
191
|
+
return redirect("/downloads", 303)
|
chellow/reports/report_231.py
CHANGED
|
@@ -3,7 +3,7 @@ import sys
|
|
|
3
3
|
import threading
|
|
4
4
|
import traceback
|
|
5
5
|
|
|
6
|
-
from flask import g
|
|
6
|
+
from flask import g, redirect
|
|
7
7
|
|
|
8
8
|
from sqlalchemy import or_
|
|
9
9
|
from sqlalchemy.sql.expression import null
|
|
@@ -14,7 +14,6 @@ from chellow.dloads import open_file
|
|
|
14
14
|
from chellow.e.computer import SupplySource, contract_func, forecast_date
|
|
15
15
|
from chellow.models import Contract, Era, Session, User
|
|
16
16
|
from chellow.utils import csv_make_val, hh_format, hh_max, hh_min, req_date, req_int
|
|
17
|
-
from chellow.views import chellow_redirect
|
|
18
17
|
|
|
19
18
|
|
|
20
19
|
def content(user_id, start_date, finish_date, contract_id):
|
|
@@ -134,4 +133,4 @@ def do_get(sess):
|
|
|
134
133
|
|
|
135
134
|
args = g.user.id, start_date, finish_date, contract_id
|
|
136
135
|
threading.Thread(target=content, args=args).start()
|
|
137
|
-
return
|
|
136
|
+
return redirect("/downloads", 303)
|
chellow/reports/report_233.py
CHANGED
|
@@ -5,7 +5,7 @@ import traceback
|
|
|
5
5
|
|
|
6
6
|
from dateutil.relativedelta import relativedelta
|
|
7
7
|
|
|
8
|
-
from flask import g
|
|
8
|
+
from flask import g, redirect
|
|
9
9
|
|
|
10
10
|
from sqlalchemy.orm import joinedload
|
|
11
11
|
from sqlalchemy.sql.expression import false, select, true
|
|
@@ -30,7 +30,6 @@ from chellow.utils import (
|
|
|
30
30
|
req_int_none,
|
|
31
31
|
utc_datetime_now,
|
|
32
32
|
)
|
|
33
|
-
from chellow.views import chellow_redirect
|
|
34
33
|
|
|
35
34
|
|
|
36
35
|
def content(contract_id, days_hidden, is_ignored, user_id):
|
|
@@ -148,4 +147,4 @@ def do_get(sess):
|
|
|
148
147
|
|
|
149
148
|
args = contract_id, days_hidden, is_ignored, g.user.id
|
|
150
149
|
threading.Thread(target=content, args=args).start()
|
|
151
|
-
return
|
|
150
|
+
return redirect("/downloads", 303)
|
chellow/reports/report_241.py
CHANGED
|
@@ -5,7 +5,7 @@ from datetime import datetime as Datetime
|
|
|
5
5
|
|
|
6
6
|
from dateutil.relativedelta import relativedelta
|
|
7
7
|
|
|
8
|
-
from flask import g
|
|
8
|
+
from flask import g, redirect
|
|
9
9
|
|
|
10
10
|
import pytz
|
|
11
11
|
|
|
@@ -17,7 +17,6 @@ from chellow.dloads import open_file
|
|
|
17
17
|
from chellow.e.computer import SupplySource, contract_func, forecast_date
|
|
18
18
|
from chellow.models import Era, Session, Site, SiteEra, Supply, User
|
|
19
19
|
from chellow.utils import HH, csv_make_val, hh_format, hh_max, hh_min, req_bool, req_int
|
|
20
|
-
from chellow.views import chellow_redirect
|
|
21
20
|
|
|
22
21
|
|
|
23
22
|
def content(
|
|
@@ -164,4 +163,4 @@ def do_get(sess):
|
|
|
164
163
|
g.user.id,
|
|
165
164
|
)
|
|
166
165
|
threading.Thread(target=content, args=args).start()
|
|
167
|
-
return
|
|
166
|
+
return redirect("/downloads", 303)
|
chellow/reports/report_247.py
CHANGED
|
@@ -6,7 +6,7 @@ from datetime import datetime as Datetime
|
|
|
6
6
|
|
|
7
7
|
from dateutil.relativedelta import relativedelta
|
|
8
8
|
|
|
9
|
-
from flask import flash, g, make_response, render_template, request
|
|
9
|
+
from flask import flash, g, make_response, redirect, render_template, request
|
|
10
10
|
|
|
11
11
|
import odio
|
|
12
12
|
|
|
@@ -48,7 +48,6 @@ from chellow.utils import (
|
|
|
48
48
|
to_utc,
|
|
49
49
|
utc_datetime_now,
|
|
50
50
|
)
|
|
51
|
-
from chellow.views import chellow_redirect
|
|
52
51
|
|
|
53
52
|
|
|
54
53
|
CATEGORY_ORDER = {None: 0, "unmetered": 1, "nhh": 2, "amr": 3, "hh": 4}
|
|
@@ -1129,7 +1128,7 @@ def do_post(sess):
|
|
|
1129
1128
|
|
|
1130
1129
|
args = (scenario_props, base_name, user.id, compression, now)
|
|
1131
1130
|
threading.Thread(target=content, args=args).start()
|
|
1132
|
-
return
|
|
1131
|
+
return redirect("/downloads", 303)
|
|
1133
1132
|
except BadRequest as e:
|
|
1134
1133
|
flash(e.description)
|
|
1135
1134
|
if "scenario_id" in request.values:
|
chellow/reports/report_29.py
CHANGED
|
@@ -3,12 +3,11 @@ import sys
|
|
|
3
3
|
import threading
|
|
4
4
|
import traceback
|
|
5
5
|
|
|
6
|
-
from flask import g
|
|
6
|
+
from flask import g, redirect
|
|
7
7
|
|
|
8
8
|
from chellow.dloads import open_file
|
|
9
9
|
from chellow.models import Session, Site, User
|
|
10
10
|
from chellow.utils import c_months_u, csv_make_val, req_int, req_str, to_ct
|
|
11
|
-
from chellow.views import chellow_redirect
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
def _write_row(writer, total, values, titles):
|
|
@@ -78,4 +77,4 @@ def do_get(sess):
|
|
|
78
77
|
site_id = req_int("site_id")
|
|
79
78
|
args = start_date, finish_date, site_id, typ, g.user.id
|
|
80
79
|
threading.Thread(target=content, args=args).start()
|
|
81
|
-
return
|
|
80
|
+
return redirect("/downloads", 303)
|
chellow/reports/report_291.py
CHANGED
|
@@ -2,7 +2,7 @@ import csv
|
|
|
2
2
|
import threading
|
|
3
3
|
import traceback
|
|
4
4
|
|
|
5
|
-
from flask import g
|
|
5
|
+
from flask import g, redirect
|
|
6
6
|
|
|
7
7
|
from sqlalchemy import or_
|
|
8
8
|
from sqlalchemy.sql.expression import null, true
|
|
@@ -23,7 +23,6 @@ from chellow.models import (
|
|
|
23
23
|
User,
|
|
24
24
|
)
|
|
25
25
|
from chellow.utils import csv_make_val, hh_format, hh_max, hh_min, req_date, req_int
|
|
26
|
-
from chellow.views import chellow_redirect
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
def content(supply_id, start_date, finish_date, user_id):
|
|
@@ -209,4 +208,4 @@ def do_get(sess):
|
|
|
209
208
|
args = supply_id, start_date, finish_date, g.user.id
|
|
210
209
|
|
|
211
210
|
threading.Thread(target=content, args=args).start()
|
|
212
|
-
return
|
|
211
|
+
return redirect("/downloads", 303)
|
chellow/reports/report_33.py
CHANGED
|
@@ -5,7 +5,7 @@ import traceback
|
|
|
5
5
|
|
|
6
6
|
from dateutil.relativedelta import relativedelta
|
|
7
7
|
|
|
8
|
-
from flask import g, request
|
|
8
|
+
from flask import g, redirect, request
|
|
9
9
|
|
|
10
10
|
from sqlalchemy import or_, text
|
|
11
11
|
from sqlalchemy.orm import joinedload
|
|
@@ -42,7 +42,6 @@ from chellow.utils import (
|
|
|
42
42
|
req_int,
|
|
43
43
|
req_str,
|
|
44
44
|
)
|
|
45
|
-
from chellow.views import chellow_redirect
|
|
46
45
|
|
|
47
46
|
|
|
48
47
|
def content(user_id, date, supply_id, mpan_cores):
|
|
@@ -528,4 +527,4 @@ def do_get(session):
|
|
|
528
527
|
|
|
529
528
|
args = user.id, date, supply_id, mpan_cores
|
|
530
529
|
threading.Thread(target=content, args=args).start()
|
|
531
|
-
return
|
|
530
|
+
return redirect("/downloads", 303)
|
chellow/reports/report_387.py
CHANGED
|
@@ -3,7 +3,7 @@ import sys
|
|
|
3
3
|
import threading
|
|
4
4
|
import traceback
|
|
5
5
|
|
|
6
|
-
from flask import g
|
|
6
|
+
from flask import g, redirect
|
|
7
7
|
|
|
8
8
|
from sqlalchemy import or_, select
|
|
9
9
|
from sqlalchemy.sql.expression import null, true
|
|
@@ -18,7 +18,6 @@ from chellow.utils import (
|
|
|
18
18
|
req_date,
|
|
19
19
|
req_int,
|
|
20
20
|
)
|
|
21
|
-
from chellow.views import chellow_redirect
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
def content(supply_id, start_date, finish_date, user):
|
|
@@ -162,4 +161,4 @@ def do_get(sess):
|
|
|
162
161
|
|
|
163
162
|
args = supply_id, start_date, finish_date, g.user
|
|
164
163
|
threading.Thread(target=content, args=args).start()
|
|
165
|
-
return
|
|
164
|
+
return redirect("/downloads", 303)
|