chellow 1712838153.0.0__py3-none-any.whl → 1712909617.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/bsuos.py CHANGED
@@ -219,7 +219,9 @@ def _process_url(logger, sess, url, contract, s):
219
219
  for row in reader:
220
220
  date_str = row[0].strip()
221
221
  len_date_str = len(date_str)
222
- if len_date_str == 19:
222
+ if len_date_str == 0:
223
+ continue
224
+ elif len_date_str == 19:
223
225
  sep_char = date_str[13]
224
226
  date_format = f"%Y-%m-%dT%H{sep_char}%M:%S"
225
227
  elif len_date_str == 20:
chellow/e/views.py CHANGED
@@ -105,7 +105,11 @@ from chellow.utils import (
105
105
  utc_datetime,
106
106
  utc_datetime_now,
107
107
  )
108
- from chellow.views import chellow_redirect as credirect, hx_redirect as chx_redirect
108
+ from chellow.views import (
109
+ chellow_redirect as credirect,
110
+ hx_redirect as chx_redirect,
111
+ requires_editor,
112
+ )
109
113
 
110
114
 
111
115
  def chellow_redirect(path, code=None):
@@ -1075,6 +1079,29 @@ def dc_contract_get(dc_contract_id):
1075
1079
  )
1076
1080
 
1077
1081
 
1082
+ @e.route("/dc_contracts/<int:dc_contract_id>/properties")
1083
+ @requires_editor
1084
+ def dc_contract_properties_get(dc_contract_id):
1085
+ contract = Contract.get_dc_by_id(g.sess, dc_contract_id)
1086
+ return render_template("dc_contract_properties.html", dc_contract=contract)
1087
+
1088
+
1089
+ @e.route("/dc_contracts/<int:dc_contract_id>/properties/edit")
1090
+ @requires_editor
1091
+ def dc_contract_properties_edit_get(dc_contract_id):
1092
+ dc_contract = Contract.get_dc_by_id(g.sess, dc_contract_id)
1093
+ return render_template("dc_contract_properties_edit.html", dc_contract=dc_contract)
1094
+
1095
+
1096
+ @e.route("/dc_contracts/<int:contract_id>/properties/edit", methods=["POST"])
1097
+ def dc_contract_properties_edit_post(contract_id):
1098
+ contract = Contract.get_dc_by_id(g.sess, contract_id)
1099
+ properties = req_zish("properties")
1100
+ contract.update(contract.name, contract.party, contract.charge_script, properties)
1101
+ g.sess.commit()
1102
+ return chellow_redirect(f"/dc_contracts/{contract.id}/properties", 303)
1103
+
1104
+
1078
1105
  @e.route("/dc_contracts/<int:dc_contract_id>/edit")
1079
1106
  def dc_contract_edit_get(dc_contract_id):
