Skip to content

Commit

Permalink
Fix import scripts that failed when run with multiple AreaTypes
Browse files Browse the repository at this point in the history
These import scripts all used QuerySet.get() insted of QuerySet.filter()
which was causing an exception when both WMC and WMC23 AreaTypes were
present in the database.
  • Loading branch information
zarino committed Sep 24, 2024
1 parent 1de02a9 commit 57195e0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hub/management/commands/import_cen_nzsg_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create_data_types(self):
},
)

for at in AreaType.objects.get(code__in=["WMC", "WMC23"]):
for at in AreaType.objects.filter(code__in=["WMC", "WMC23"]):
nzsg_ds.areas_available.add(at)
cen_ds.areas_available.add(at)

Expand Down
4 changes: 2 additions & 2 deletions hub/management/commands/import_mp_engagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def create_data_types(self):
},
)

for at in AreaType.objects.get(code__in=["WMC", "WMC23"]):
for at in AreaType.objects.filter(code__in=["WMC", "WMC23"]):
ds.areas_available.add(at)

data_type, created = DataType.objects.update_or_create(
Expand All @@ -79,7 +79,7 @@ def create_data_types(self):
},
)

for at in AreaType.objects.get(code__in=["WMC", "WMC23"]):
for at in AreaType.objects.filter(code__in=["WMC", "WMC23"]):
ds.areas_available.add(at)

data_type, created = DataType.objects.update_or_create(
Expand Down
2 changes: 1 addition & 1 deletion hub/management/commands/import_mps_appg_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def create_data_type(self):
},
)

for at in AreaType.objects.get(code__in=["WMC", "WMC23"]):
for at in AreaType.objects.filter(code__in=["WMC", "WMC23"]):
appg_membership_ds.areas_available.add(at)

appg_membership, created = DataType.objects.update_or_create(
Expand Down
4 changes: 2 additions & 2 deletions hub/management/commands/import_mps_relevant_votes.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def create_data_types(self, votes, edms):
},
)

for at in AreaType.objects.get(code__in=["WMC", "WMC23"]):
for at in AreaType.objects.filter(code__in=["WMC", "WMC23"]):
ds.areas_available.add(at)

data_type, created = DataType.objects.update_or_create(
Expand Down Expand Up @@ -226,7 +226,7 @@ def create_data_types(self, votes, edms):
},
)

for at in AreaType.objects.get(code__in=["WMC", "WMC23"]):
for at in AreaType.objects.filter(code__in=["WMC", "WMC23"]):
ds.areas_available.add(at)

data_type, created = DataType.objects.update_or_create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def create_data_types(self):
},
)

for at in AreaType.objects.get(code__in=["WMC", "WMC23"]):
for at in AreaType.objects.filter(code__in=["WMC", "WMC23"]):
select_committee_membership_ds.areas_available.add(at)

select_committee_membership, created = DataType.objects.update_or_create(
Expand Down

0 comments on commit 57195e0

Please sign in to comment.