Skip to content

Commit

Permalink
Merge pull request #2371 from uktrade/dev
Browse files Browse the repository at this point in the history
UAT release
  • Loading branch information
markj0hnst0n authored Jan 14, 2025
2 parents d423956 + f76b4e4 commit 7d3409e
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ django-log-formatter-ecs = "==0.0.5"
whitenoise = "~=5.3.0"
django-audit-log-middleware = "~=0.0.4"
django-extensions = "~=3.2.3"
ipython = "~=7.34.0"
ipython = "~=8.10.0"
celery = "~=5.3.0"
redis = "~=4.4.4"
django-test-migrations = "~=1.2.0"
django-silk = "~=5.0.3"
django = "~=4.2.15"
django = "~=4.2.17"
django-queryable-properties = "~=1.9.1"
database-sanitizer = ">=1.1.0"
django-reversion = ">=5.0.12"
Expand Down
61 changes: 46 additions & 15 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion api/organisations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,11 @@ def validate_registration_number(self, value):

# Check for uniqueness only when creating a new Organisation
if not self.instance:
if Organisation.objects.filter(registration_number=value).exists():
if (
Organisation.objects.filter(registration_number=value)
.exclude(status__in=[OrganisationStatus.REJECTED, OrganisationStatus.DRAFT])
.exists()
):
raise serializers.ValidationError("This registration number is already in use.")

return value
Expand Down
47 changes: 46 additions & 1 deletion api/organisations/tests/test_organisations.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_create_commercial_organisation_as_internal_success(
"region": "Hertfordshire",
"postcode": "AL1 4GT",
"city": "St Albans",
}
},
],
[{"address": "123", "country": "PL"}],
]
Expand Down Expand Up @@ -246,6 +246,51 @@ def test_create_commercial_organisation_as_exporter_success(
{"organisation_name": data["name"], "applicant_email": data["user"]["email"]}
)

def test_create_commercial_organisation_as_exporter_success_with_previously_rejected_or_draft_crn(self):
data = {
"name": "Lemonworld Co",
"type": OrganisationType.COMMERCIAL,
"eori_number": "GB123456789000",
"sic_number": "01110",
"vat_number": "GB123456789",
"registration_number": "98765432",
"phone_number": "+441234567895",
"website": "",
"site": {
"name": "Headquarters",
"address": {
"address_line_1": "42 Industrial Estate",
"address_line_2": "Queens Road",
"region": "Hertfordshire",
"postcode": "AL1 4GT",
"city": "St Albans",
},
},
"user": {"email": "[email protected]"},
}
response = self.client.post(
self.url, data, **{EXPORTER_USER_TOKEN_HEADER: user_to_token(self.exporter_user.baseuser_ptr)}
)

self.assertEqual(response.status_code, status.HTTP_201_CREATED)
organisation = Organisation.objects.get(id=response.json()["id"])
organisation.status = OrganisationStatus.REJECTED
organisation.save()
response = self.client.post(
self.url, data, **{EXPORTER_USER_TOKEN_HEADER: user_to_token(self.exporter_user.baseuser_ptr)}
)

self.assertEqual(response.status_code, status.HTTP_201_CREATED)

organisation = Organisation.objects.get(id=response.json()["id"])
organisation.status = OrganisationStatus.DRAFT
organisation.save()
response = self.client.post(
self.url, data, **{EXPORTER_USER_TOKEN_HEADER: user_to_token(self.exporter_user.baseuser_ptr)}
)

self.assertEqual(response.status_code, status.HTTP_201_CREATED)

def test_create_organisation_phone_number_mandatory(self):
data = {
"name": "Lemonworld Co",
Expand Down

0 comments on commit 7d3409e

Please sign in to comment.