1080
1107
  parties = (
@@ -1127,9 +1154,8 @@ def dc_contract_edit_post(contract_id):
1127
1154
  party_id = req_int("party_id")
1128
1155
  name = req_str("name")
1129
1156
  charge_script = req_str("charge_script")
1130
- properties = req_zish("properties")
1131
1157
  party = Party.get_by_id(g.sess, party_id)
1132
- contract.update(name, party, charge_script, properties)
1158
+ contract.update(name, party, charge_script, contract.properties)
1133
1159
  g.sess.commit()
1134
1160
  return chellow_redirect(f"/dc_contracts/{contract.id}", 303)
1135
1161
  except BadRequest as e:
@@ -66,6 +66,9 @@
66
66
  </table>
67
67
  <br>
68
68
  <ul>
69
+ <li>
70
+ <a href="/e/dc_contracts/{{dc_contract.id}}/properties">Properties</a>
71
+ </li>
69
72
  <li>
70
73
  <a href="/e/dc_batches?dc_contract_id={{dc_contract.id}}">Batches</a>
71
74
  </li>
@@ -99,10 +102,6 @@
99
102
 
100
103
  <pre>{{dc_contract.charge_script}}</pre>
101
104
 
102
- <h3>Properties</h3>
103
-
104
- <pre>{{dc_contract.properties }}</pre>
105
-
106
105
  <h3>State</h3>
107
106
 
108
107
  <pre>{{dc_contract.state }}</pre>
@@ -42,58 +42,10 @@
42
42
  {{input_textarea(
43
43
  'charge_script', dc_contract.charge_script, 40, 80)}}
44
44
 
45
- <label>Properties</label>
46
- {{ input_textarea(
47
- 'properties', dc_contract.properties, 40, 80) }}
48
-
49
45
  <input type="submit" value="Update">
50
46
  </fieldset>
51
47
  </form>
52
48
 
53
- <h4>Example</h4>
54
-
55
- <p>For the SFTP protocol:</p>
56
- <code>
57
- <pre>
58
- {
59
- "enabled": true,
60
- "protocol": "sftp",
61
- "file_type": ".df2",
62
- "hostname": "example.com",
63
- "username": "username",
64
- "password": "password",
65
- "directories": ["downloads1", "downloads2"]
66
- "mpan_map": { \\ Optional
67
- "99 0993 2821 985": null, \\ Ignore MPAN
68
- },
69
- }
70
- </pre>
71
- </code>
72
- <p>For the HTTPS protocol:</p>
73
- <code>
74
- <pre>
75
- {% raw %}
76
- {
77
- "enabled": true,
78
- "protocol": "https",
79
- "download_days": 8,
80
- "parser": "meniscus",
81
- "url_template": "https://data.example.com/?from={{chunk_start.strftime('%d/%m/%Y')}}&amp;to={{chunk_finish.strftime('%d/%m/%Y')}}",
82
- "url_values": {
83
- "99 4298 4729 917": {
84
- "name1": val1,
85
- "name2": val2,
86
- }
87
- }
88
- "mpan_map": { \\ Optional
89
- "99 0993 2821 985": null, \\ Ignore MPAN
90
- },
91
- }
92
-
93
- {% endraw %}
94
- </pre>
95
- </code>
96
-
97
49
  <form action="/e/dc_contracts/{{dc_contract.id}}/edit" method="post">
98
50
  <fieldset>
99
51
  <legend>Update State</legend>
@@ -0,0 +1,17 @@
1
+ {% extends "base.html" %}
2
+
3
+ {% block title %}
4
+ &raquo; DC Contracts &raquo; {{dc_contract.name}} &raquo; Properties
5
+ {% endblock %}
6
+
7
+ {% block nav %}
8
+ <a href="/e/dc_contracts">DC Contracts</a> &raquo;
9
+ <a href="/e/dc_contracts/{{dc_contract.id}}">dc_contract.name</a> &raquo;
10
+ Properties [<a href="/e/dc_contracts/{{dc_contract.id}}/properties/edit">edit</a>]
11
+ {% endblock %}
12
+
13
+ {% block content %}
14
+
15
+ <pre>{{dc_contract.properties }}</pre>
16
+
17
+ {% endblock %}
@@ -0,0 +1,70 @@
1
+ {% extends "base.html" %}
2
+
3
+ {% block title %}
4
+ &raquo; DC Contracts &raquo; {{dc_contract.name}} &raquo; Properties &raquo; Edit
5
+ {% endblock %}
6
+
7
+ {% block nav %}
8
+ <a href="/e/dc_contracts">DC Contracts</a> &raquo;
9
+ <a href="/e/dc_contracts/{{dc_contract.id}}">{{dc_contract.name}}</a> &raquo;
10
+ <a href="/e/dc_contracts/{{dc_contract.id}}/properties">Properties</a> &raquo;
11
+ Edit
12
+ {% endblock %}
13
+
14
+ {% block content %}
15
+
16
+ <form action="/e/dc_contracts/{{dc_contract.id}}/properties/edit" method="post">
17
+ <fieldset>
18
+ <legend>Update Properties</legend>
19
+
20
+ <label>Properties</label>
21
+ {{ input_textarea('properties', dc_contract.properties, 40, 80) }}
22
+
23
+ <input type="submit" value="Update">
24
+ </fieldset>
25
+ </form>
26
+
27
+ <h4>Example</h4>
28
+
29
+ <p>For the SFTP protocol:</p>
30
+ <code>
31
+ <pre>
32
+ {
33
+ "enabled": true,
34
+ "protocol": "sftp",
35
+ "file_type": ".df2",
36
+ "hostname": "example.com",
37
+ "username": "username",
38
+ "password": "password",
39
+ "directories": ["downloads1", "downloads2"]
40
+ "mpan_map": { \\ Optional
41
+ "99 0993 2821 985": null, \\ Ignore MPAN
42
+ },
43
+ }
44
+ </pre>
45
+ </code>
46
+ <p>For the HTTPS protocol:</p>
47
+ <code>
48
+ <pre>
49
+ {% raw %}
50
+ {
51
+ "enabled": true,
52
+ "protocol": "https",
53
+ "download_days": 8,
54
+ "parser": "meniscus",
55
+ "url_template": "https://data.example.com/?from={{chunk_start.strftime('%d/%m/%Y')}}&amp;to={{chunk_finish.strftime('%d/%m/%Y')}}",
56
+ "url_values": {
57
+ "99 4298 4729 917": {
58
+ "name1": val1,
59
+ "name2": val2,
60
+ }
61
+ }
62
+ "mpan_map": { \\ Optional
63
+ "99 0993 2821 985": null, \\ Ignore MPAN
64
+ },
65
+ }
66
+
67
+ {% endraw %}
68
+ </pre>
69
+ </code>
70
+ {% endblock %}
chellow/views.py CHANGED
@@ -11,6 +11,7 @@ import types
11
11
  from collections import OrderedDict
12
12
  from datetime import datetime as Datetime
13
13
  from decimal import Decimal
14
+ from functools import wraps
14
15
  from importlib import import_module
15
16
  from io import DEFAULT_BUFFER_SIZE, StringIO
16
17
  from itertools import chain, islice
@@ -52,7 +53,7 @@ from sqlalchemy.exc import IntegrityError
52
53
  from sqlalchemy.orm import joinedload
53
54
  from sqlalchemy.orm.attributes import flag_modified
54
55
 
55
- from werkzeug.exceptions import BadRequest
56
+ from werkzeug.exceptions import BadRequest, Forbidden
56
57
 
57
58
  import chellow.bank_holidays
58
59
  import chellow.dloads
@@ -147,6 +148,17 @@ def hx_redirect(path, status=None):
147
148
  return res
148
149
 
149
150
 
151
+ def requires_editor(f):
152
+ @wraps(f)
153
+ def decorated_function(*args, **kwargs):
154
+ if g.user.user_role.code == "editor":
155
+ return f(*args, **kwargs)
156
+ else:
157
+ raise Forbidden("You must be an editor to do this.")
158
+
159
+ return decorated_function
160
+
161
+
150
162
  @home.route("/configuration", methods=["GET"])
151
163
  def configuration():
152
164
  config = Contract.get_non_core_by_name(g.sess, "configuration")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: chellow
3
- Version: 1712838153.0.0
3
+ Version: 1712909617.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)
@@ -11,12 +11,12 @@ chellow/proxy.py,sha256=cVXIktPlX3tQ1BYcwxq0nJXKE6r3DtFTtfFHPq55HaM,1351
11
11
  chellow/rate_server.py,sha256=vNuKzlr0lkAzZ4zG7zboStoo92_6iLKAxbw1yZ-ucII,5626
