Skip to content

Commit

Permalink
feat: Add correct path to allow unpublished quota order numbers to be…
Browse files Browse the repository at this point in the history
… edited (#1067)
  • Loading branch information
nboyse authored Oct 17, 2023
1 parent bd0cddf commit cba08df
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion quotas/jinja2/includes/quotas/actions.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
<li><a class="govuk-link" href="{{ uk_tariff_url }}" target="_blank" noopener noreferrer>View this quota on the UK Integrated Online Tariff </a></li>
</ul>
</div>
</div>
</div>
63 changes: 63 additions & 0 deletions quotas/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,3 +1059,66 @@ def test_quota_create_origin_no_overlapping_origins(
"There may be no overlap in time of two quota order number origins with "
"the same quota order number SID and geographical area id."
)


@pytest.mark.django_db
def test_quota_order_number_and_origin_edit_create_view(
valid_user_client, date_ranges, approved_transaction, geo_group1, geo_group2
):
quota = factories.QuotaOrderNumberFactory.create(
valid_between=date_ranges.no_end,
transaction=approved_transaction,
)

origin = models.QuotaOrderNumberOrigin.objects.last()

form_data = {
"start_date_0": origin.valid_between.lower.day,
"start_date_1": origin.valid_between.lower.month,
"start_date_2": origin.valid_between.lower.year,
"geographical_area": geo_group1.id,
"quota-origin-exclusions-formset-__prefix__-exclusion": geo_group2.id,
"submit": "Save",
}

response = valid_user_client.post(
reverse("quota_order_number_origin-ui-edit-create", kwargs={"sid": origin.sid}),
form_data,
)

assert response.status_code == 302

response = valid_user_client.get(
reverse("quota-ui-edit-create", kwargs={"sid": quota.sid}),
form_data,
)

assert response.status_code == 200


@pytest.mark.django_db
def test_quota_order_number_update_view(
valid_user_client, date_ranges, approved_transaction, geo_group1, geo_group2
):
quota = factories.QuotaOrderNumberFactory.create(
valid_between=date_ranges.no_end,
transaction=approved_transaction,
)

origin = models.QuotaOrderNumberOrigin.objects.last()

form_data = {
"start_date_0": origin.valid_between.lower.day,
"start_date_1": origin.valid_between.lower.month,
"start_date_2": origin.valid_between.lower.year,
"geographical_area": geo_group1.id,
"quota-origin-exclusions-formset-__prefix__-exclusion": geo_group2.id,
"submit": "Save",
}

response = valid_user_client.get(
reverse("quota-ui-edit-update", kwargs={"sid": quota.sid}),
form_data,
)

assert response.status_code == 200
5 changes: 5 additions & 0 deletions quotas/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
views.QuotaOrderNumberOriginUpdate.as_view(),
name="quota_order_number_origin-ui-edit",
),
path(
f"quota_order_number_origins/<sid>/edit-create/",
views.QuotaOrderNumberOriginUpdate.as_view(),
name="quota_order_number_origin-ui-edit-create",
),
path(
f"quotas/<sid>/quota_order_number_origins/",
views.QuotaOrderNumberOriginCreate.as_view(),
Expand Down
7 changes: 7 additions & 0 deletions quotas/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,13 @@ class QuotaUpdate(
pass


class QuotaEditCreate(
QuotaUpdateMixin,
EditTaricView,
):
pass


class QuotaEditUpdate(
QuotaUpdateMixin,
EditTaricView,
Expand Down

0 comments on commit cba08df

Please sign in to comment.