Skip to content

Commit

Permalink
Merge branch 'master' into TP2000-1069--packaging-queue-management-co…
Browse files Browse the repository at this point in the history
…mmand
  • Loading branch information
paulpepper-trade authored Sep 28, 2023
2 parents 1d03bb7 + b5e90ef commit 44aae88
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 18 deletions.
2 changes: 1 addition & 1 deletion common/static/common/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const nodeListForEach = (nodes, callback) => {
}
}

const newLine = /\n/g;
const newLine = /[\n\r]/g;
const removeNewLine = (str) => str.replace(newLine, "")

const cleanResults = (results) => {
Expand Down
4 changes: 3 additions & 1 deletion measures/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,9 @@ def clean(self):

# Use quota order number origins and exclusions to set cleaned_data
if self.order_number:
origins = self.order_number.quotaordernumberorigin_set.current()
origins = (
self.order_number.quotaordernumberorigin_set.current().as_at_today_and_beyond()
)
cleaned_data["geo_areas_and_exclusions"] = [
{
"geo_area": origin.geographical_area,
Expand Down
18 changes: 14 additions & 4 deletions measures/jinja2/measures/create-geo-areas-formset.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@
{% from "components/summary-list/macro.njk" import govukSummaryList %}

{% block breadcrumb %}
{% if request.path != "/" %}
{{ breadcrumbs(request, [{"text": "Review the geographical areas"}]) }}
{% if order_number %}
{% if request.path != "/" %}
{{ breadcrumbs(request, [{"text": "Review the geographical areas"}]) }}
{% endif %}
{% else %}
{{ super() }}
{% endif %}
{% endblock %}
{% endblock %}

{% block page_title_heading %}Review the geographical areas{% endblock %}
{% block page_title_heading %}
{% if order_number %}
Review the geographical areas
{% else %}
{{ super() }}
{% endif %}
{% endblock %}

{% block form %}
{% if order_number and origins_and_exclusions %}
Expand Down
30 changes: 19 additions & 11 deletions measures/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,26 @@ def test_measure_forms_geo_area_invalid_data_error_messages(data, error, erga_om
assert error in form.errors["geo_area"]


def test_measure_geographical_area_form_quota_order_number():
def test_measure_geographical_area_form_quota_order_number(date_ranges):
"""Tests that `MeasureGeographicalAreaForm` sets `cleaned_data` with
geographical data from quota order number if one is passed in `kwargs`."""
origin_1 = factories.QuotaOrderNumberOriginFactory.create()
origin_2 = factories.QuotaOrderNumberOriginFactory.create(
order_number=origin_1.order_number,
old_origin = factories.QuotaOrderNumberOriginFactory.create(
valid_between=date_ranges.earlier,
)
origin_1_exclusions = factories.QuotaOrderNumberOriginExclusionFactory.create_batch(
2,
origin=origin_1,
order_number = old_origin.order_number

new_origin_1 = factories.QuotaOrderNumberOriginFactory.create(
order_number=order_number,
)
new_origin_2 = factories.QuotaOrderNumberOriginFactory.create(
order_number=order_number,
)
new_origin_1_exclusions = (
factories.QuotaOrderNumberOriginExclusionFactory.create_batch(
2,
origin=new_origin_1,
)
)
order_number = origin_1.order_number

with override_current_transaction(Transaction.objects.last()):
form = forms.MeasureGeographicalAreaForm(
Expand All @@ -495,11 +503,11 @@ def test_measure_geographical_area_form_quota_order_number():

expected_cleaned_data = [
{
"geo_area": origin_1.geographical_area,
"exclusions": list(origin_1.excluded_areas.all()),
"geo_area": new_origin_1.geographical_area,
"exclusions": list(new_origin_1.excluded_areas.all()),
},
{
"geo_area": origin_2.geographical_area,
"geo_area": new_origin_2.geographical_area,
"exclusions": [],
},
]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ elastic-apm==6.7.2
factory-boy==3.2.0
flower==1.2.0
freezegun==1.1.0
gevent==21.12.0
gevent==23.9.1
govuk-frontend-jinja @ git+https://github.com/alphagov/govuk-frontend-jinja.git@15845e4cca3a05df72c6e13ec6a7e35acc682f52
govuk-tech-docs-sphinx-theme==1.0.0
gunicorn==20.1.0
Expand Down

0 comments on commit 44aae88

Please sign in to comment.