12
12
  chellow/testing.py,sha256=Od4HHH6pZrhJ_De118_F55RJEKmAvhUH2S24QE9qFQk,3635
13
13
  chellow/utils.py,sha256=32qPWEGzCPKPhSM7ztpzcR6ZG74sVZanScDIdK50Rq4,19308
14
- chellow/views.py,sha256=_vkjpoprfhIAzbaDlBYf2ewfsJXcthY_t9tfjrcMK9g,78520
14
+ chellow/views.py,sha256=YmczsGgUjNIWf3VZcH1oscOYolJhZ4j8mUBS8RewrHY,78838
15
15
  chellow/e/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  chellow/e/aahedc.py,sha256=d2usudp7KYWpU6Pk3fal5EQ47EbvkvKeaFGylnb3NWw,606
17
17
  chellow/e/bill_importer.py,sha256=y1bpn49xDwltj0PRFowWsjAVamcD8eyxUbCTdGxEZiE,7389
18
18
  chellow/e/bmarketidx.py,sha256=0JCBBnP3xfLq2eFjXO_u-gzHyTizab4Pp6PRK6OZLcw,7134
19
- chellow/e/bsuos.py,sha256=f3TsTaUbEfAGK7hwPf5nSu7QqGnb8rht8mx6a3Y98fc,15489
19
+ chellow/e/bsuos.py,sha256=hdP9vnOJSuZl46OAkJeUg1XJYvYIBj4J6Sqce1Hy9Vs,15542
20
20
  chellow/e/ccl.py,sha256=CYeFrg0TNF7Av49nqxa0guA8CMcJhdMpBRmOq8PH6G0,564
21
21
  chellow/e/cfd.py,sha256=V1DTT5XBQbt8hO1gae1u3315fZ4iuYk3XC7J2sUbhKQ,14352
22
22
  chellow/e/computer.py,sha256=YL1JFUYfFW-i9DODfvSnp6gTL_MwIfwoWj1TWtOsxPg,67105
@@ -38,7 +38,7 @@ chellow/e/system_price.py,sha256=3cPWohHmmBI9v7fENLBzXQkpAeC3r0s5xV29Nmr6k_E,583
38
38
  chellow/e/tlms.py,sha256=kHAy2A2d1Mma7x4GdNDyrzscJd5DpJtDBYiZEg241Dw,8538
