Skip to content

Commit

Permalink
i
Browse files Browse the repository at this point in the history
  • Loading branch information
tlocke committed Sep 4, 2023
1 parent 08a8fd7 commit 3408e1d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 13 deletions.
58 changes: 48 additions & 10 deletions chellow/e/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)

from sqlalchemy import Float, case, cast, false, func, null, or_, select, text, true
from sqlalchemy.orm import joinedload
from sqlalchemy.orm import aliased, joinedload


from werkzeug.exceptions import BadRequest, NotFound
Expand Down Expand Up @@ -3825,22 +3825,60 @@ def site_add_e_supply_form_get(site_id):
.filter(SiteEra.site == site)
.order_by(Era.start_date.desc())
)
mop_contracts = (
g.sess.query(Contract)
RateScriptAliasStart = aliased(RateScript)
RateScriptAliasFinish = aliased(RateScript)
mop_contracts = g.sess.scalars(
select(Contract)
.join(MarketRole)
.filter(MarketRole.code == "M")
.join(
RateScriptAliasStart,
Contract.start_rate_script_id == RateScriptAliasStart.id,
)
.join(
RateScriptAliasFinish,
Contract.finish_rate_script_id == RateScriptAliasFinish.id,
)
.where(
MarketRole.code == "M",
start_date >= RateScriptAliasStart.start_date,
RateScriptAliasFinish.finish_date == null(),
)
.order_by(Contract.name)
)
dc_contracts = (
g.sess.query(Contract)
dc_contracts = g.sess.scalars(
select(Contract)
.join(MarketRole)
.filter(MarketRole.code.in_(("C", "D")))
.join(
RateScriptAliasStart,
Contract.start_rate_script_id == RateScriptAliasStart.id,
)
.join(
RateScriptAliasFinish,
Contract.finish_rate_script_id == RateScriptAliasFinish.id,
)
.where(
MarketRole.code.in_(("C", "D")),
start_date >= RateScriptAliasStart.start_date,
RateScriptAliasFinish.finish_date == null(),
)
.order_by(Contract.name)
)
supplier_contracts = (
g.sess.query(Contract)
supplier_contracts = g.sess.scalars(
select(Contract)
.join(MarketRole)
.filter(MarketRole.code == "X")
.join(
RateScriptAliasStart,
Contract.start_rate_script_id == RateScriptAliasStart.id,
)
.join(
RateScriptAliasFinish,
Contract.finish_rate_script_id == RateScriptAliasFinish.id,
)
.where(
MarketRole.code == "X",
start_date >= RateScriptAliasStart.start_date,
RateScriptAliasFinish.finish_date == null(),
)
.order_by(Contract.name)
)
pcs = g.sess.query(Pc).order_by(Pc.code)
Expand Down
6 changes: 3 additions & 3 deletions chellow/templates/e/site_add_e_supply_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@
{% endfor %}
</select>

<label>Properties</label> {{input_textarea('properties', '{}', 20, 80)}}
<label>Properties</label> {{input_textarea('properties', '{}', 10, 80)}}

<label>Has An Import MPAN?</label> {{input_checkbox('has_imp_mpan')}}

{% if 'has_imp_mpan' in request.values %}
{% if request.values.has_imp_mpan == 'true' %}
<fieldset>
<legend>Import</legend>
<label>Mpan Core</label>
Expand All @@ -143,7 +143,7 @@

<label>Has An Export MPAN?</label> {{input_checkbox('has_exp_mpan')}}

{% if 'has_exp_mpan' in request.values %}
{% if request.values.has_exp_mpan == 'true' %}
<fieldset>
<legend>Export</legend>
<label>Mpan Core</label>
Expand Down

0 comments on commit 3408e1d

Please sign in to comment.