from django.utils.text import slugify

from data_importers.github_importer import BaseGitHubImporter


class Command(BaseGitHubImporter):

    srid = 4326
    districts_srid = 4326
    council_id = "DND"
    elections = ["2022-05-05"]
    scraper_name = "wdiv-scrapers/DC-PollingStations-Dundee"
    geom_type = "geojson"

    def district_record_to_dict(self, record):
        poly = self.extract_geometry(record, self.geom_type, self.get_srid("districts"))

        return {
            "internal_council_id": record["POLLING_DISTRICT"],
            "name": record["POLLING_DISTRICT"],
            "area": poly,
        }

    def station_record_to_dict(self, record):
        location = self.extract_geometry(
            record, self.geom_type, self.get_srid("stations")
        )
        return {
            "internal_council_id": f'{slugify(record["WARD"])}-{record["POLLINGSTATIONID"]}',
            "address": record["PS_ADDRESS"],
            "postcode": "",
            "location": location,
            "polling_district_id": record["POLLINGDISTRICTREFERENCE"],
        }

@@ -32,16 +32,70 @@
 lugify%0A%0A
+from data_importers.geo_utils import fix_bad_polygons%0A
 from dat
@@ -193,28 +193,29 @@
 %0A    srid = 
-4326
+27700
 %0A    distric
@@ -228,12 +228,13 @@
 d = 
-4326
+27700
 %0A   
@@ -1121,20 +1121,75 @@
 ERENCE%22%5D,%0A        %7D%0A
+%0A    def post_import(self):%0A        fix_bad_polygons()%0A

Fix Dundee projection issue