from data_collection.management.commands import BaseXpressDemocracyClubCsvImporter


class Command(BaseXpressDemocracyClubCsvImporter):
    council_id = "E07000112"
    addresses_name = "local.2019-05-02/Version 1/Democracy_Club__02May2019folkstone.tsv"
    stations_name = "local.2019-05-02/Version 1/Democracy_Club__02May2019folkstone.tsv"
    elections = ["local.2019-05-02"]
    csv_delimiter = "\t"

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

        if uprn in [
            "50104978",  # TN299AU -> TN299UA : Headmasters House, Rhee Wall, Brenzett, Romney Marsh, Kent
            "50042070",  # CT202NQ -> CT202QN : Flat D, 104 Cheriton Road, Folkestone, Kent
        ]:
            rec["accept_suggestion"] = True

        if uprn in [
            "50124993",  # CT195UW -> CT202PX : 1 Melanie Close, Folkestone, Kent
            "50124434",  # CT188LW -> CT188EW : Annexe Holly Lodge, Reece Lane, Acrise, Folkestone, Kent
        ]:
            rec["accept_suggestion"] = False

        return rec

@@ -1,8 +1,50 @@
+from django.contrib.gis.geos import Point%0A
 from dat
@@ -1155,8 +1155,1426 @@
 urn rec%0A
+%0A    def station_record_to_dict(self, record):%0A%0A        uprns = %7B%0A            %225223%22: %2250032257%22,  # Wards Hotel%0A            %225279%22: %2250046311%22,  # St Marys Primary School%0A            %225283%22: %2250102495%22,  # Hawkinge Community Centre%0A            %225342%22: %2250103399%22,  # Newington Village Hall%0A            %225260%22: %2250021990%22,  # Elham Village Hall%0A            %225264%22: %2250011466%22,  # Bodsham Primary School%0A            %225245%22: %2250011480%22,  # The Neptune%0A            %225364%22: %2250103652%22,  # The Star Inn%0A            %225317%22: %2250103844%22,  # Dungeness Lifeboat Station%0A            %225387%22: %2250001094%22,  # Rose & Crown%0A        %7D%0A%0A        gridrefs = %7B%0A            %225384%22: Point(1.0357008, 51.1383074, srid=4326),  # Peace Room%0A            %225323%22: Point(1.0842234, 51.1261431, srid=4326),  # Lyminge Village Hall%0A            %225214%22: Point(0.9963577, 51.048795, srid=4326),  # Burmarsh Church Hall%0A            %225198%22: Point(0.8502587, 51.0086578, srid=4326),  # Brenzett Village Hall%0A        %7D%0A%0A        if record.polling_place_id == %225244%22:%0A            record = record._replace(polling_place_postcode=%22TN29 0NX%22)%0A%0A        if record.polling_place_id in uprns:%0A            record = record._replace(polling_place_uprn=uprns%5Brecord.polling_place_id%5D)%0A        rec = super().station_record_to_dict(record)%0A        if record.polling_place_id in gridrefs:%0A            rec%5B%22location%22%5D = gridrefs%5Brecord.polling_place_id%5D%0A%0A        return rec%0A

Update Folkestone and Hythe (closes #1651)