Skip to content

Commit

Permalink
add mixin to allow base importers to handle multiple area types
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed Mar 12, 2024
1 parent 04581b9 commit 9c12f9c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion hub/management/commands/base_importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
)


class MultipleAreaTypesMixin:
def handle(self, *args, **options):
for area_type in self.area_types:
self.area_type = area_type
super(MultipleAreaTypesMixin, self).handle(*args, **options)


class BaseAreaImportCommand(BaseCommand):
area_type = "WMC"

Expand All @@ -42,7 +49,9 @@ def get_label(self, config):

def delete_data(self):
for data_type in self.data_types.values():
AreaData.objects.filter(data_type=data_type).delete()
AreaData.objects.filter(
data_type=data_type, area__area_type__code=self.area_type
).delete()

@cache
def get_area_type(self):
Expand Down

0 comments on commit 9c12f9c

Please sign in to comment.