chellow 1725527086.0.0__py3-none-any.whl → 1725628177.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/e/views.py CHANGED
@@ -5898,11 +5898,23 @@ def supply_months_get(supply_id):
5898
5898
  @e.route("/supplies/<int:supply_id>/edit")
5899
5899
  def supply_edit_get(supply_id):
5900
5900
  supply = Supply.get_by_id(g.sess, supply_id)
5901
- sources = g.sess.query(Source).order_by(Source.code)
5902
- generator_types = g.sess.query(GeneratorType).order_by(GeneratorType.code)
5903
- gsp_groups = g.sess.query(GspGroup).order_by(GspGroup.code)
5904
- eras = (
5905
- g.sess.query(Era).filter(Era.supply == supply).order_by(Era.start_date.desc())
5901
+ sources = g.sess.scalars(select(Source).order_by(Source.code))
5902
+ generator_types = g.sess.scalars(select(GeneratorType).order_by(GeneratorType.code))
5903
+
5904
+ dno_contract = Contract.get_dno_by_name(g.sess, supply.dno.dno_code)
5905
+ dno_rate_script = dno_contract.find_rate_script_at(
5906
+ g.sess, supply.eras[-1].start_date
5907
+ )
5908
+ dno_props = dno_rate_script.make_script()
5909
+ allowed_gsp_group_codes = list(dno_props.keys())
5910
+
5911
+ gsp_groups = g.sess.scalars(
5912
+ select(GspGroup)
5913
+ .where(GspGroup.code.in_(allowed_gsp_group_codes))
5914
+ .order_by(GspGroup.code)
5915
+ )
5916
+ eras = g.sess.scalars(
5917
+ select(Era).where(Era.supply == supply).order_by(Era.start_date.desc())
5906
5918
  )
5907
5919
  return render_template(
5908
5920
  "supply_edit.html",
@@ -5914,50 +5926,127 @@ def supply_edit_get(supply_id):
5914
5926
  )
5915
5927
 
5916
5928
 
5917
- @e.route("/supplies/<int:supply_id>/edit", methods=["POST"])
5918
- def supply_edit_post(supply_id):
5929
+ @e.route("/supplies/<int:supply_id>/edit", methods=["DELETE"])
5930
+ def supply_edit_delete(supply_id):
5919
5931
  try:
5920
5932
  supply = Supply.get_by_id(g.sess, supply_id)
5921
5933
 
5922
- if "delete" in request.form:
5923
- site_id = None
5924
- for site_era in supply.eras[-1].site_eras:
5925
- if site_era.is_physical:
5926
- site_id = site_era.site.id
5927
- break
5934
+ site_id = None
5935
+ for site_era in supply.eras[-1].site_eras:
5936
+ if site_era.is_physical:
5937
+ site_id = site_era.site.id
5938
+ break
5928
5939
 
5929
- supply.delete(g.sess)
5930
- g.sess.commit()
5931
- return credirect(f"/sites/{site_id}", 303)
5932
- elif "insert_era" in request.form:
5933
- start_date = req_date("start")
5934
- supply.insert_era_at(g.sess, start_date)
5935
- g.sess.commit()
5936
- return chellow_redirect(f"/supplies/{supply.id}", 303)
5940
+ supply.delete(g.sess)
5941
+ g.sess.commit()
5942
+ return hx_redirect(f"/sites/{site_id}", 303)
5943
+ except BadRequest as e:
5944
+ g.sess.rollback()
5945
+ flash(e.description)
5946
+ sources = g.sess.scalars(select(Source).order_by(Source.code))
5947
+ generator_types = g.sess.scalars(
5948
+ select(GeneratorType).order_by(GeneratorType.code)
5949
+ )
5950
+ dno_contract = Contract.get_dno_by_name(g.sess, supply.dno.dno_code)
5951
+ dno_rate_script = dno_contract.find_rate_script_at(
5952
+ g.sess, supply.eras[-1].start_date
5953
+ )
5954
+ dno_props = dno_rate_script.make_script()
5955
+ allowed_gsp_group_codes = list(dno_props.keys())
5956
+
5957
+ gsp_groups = g.sess.scalars(
5958
+ select(GspGroup)
5959
+ .where(GspGroup.code.in_(allowed_gsp_group_codes))
5960
+ .order_by(GspGroup.code)
5961
+ )
5962
+ eras = g.sess.scalars(
5963
+ select(Era).where(Era.supply == supply).order_by(Era.start_date.desc())
5964
+ )
5965
+ return make_response(
5966
+ render_template(
5967
+ "supply_edit.html",
5968
+ supply=supply,
5969
+ sources=sources,
5970
+ generator_types=generator_types,
5971
+ gsp_groups=gsp_groups,
5972
+ eras=eras,
5973
+ ),
5974
+ 400,
5975
+ )
5976
+
5977
+
5978
+ @e.route("/supplies/<int:supply_id>/edit", methods=["PATCH"])
5979
+ def supply_edit_patch(supply_id):
5980
+ try:
5981
+ supply = Supply.get_by_id(g.sess, supply_id)
5982
+
5983
+ name = req_str("name")
5984
+ source_id = req_int("source_id")
5985
+ gsp_group_id = req_int("gsp_group_id")
5986
+ source = Source.get_by_id(g.sess, source_id)
5987
+ if source.code in ("gen", "gen-grid"):
5988
+ generator_type_id = req_int("generator_type_id")
5989
+ generator_type = GeneratorType.get_by_id(g.sess, generator_type_id)
5937
5990
  else:
5938
- name = req_str("name")
5939
- source_id = req_int("source_id")
5940
- gsp_group_id = req_int("gsp_group_id")
5941
- source = Source.get_by_id(g.sess, source_id)
5942
- if source.code in ("gen", "gen-grid"):
5943
- generator_type_id = req_int("generator_type_id")
5944
- generator_type = GeneratorType.get_by_id(g.sess, generator_type_id)
5945
- else:
5946
- generator_type = None
5947
- gsp_group = GspGroup.get_by_id(g.sess, gsp_group_id)
5948
- supply.update(name, source, generator_type, gsp_group, supply.dno)
5949
- g.sess.commit()
5950
- return chellow_redirect(f"/supplies/{supply.id}", 303)
5991
+ generator_type = None
5992
+ gsp_group = GspGroup.get_by_id(g.sess, gsp_group_id)
5993
+ supply.update(name, source, generator_type, gsp_group, supply.dno)
5994
+ g.sess.commit()
5995
+ return hx_redirect(f"/supplies/{supply.id}", 303)
5951
5996
  except BadRequest as e:
5952
5997
  g.sess.rollback()
5953
5998
  flash(e.description)
5954
- sources = g.sess.query(Source).order_by(Source.code)
5955
- generator_types = g.sess.query(GeneratorType).order_by(GeneratorType.code)
5956
- gsp_groups = g.sess.query(GspGroup).order_by(GspGroup.code)
5957
- eras = (
5958
- g.sess.query(Era)
5959
- .filter(Era.supply == supply)
5960
- .order_by(Era.start_date.desc())
5999
+ sources = g.sess.scalars(select(Source).order_by(Source.code))
6000
+ generator_types = g.sess.scalars(
6001
+ select(GeneratorType).order_by(GeneratorType.code)
6002
+ )
6003
+ dno_contract = Contract.get_dno_by_name(g.sess, supply.dno.dno_code)
6004
+ dno_rate_script = dno_contract.find_rate_script_at(
6005
+ g.sess, supply.eras[-1].start_date
6006
+ )
6007
+ dno_props = dno_rate_script.make_script()
6008
+ allowed_gsp_group_codes = list(dno_props.keys())
6009
+
6010
+ gsp_groups = g.sess.scalars(
6011
+ select(GspGroup)
6012
+ .where(GspGroup.code.in_(allowed_gsp_group_codes))
6013
+ .order_by(GspGroup.code)
6014
+ )
6015
+ eras = g.sess.scalars(
6016
+ select(Era).where(Era.supply == supply).order_by(Era.start_date.desc())
6017
+ )
6018
+ return make_response(
6019
+ render_template(
6020
+ "supply_edit.html",
6021
+ supply=supply,
6022
+ sources=sources,
6023
+ generator_types=generator_types,
6024
+ gsp_groups=gsp_groups,
6025
+ eras=eras,
6026
+ ),
6027
+ 400,
6028
+ )
6029
+
6030
+
6031
+ @e.route("/supplies/<int:supply_id>/edit", methods=["POST"])
6032
+ def supply_edit_post(supply_id):
6033
+ try:
6034
+ supply = Supply.get_by_id(g.sess, supply_id)
6035
+
6036
+ start_date = req_date("start")
6037
+ supply.insert_era_at(g.sess, start_date)
6038
+ g.sess.commit()
6039
+ return chellow_redirect(f"/supplies/{supply.id}", 303)
6040
+ except BadRequest as e:
6041
+ g.sess.rollback()
6042
+ flash(e.description)
6043
+ sources = g.sess.scalars(select(Source).order_by(Source.code))
6044
+ generator_types = g.sess.scalars(
6045
+ select(GeneratorType).order_by(GeneratorType.code)
6046
+ )
6047
+ gsp_groups = g.sess.scalars(select(GspGroup).order_by(GspGroup.code))
6048
+ eras = g.sess.scalars(
6049
+ select(Era).where(Era.supply == supply).order_by(Era.start_date.desc())
5961
6050
  )
5962
6051
  return make_response(
5963
6052
  render_template(
@@ -11,95 +11,80 @@
11
11
 
12
12
  {% block content %}
13
13
 
14
- {% if request.method == 'GET' and request.values.delete %}
14
+ <form hx-patch="/e/supplies/{{supply.id}}/edit">
15
+ <fieldset>
16
+ <legend>Update this supply</legend>
17
+ <label>Name</label> {{input_text('name', supply.name)}}
18
+ <label>Source</label>
19
+ <select name="source_id">
20
+ {% for source in sources %}
21
+ {{input_option('source_id', source.id, source.code, supply.source.id)}}
22
+ {% endfor %}
23
+ </select>
24
+ <label>Generator Type (if source is 'gen' or 'gen-net')</label>
25
+ <select name="generator_type_id">
26
+ {% for generator_type in generator_types %}
27
+ {{input_option(
28
+ 'generator_type_id', generator_type.id, generator_type.code,
29
+ supply.generator_type.id)}}
30
+ {% endfor %}
31
+ </select>
32
+ <label>GSP Group</label>
33
+ <select name="gsp_group_id">
34
+ {% for gsp_group in gsp_groups %}
35
+ {{input_option(
36
+ 'gsp_group_id', gsp_group.id,
37
+ gsp_group.code + ' ' + gsp_group.description, supply.gsp_group.id)}}
38
+ {% endfor %}
39
+ </select>
40
+ <input type="submit" value="Update">
41
+ </fieldset>
42
+ </form>
15
43
 
16
- <form method="post">
17
- <fieldset>
18
- <legend>Are you sure you want to delete this supply?</legend>
19
- <input type="submit" name="delete" value="Delete">
20
- <a class="btn" href="/e/supplies/{{supply.id}}/edit">Cancel</a>
21
- </fieldset>
22
- </form>
44
+ <form hx-delete="/e/supplies/{{supply.id}}/edit"
45
+ hx-confirm="Are you sure you want to delete this supply?">
46
+ <fieldset>
47
+ <legend>Delete this supply</legend>
48
+ <input type="submit" name="delete" value="Delete">
49
+ </fieldset>
50
+ </form>
23
51
 
24
- {% else %}
52
+ <form method="post" action="/e/supplies/{{supply.id}}/edit">
53
+ <fieldset>
54
+ <legend>Insert a new era</legend>
55
+ <label>Start date</label> {{input_date('start', None)}}
56
+ <input type="submit" name="insert_era" value="Insert">
57
+ </fieldset>
58
+ </form>
25
59
 
26
- <form method="post" action="/e/supplies/{{supply.id}}/edit">
27
- <fieldset>
28
- <legend>Update this supply</legend>
29
- <label>Name</label> {{input_text('name', supply.name)}}
30
- <label>Source</label>
31
- <select name="source_id">
32
- {% for source in sources %}
33
- {{input_option('source_id', source.id, source.code, supply.source.id)}}
34
- {% endfor %}
35
- </select>
36
- <label>Generator Type (if source is 'gen' or 'gen-net')</label>
37
- <select name="generator_type_id">
38
- {% for generator_type in generator_types %}
39
- {{input_option(
40
- 'generator_type_id', generator_type.id, generator_type.code,
41
- supply.generator_type.id)}}
42
- {% endfor %}
43
- </select>
44
- </div>
45
- </div>
46
- <label>GSP Group</label>
47
- <select name="gsp_group_id">
48
- {% for gsp_group in gsp_groups %}
49
- {{input_option(
50
- 'gsp_group_id', gsp_group.id,
51
- gsp_group.code + ' ' + gsp_group.description, supply.gsp_group.id)}}
52
- {% endfor %}
53
- </select>
54
- <input type="submit" value="Update">
55
- </fieldset>
56
- </form>
57
-
58
- <form action="/e/supplies/{{supply.id}}/edit">
59
- <fieldset>
60
- <legend>Delete this supply</legend>
61
- <input type="submit" name="delete" value="Delete">
62
- </fieldset>
63
- </form>
64
-
65
- <form method="post" action="/e/supplies/{{supply.id}}/edit">
66
- <fieldset>
67
- <legend>Insert a new era</legend>
68
- <label>Start date</label> {{input_date('start', None)}}
69
- <input type="submit" name="insert_era" value="Insert">
70
- </fieldset>
71
- </form>
72
-
73
- <table>
74
- <caption>Existing Eras</caption>
75
- <thead>
76
- <tr>
77
- <th>Start date</th>
78
- <th>Finish date</th>
79
- <th>Import Mpan Core</th>
80
- <th>Export Mpan Core</th>
81
- </tr>
82
- </thead>
83
- <tbody>
84
- {% for era in eras %}
85
- <tr>
86
- <td>{{era.start_date|hh_format}}</td>
87
- <td>{{era.finish_date|hh_format}}</td>
88
- <td>
89
- {% if era.imp_mpan_core %}
90
- {{era.imp_mpan_core}}
91
- {% endif %}
92
- </td>
93
- <td>
94
- {% if era.exp_mpan_core %}
95
- {{era.exp_mpan_core}}
96
- {% endif %}
97
- </td>
98
- </tr>
99
- {% endfor %}
100
- </tbody>
101
- </table>
102
-
103
- {% endif %}
60
+ <table>
61
+ <caption>Existing Eras</caption>
62
+ <thead>
63
+ <tr>
64
+ <th>Start date</th>
65
+ <th>Finish date</th>
66
+ <th>Import Mpan Core</th>
67
+ <th>Export Mpan Core</th>
68
+ </tr>
69
+ </thead>
70
+ <tbody>
71
+ {% for era in eras %}
72
+ <tr>
73
+ <td>{{era.start_date|hh_format}}</td>
74
+ <td>{{era.finish_date|hh_format}}</td>
75
+ <td>
76
+ {% if era.imp_mpan_core %}
77
+ {{era.imp_mpan_core}}
78
+ {% endif %}
79
+ </td>
80
+ <td>
81
+ {% if era.exp_mpan_core %}
82
+ {{era.exp_mpan_core}}
83
+ {% endif %}
84
+ </td>
85
+ </tr>
86
+ {% endfor %}
87
+ </tbody>
88
+ </table>
104
89
 
105
90
  {% endblock %}
@@ -1,24 +1,23 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: chellow
3
- Version: 1725527086.0.0
3
+ Version: 1725628177.0.0
4
4
  Summary: Web Application for checking UK energy bills.
5
5
  Project-URL: Homepage, https://github.com/WessexWater/chellow
6
6
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
7
7
  Classifier: Operating System :: OS Independent
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Requires-Python: >=3.9
10
- Requires-Dist: cryptography==42.0.8
11
10
  Requires-Dist: flask-restx==1.2.0
12
11
  Requires-Dist: flask==2.3.3
13
12
  Requires-Dist: odio==0.0.23
14
13
  Requires-Dist: openpyxl==3.1.2
15
- Requires-Dist: paramiko==3.4.0
14
+ Requires-Dist: paramiko==3.4.1
16
15
  Requires-Dist: pep3143daemon==0.0.6
17
16
  Requires-Dist: pg8000==1.31.1
18
17
  Requires-Dist: pip>=9.0.1
19
18
  Requires-Dist: psutil==5.9.5
20
19
  Requires-Dist: pympler==1.0.1
21
- Requires-Dist: pypdf==3.17.0
20
+ Requires-Dist: pypdf==4.3.1
22
21
  Requires-Dist: python-dateutil==2.8.2
23
22
  Requires-Dist: pytz==2022.6
24
23
  Requires-Dist: requests==2.32.2
@@ -38,7 +38,7 @@ chellow/e/system_price.py,sha256=6w5J7bzwFAZubE2zdOFRiS8IIrVP8hkoIOaG2yCt-Ic,623
38
38
  chellow/e/tlms.py,sha256=M33D6YpMixu2KkwSCzDRM3kThLgShg8exp63Obo75l8,8905
39
39
  chellow/e/tnuos.py,sha256=XseYztPUsQXNKuBmystO2kzzwAG9ehCZgpGBTdgSk-A,4313
40
40
  chellow/e/triad.py,sha256=lIQj7EdUrcFwEqleuHZXYU_bfzIwNOqUVVxB3NPQt4A,13710
41
- chellow/e/views.py,sha256=Ue11tdJSjXni4sFobzlvnrTI5evSja_qUuTQ_JusPdU,216671
41
+ chellow/e/views.py,sha256=NwDgs0iZ6nmfX4qF5sSwFlecSsqDBMRsf46vxuIkgVg,219605
42
42
  chellow/e/bill_parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  chellow/e/bill_parsers/activity_mop_stark_xlsx.py,sha256=UgWXDPzQkQghyj_lfgBqoSJpHB-t-qOdSaB8qY6GLog,4071
44
44
  chellow/e/bill_parsers/annual_mop_stark_xlsx.py,sha256=-HMoIfa_utXYKA44RuC0Xqv3vd2HLeQU_4P0iBUd3WA,4219
@@ -310,7 +310,7 @@ chellow/templates/e/supplier_rate_script.html,sha256=tjWeCUAgNip3VLHzbXqe19Msias
310
310
  chellow/templates/e/supplier_rate_script_add.html,sha256=Yf2LZEIHbL7qT6oxBCtPf0ZX7vJsSo_ZeOKJhJoVh3o,690
311
311
  chellow/templates/e/supplier_rate_script_edit.html,sha256=VaYJt8nxHdnuP-zEAuBJC-ibEpjDU1b80hXtdBQH1dg,1968
312
312
  chellow/templates/e/supply.html,sha256=No26xivLm4hA8kRufVvPjrEOE3of7pmZaW_jgTcKSY0,8511
313
- chellow/templates/e/supply_edit.html,sha256=Ef4ivmSvj9NAb1Uy43S3TCwheCffV457bdpaoD8XZ_s,2723
313
+ chellow/templates/e/supply_edit.html,sha256=2BRGU35nb0ZpUHKCi_fgAPMU6SlHI7ve3_Ne8LXHtms,2333
314
314
  chellow/templates/e/supply_eras.html,sha256=5lB7_oC-sTWRQoASuPgBWj5XSZa9ajR0s6V6xKHvf6E,19996
315
315
  chellow/templates/e/supply_hh_data.html,sha256=d9ho4Tq3ZkR5GmxSZr_zHGwCU68PH3aSc4OwFG9i9zE,3587
316
316
  chellow/templates/e/supply_months.html,sha256=2EUF_SWCcjG9GiAw86gco8xR6LXaqCPXfQE5A33TqqI,1927
@@ -365,6 +365,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
365
365
  chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
366
366
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
367
367
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
368
- chellow-1725527086.0.0.dist-info/METADATA,sha256=oUR_vnJy2tF7UGGlfYWk61_NiBlhC64Qy7SuE-FbV38,12241
369
- chellow-1725527086.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
370
- chellow-1725527086.0.0.dist-info/RECORD,,
368
+ chellow-1725628177.0.0.dist-info/METADATA,sha256=wHjj_Ouyy8wLs6Dv3TYkeiDOzc0SCVRSPCsUOjCnSoM,12204
369
+ chellow-1725628177.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
370
+ chellow-1725628177.0.0.dist-info/RECORD,,