Skip to content

Commit

Permalink
Merge pull request #1343 from open-zaak/issue/admin-relative-urls
Browse files Browse the repository at this point in the history
Issue/admin relative urls
  • Loading branch information
sergei-maertens committed Feb 21, 2023
2 parents 5916979 + 1a7a969 commit 056deac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/openzaak/components/zaken/tests/admin/test_zaak_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import requests_mock
from django_webtest import WebTest
from vng_api_common.constants import VertrouwelijkheidsAanduiding
from zgw_consumers.constants import APITypes
from zgw_consumers.models import Service

Expand Down Expand Up @@ -100,3 +101,24 @@ def test_related_object_links(self):
with self.subTest(url):
response = self.app.get(url)
self.assertEqual(response.status_code, 200)

def test_create_with_external_zaaktype(self):
"""
Add a zaak with an external zaaktype
"""
zaak_add_url = reverse("admin:zaken_zaak_add")

response = self.app.get(zaak_add_url)

form = response.form
form["_zaaktype_base_url"] = self.service.pk
form["_zaaktype_relative_url"] = "zaken/c10edbb4-d038-4333-a9ba-bbccfc8fa8bd"
form["vertrouwelijkheidaanduiding"] = VertrouwelijkheidsAanduiding.openbaar
form["bronorganisatie"] = "517439943"
form["verantwoordelijke_organisatie"] = "517439943"
form["startdatum"] = "2023-01-01"
form["registratiedatum"] = "2023-01-01"

submit_response = form.submit()

self.assertEqual(submit_response.status_code, 302)
2 changes: 1 addition & 1 deletion src/openzaak/utils/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def check(self, **kwargs) -> List[checks.Error]:
def validate_relative_url(value):
message = _("Enter a valid relative URL.")

if value.startswith("https://", "http://", "fps://", "ftps://", "/"):
if value.startswith(("https://", "http://", "fps://", "ftps://", "/")):
raise exceptions.ValidationError(
message, code="invalid", params={"value": value}
)
Expand Down

0 comments on commit 056deac

Please sign in to comment.