from data_collection.management.commands import BaseShpStationsShpDistrictsImporter

class Command(BaseShpStationsShpDistrictsImporter):
    srid = 27700
    council_id = 'W06000009'
    districts_name = 'PollingDistrictWithStation Pembrokeshire for 2017/PollingDistrictWithStation'
    stations_name = 'PollingDistrictWithStation Pembrokeshire for 2017/PollingDistrictWithStation.shp'
    elections = [
        'local.pembrokeshire.2017-05-04',
        #'parl.2017-06-08'
    ]

    def district_record_to_dict(self, record):
        return {
            'internal_council_id': str(record[1]).strip(),
            'name': str(record[2]).strip()
        }

    def station_record_to_dict(self, record):
        station = {
            'internal_council_id': str(record[1]).strip(),
            'postcode': '',
            'address': str(record[4]).strip(),
            'polling_district_id': str(record[1]).strip(),
        }

        """
        This file doesn't actually have points for stations
        and we want to ensure that we don't try to insert
        the polygon data into the location field
        """
        station ['location'] = None

        return station

from data_collection.morph_importer import BaseMorphApiImporter

class Command(BaseMorphApiImporter):

    srid = 4326
    districts_srid  = 4326
    council_id = 'W06000009'
    elections = ['parl.2017-06-08']
    scraper_name = 'wdiv-scrapers/DC-PollingStations-Pembrokeshire'
    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['DistrictID'],
            'name': record['DistrictName'],
            'area': poly,
            'polling_station_id': record['StationID'],
        }

    def station_record_to_dict(self, record):
        location = self.extract_geometry(record, self.geom_type, self.get_srid('stations'))
        return {
            'internal_council_id': record['StationID'],
            'postcode': '',
            'address': record['StationName'],
            'location': location,
        }

update Pembrokeshire import script