Skip to content

Commit

Permalink
Merge pull request #265 from UKGovernmentBEIS/staging
Browse files Browse the repository at this point in the history
Deploy staging to main
  • Loading branch information
jamiehumphries authored Jan 31, 2024
2 parents 8733b6c + bbe7a6f commit 95e7546
Show file tree
Hide file tree
Showing 22 changed files with 1,469 additions and 562 deletions.
422 changes: 413 additions & 9 deletions .gitignore

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Formerly known as "Help to Heat".
## Initial Setup

1. From the project root, run `cp envs/web.template envs/web`
2. Populate the OS API key into the OS_API_KEY variable. The key can be found in keeper
2. Populate the OS API key into the OS_API_KEY variable. The key can be found in Keeper. Please only use a single value (i.e. `["my_key_here"]`), rather than all of the keys that are stored in Keeper, in order to avoid needing to rotate all of the keys if your local environment is accidentally leaked.

## Using Docker

Expand Down
16 changes: 12 additions & 4 deletions docker/web/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ echo "Starting app"

python manage.py collectstatic --no-input

watchmedo auto-restart --directory=./ --pattern=""*.py"" --recursive -- \
gunicorn --bind="0.0.0.0:$PORT" \
--workers=24 --worker-class="eventlet" \
help_to_heat.wsgi:application
if [ "$DEBUG" = "True" ]
then
watchmedo auto-restart --directory=./ --pattern=""*.py"" --recursive -- \
waitress-serve --port=$PORT --threads=128 --asyncore-use-poll \
--connection-limit=2000 --backlog=2000 \
help_to_heat.wsgi:application
else
watchmedo auto-restart --directory=./ --pattern=""*.py"" --recursive -- \
gunicorn --bind="0.0.0.0:$PORT" \
--workers=24 --worker-class="eventlet" \
help_to_heat.wsgi:application
fi
2 changes: 1 addition & 1 deletion envs/web
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CONTACT_EMAIL="[email protected]"
FROM_EMAIL="[email protected]"
EMAIL_BACKEND_TYPE=CONSOLE
BASE_URL=http://localhost:8012/
OS_API_KEY=["f4k3k3y"]
OS_API_KEY=["api_key_1","api_key_2","api_key_3","api_key_4","api_key_5"]
EPC_API_BASE_URL="https://api.epb.digital.communities.gov.uk"
EPC_API_CLIENT_ID="client_id"
EPC_API_CLIENT_SECRET="client_secret"
115 changes: 36 additions & 79 deletions help_to_heat/frontdoor/eligibility.py
Original file line number Diff line number Diff line change
@@ -1,95 +1,52 @@
import logging
gbis = "GBIS"
eco4 = "ECO4"

logger = logging.getLogger(__name__)
not_eligible = ()
eligible_for_gbis = (gbis,)
eligible_for_gbis_and_eco4 = (gbis, eco4)

country_council_tax_bands = {
"England": {
"eligible": ("A", "B", "C", "D"),
"ineligible": ("E", "F", "G", "H"),
},
"Scotland": {
"eligible": ("A", "B", "C", "D", "E"),
"ineligible": ("F", "G", "H"),
},
"Wales": {
"eligible": ("A", "B", "C", "D", "E"),
"ineligible": ("F", "G", "H", "I"),
},
}

def _is_eligible_council_tax_band(country, council_tax_band):
if country == "England":
return council_tax_band in ("A", "B", "C", "D")
if country in ("Scotland", "Wales"):
return council_tax_band in ("A", "B", "C", "D", "E")
return False


def calculate_eligibility(session_data):
"""
:param session_data:
:return: A tuple of which schemes the person is eligible for, if any
"""
epc_rating = session_data.get("epc_rating", "Not found")
council_tax_band = session_data.get("council_tax_band")
country = session_data.get("country")
benefits = session_data.get("benefits")
property_type = session_data.get("property_type")
own_property = session_data.get("own_property")
property_type = session_data.get("property_type")
park_home_main_residence = session_data.get("park_home_main_residence", "No")
council_tax_band = session_data.get("council_tax_band")
epc_rating = session_data.get("epc_rating", "Not found")
accept_suggested_epc = session_data.get("accept_suggested_epc")
benefits = session_data.get("benefits")
household_income = session_data.get("household_income")

# "Scenario 0"
if property_type == "Park home":
return ("GBIS",)

# ECO4 and GBIS scenario 1 - home owner
if country in country_council_tax_bands:
if own_property in ("Yes, I own my property and live in it",):
if epc_rating in ("D", "E", "F", "G", "Not found"):
if benefits in ("Yes",):
return ("GBIS", "ECO4")
if country not in ("England", "Scotland", "Wales"):
return not_eligible

# ECO4 and GBIS scenario 2 - private rented (tenant or landlord)
if country in country_council_tax_bands:
if own_property in (
"No, I am a tenant",
"Yes, I am the property owner but I lease the property to one or more tenants",
):
if epc_rating in ("E", "F", "G", "Not found"):
if benefits in ("Yes",):
return ("GBIS", "ECO4")
if epc_rating in ("A", "B", "C") and accept_suggested_epc == "Yes":
return not_eligible