39
39
  chellow/e/tnuos.py,sha256=KoMPJDIXfE4zwhSDuywGF1ooxjTYLVjtF7BkSFm6X24,4158
40
40
  chellow/e/triad.py,sha256=S6LEMHvUKhAZe0-yfLIRciYDZ8IKMn1jh1TmmsbQD3s,13588
41
- chellow/e/views.py,sha256=p-zQa24HtNVLTHILqfiZ8UrixuljHSC163SrJuLQ3Ik,212590
41
+ chellow/e/views.py,sha256=EdNlMI-cutMhWiog_PUBOW1jWu-u4MLOCHxv1uyIGVQ,213550
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
@@ -183,10 +183,12 @@ chellow/templates/e/dc_bill_add.html,sha256=73Sn_MKBsUuYYnDfUMCdX1Dul6GimMC9YXk6
183
183
  chellow/templates/e/dc_bill_edit.html,sha256=0GsN-ZIc4q-z_xs8igC2ZS6t4soo2SvB3qRA6iC-AuM,2707
184
184
  chellow/templates/e/dc_bill_import.html,sha256=NHjMSoFizvFQIaPWuVE3nTCtMDTzJB0XmH8jXfV1tiA,2188
185
185
  chellow/templates/e/dc_bill_imports.html,sha256=lCaUR47r9KPr0VrQhEvVEaKexM5R_nmkxtzgpWZ0e9s,2135
186
- chellow/templates/e/dc_contract.html,sha256=_fq_s69kmbrGlScYngRYm4cPdRgh2roMvSfvG0J4xzA,2326
187
- chellow/templates/e/dc_contract_edit.html,sha256=wKK2pXN78VfSJ6gjfNRkikRFkYTiKtGL3UeVFIYSRwc,3115
186
+ chellow/templates/e/dc_contract.html,sha256=b6DLDrGdzN9Rri56pFvfpE7QZKYXGHib2veYAztuHlg,2352
187
+ chellow/templates/e/dc_contract_edit.html,sha256=YraU0_MTBjmzBCMdsuvtIYm7K58hnDly5wUZ-6n8XzY,2148
188
188
  chellow/templates/e/dc_contract_hh_import.html,sha256=UODiBFNohb60MjH1w-9JW1JE0O9GR2uKPGw-lD7Da5g,848
189
189
  chellow/templates/e/dc_contract_hh_imports.html,sha256=eXFDGyzSgag4JRism81_p5yTzQOjCIXaVkQ8tl3dDcM,8172
190
+ chellow/templates/e/dc_contract_properties.html,sha256=fOHCBeAI7k9yi9vBCtaYDpYRB9zk1WuMaO1pnNCMxes,451
191
+ chellow/templates/e/dc_contract_properties_edit.html,sha256=852aWHaDsIa_VZdn9sLQzjP7ynueXa0CKL4ZHaOBmmM,1585
190
192
  chellow/templates/e/dc_contracts.html,sha256=v8czpEcMzndngfWNXIKXib6Xrz9OwJjQAmNQNrQ6Y08,1705
191
193
  chellow/templates/e/dc_contracts_add.html,sha256=2lrGrNqAoKp16OiMoNDNlJxBMW3QdSPfgEFheSg826s,710
192
194
  chellow/templates/e/dc_rate_script.html,sha256=gfKUHV2IMsTQT-cYfjl4aiEBqGEWSj3uW22UZpoyGq4,1219
@@ -361,6 +363,6 @@ chellow/templates/g/supply_note_edit.html,sha256=6UQf_qbhFDys3cVsTp-c7ABWZpggW9R
361
363
  chellow/templates/g/supply_notes.html,sha256=WR3YwGh_qqTklSJ7JqWX6BKBc9rk_jMff4RiWZiF2CM,936
362
364
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
363
365
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
364
- chellow-1712838153.0.0.dist-info/METADATA,sha256=Xtd86NDSwOVRdtBadWm_V5D9VIJ2WCa2T17MD_rBvG0,12203
365
- chellow-1712838153.0.0.dist-info/WHEEL,sha256=as-1oFTWSeWBgyzh0O_qF439xqBe6AbBgt4MfYe5zwY,87
366
- chellow-1712838153.0.0.dist-info/RECORD,,
366
+ chellow-1712909617.0.0.dist-info/METADATA,sha256=qV7hEsZpgKlO6cp3iu5A8YJhHVmh28JRt1sVz42GH64,12203
367
+ chellow-1712909617.0.0.dist-info/WHEEL,sha256=as-1oFTWSeWBgyzh0O_qF439xqBe6AbBgt4MfYe5zwY,87
368
+ chellow-1712909617.0.0.dist-info/RECORD,,