from data_importers.management.commands import BaseXpressDemocracyClubCsvImporter


class Command(BaseXpressDemocracyClubCsvImporter):
    council_id = "SST"
    addresses_name = (
        "2021-03-23T12:44:29.340168/South Staffs Democracy_Club__06May2021.CSV"
    )
    stations_name = (
        "2021-03-23T12:44:29.340168/South Staffs Democracy_Club__06May2021.CSV"
    )
    elections = ["2021-05-06"]
    csv_delimiter = ","

    def address_record_to_dict(self, record):
        rec = super().address_record_to_dict(record)
        uprn = record.property_urn.strip().lstrip("0")

        if uprn in [
            "100031812029",  # 7 PARK CLOSE, CHESLYN HAY, WALSALL, WS6 7DA
            "10003692636",  # NARROWBOAT SERENITY GAILEY WHARF WATLING STREET, GAILEY ST19 5PR
            "100031799992",  # GREENSFORGE HOUSE, GREENSFORGE, KINGSWINFORD, DY6 0AH
            "200004524554",  # IVETSEY BANK FARM, IVETSEY BANK, WHEATON ASTON, STAFFORD
            "10094875300",  # POOL FARM BUNGALOW, GAILEY LEA LANE, GAILEY, STAFFORD ST19 5PT
        ]:
            return None

        if record.addressline6 in [
            "DY7 5HL",
            "ST19 5RH",
            "ST19 9AG",
            "WV9 5BW",
            "WV11 2DN",
        ]:
            return None

        return rec

    def station_record_to_dict(self, record):

        # Bede Hall, Wombourne Parish Offices, Giggetty Lane, Wombourne, WV5 9EZ => WV5 9ED
        if record.polling_place_id == "4059":
            record = record._replace(polling_place_postcode="WV5 9ED")

        # Bishopswood Village Hall, Ivetsey Bank Road, Bishopswood, Stafford, ST19 9AR => ST19 9AB
        if record.polling_place_id == "3833":
            record = record._replace(polling_place_postcode="ST19 9AB")

        # Village Hall, High Street, Wheaton Aston, South Staffordshire ST19 9PL => ST19 9NG
        if record.polling_place_id == "3868":
            record = record._replace(polling_place_postcode="ST19 9NG")

        # Village Hall, Hyde Lea
        if record.polling_place_id == "3849":
            record = record._replace(
                polling_place_easting="391056", polling_place_northing="319891"
            )

        # St Bartholomews Church Hall
        if record.polling_place_id == "4044":
            record = record._replace(
                polling_place_easting="389364", polling_place_northing="295314"
            )

        return super().station_record_to_dict(record)

@@ -167,34 +167,24 @@
 esses_name =
- (%0A       
  %222021-03-23
@@ -181,33 +181,33 @@
 2021-03-
-2
 3
+1
 T12:
-44:29.34016
+26:09.08033
 8/South 
@@ -226,35 +226,25 @@
 racy
-_
+ 
 Club
-__06May2021.CSV%22%0A    )
+ Report.csv%22
 %0A   
@@ -263,18 +263,8 @@
 me =
- (%0A       
  %2220
@@ -273,25 +273,25 @@
 -03-
-2
 3
+1
 T12:
-44:29.34016
+26:09.08033
 8/So
@@ -314,35 +314,25 @@
 racy
-_
+ 
 Club
-__06May2021.CSV%22%0A    )
+ Report.csv%22
 %0A   
@@ -434,61 +434,8 @@
 d):%0A
-        rec = super().address_record_to_dict(record)%0A
     
@@ -1032,15 +1032,16 @@
    %22
-DY7 5HL
+ST19 9AB
 %22,%0A 
@@ -1061,11 +1061,57 @@
 T19 
-5RH
+9AG%22,%0A            %22WV8 1QS%22,%0A            %22WV9 5BW
 %22,%0A 
@@ -1119,35 +1119,35 @@
           %22ST19 
-9AG
+5QH
 %22,%0A            %22
@@ -1139,38 +1139,38 @@
 ,%0A            %22W
-V9 5BW
+S6 7BL
 %22,%0A            %22
@@ -1180,16 +1180,174 @@
 1 2DN%22,%0A
+            %22DY7 5EF%22,%0A            %22WV5 9BN%22,%0A            %22DY6 0BA%22,%0A            %22WV5 7EY%22%0A            #         %22DY7 5HL%22,%0A            #         %22ST19 5RH%22,%0A
         
@@ -1389,19 +1389,54 @@
  return 
-rec
+super().address_record_to_dict(record)
 %0A%0A    de

Update South Staffordshire (closes #3437)