Skip to content

Commit 652edde

Browse files
committed
🐛(import) fix EPCI SIRETs not being imported anymore
1 parent b4dcb06 commit 652edde

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/backend/core/admin.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,16 @@ def _process_siren_code(self, code, operator, role, expand_epci):
656656
created += 1
657657
elif was_existing:
658658
already_exists += 1
659+
elif not expand_epci and epci_organizations:
660+
# If expansion is disabled, create relationships for EPCIs themselves
661+
for epci in epci_organizations:
662+
was_created, was_existing = self._create_relationship(
663+
operator, epci, role
664+
)
665+
if was_created:
666+
created += 1
667+
elif was_existing:
668+
already_exists += 1
659669

660670
# Process non-EPCI organizations
661671
for organization in other_organizations:

src/backend/core/api/serializers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ def to_representation(self, instance):
477477
"""Convert the representation to the desired format."""
478478
data = super().to_representation(instance)
479479
if "organization" not in self.context:
480-
raise ValueError("OrganizationServiceSerializer requires 'organization' in context")
480+
raise ValueError(
481+
"OrganizationServiceSerializer requires 'organization' in context"
482+
)
481483
data["can_activate"] = instance.can_activate(self.context["organization"])
482484
return data

src/backend/core/api/viewsets/service.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ def get_serializer_context(self):
103103
id=self.kwargs["organization_id"]
104104
)
105105
except models.Organization.DoesNotExist as err:
106-
raise NotFound(
107-
"Organization not found."
108-
) from err
106+
raise NotFound("Organization not found.") from err
109107
context["organization"] = organization
110108
return context
111109

0 commit comments

Comments
 (0)