# ECO4 and GBIS scenario 3 - social housing tenant
if country in country_council_tax_bands:
if own_property in ("No, I am a social housing tenant",):
if epc_rating in ("D", "E", "F", "G", "Not found"):
if benefits in ("Yes",):
return ("GBIS", "ECO4")
if own_property == "No, I am a social housing tenant":
return eligible_for_gbis_and_eco4

# Scenario 3
if country in country_council_tax_bands:
if council_tax_band in country_council_tax_bands[country]["eligible"]:
if epc_rating in ("D", "E", "F", "G", "Not found"):
if benefits in ("No",):
return ("GBIS",)
if property_type == "Park home" and park_home_main_residence == "No":
return not_eligible

if country in country_council_tax_bands:
if council_tax_band in country_council_tax_bands[country]["eligible"]:
if epc_rating in ("D", "Not Found"):
if benefits in ("Yes",):
return ("GBIS",)
if benefits == "Yes":
return eligible_for_gbis_and_eco4

# Scenario 3.1
if country in country_council_tax_bands:
if council_tax_band in country_council_tax_bands[country]["ineligible"]:
if epc_rating in ("D", "Not Found"):
if benefits in ("Yes",):
return ("GBIS",)
if household_income == "Less than £31,000 a year":
return eligible_for_gbis_and_eco4

# Scenario 4
if country in country_council_tax_bands:
if council_tax_band in country_council_tax_bands[country]["ineligible"]:
if epc_rating in ("D", "E", "F", "G"):
if benefits in ("No",):
return ()
if property_type == "Park home":
return eligible_for_gbis

# Scenario 5
if country in country_council_tax_bands:
if council_tax_band in country_council_tax_bands[country]["ineligible"]:
if epc_rating in ("Not found"):
if benefits in ("No",):
return ()
if _is_eligible_council_tax_band(country, council_tax_band):
return eligible_for_gbis

return ()
return not_eligible
45 changes: 41 additions & 4 deletions help_to_heat/frontdoor/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"country",
"supplier",
"own-property",
"park-home",
"address",
"council-tax-band",
"epc",
Expand All @@ -33,6 +34,7 @@
"park-home",
"park-home-main-residence",
"address",
"epc",
"benefits",
"household-income",
"summary",
Expand All @@ -42,6 +44,25 @@
"success",
)

page_order_social_housing = (
"country",
"supplier",
"own-property",
"address",
"epc",
"property-type",
"property-subtype",
"number-of-bedrooms",
"wall-type",
"wall-insulation",
"loft",
"summary",
"schemes",
"contact-details",
"confirm-and-submit",
"success",
)

extra_pages = (
"applications-closed",
"address-select",
Expand All @@ -65,7 +86,7 @@
"loft-access": {"prev": "loft", "next": "loft-insulation"},
"loft-insulation": {"prev": "loft-access", "next": "summary"},
"epc-ineligible": {"prev": "epc", "next": None},
"ineligible": {"prev": "benefits", "next": None},
"ineligible": {"prev": "household-income", "next": None},
"northern-ireland": {"prev": "country", "next": None},
"bulb-warning-page": {"prev": "supplier", "next": "own-property"},
"utility-warehouse-warning-page": {"prev": "supplier", "next": "own-property"},
Expand All @@ -77,15 +98,31 @@
}

page_prev_next_map_park_home = {
"address-select": {"prev": "address", "next": "benefits"},
"epc-select": {"prev": "address", "next": "benefits"},
"address-manual": {"prev": "address", "next": "benefits"},
"address-select": {"prev": "address", "next": "epc"},
"epc-select": {"prev": "address", "next": "epc"},
"address-manual": {"prev": "address", "next": "epc"},
"northern-ireland": {"prev": "country", "next": None},
"bulb-warning-page": {"prev": "supplier", "next": "own-property"},
"utility-warehouse-warning-page": {"prev": "supplier", "next": "own-property"},
"applications-closed": {"prev": "supplier", "next": None},
"application-closed-utility-warehouse": {"prev": "supplier", "next": None},
"park-home-application-closed": {"prev": "park-home-main-residence", "next": None},
"epc-ineligible": {"prev": "epc", "next": None},
"ineligible": {"prev": "household-income", "next": None},
}

page_prev_next_map_social_housing = {
"address-select": {"prev": "address", "next": "epc"},
"epc-select": {"prev": "address", "next": "epc"},
"address-manual": {"prev": "address", "next": "epc"},
"loft": {"prev": "wall-insulation", "next": "loft-access"},
"loft-access": {"prev": "loft", "next": "loft-insulation"},
"loft-insulation": {"prev": "loft-access", "next": "summary"},
"epc-ineligible": {"prev": "epc", "next": None},
"northern-ireland": {"prev": "country", "next": None},
"bulb-warning-page": {"prev": "supplier", "next": "own-property"},
"utility-warehouse-warning-page": {"prev": "supplier", "next": "own-property"},
"applications-closed": {"prev": "supplier", "next": None},
}

summary_map = {
Expand Down
Loading

0 comments on commit 95e7546

Please sign in to comment.