def _process_row(self, row, simulate=False, **options):
        """Process one single row."""
        pk = parse_uuid(row['id'])
        company = Company.objects.get(pk=pk)
        old_company_name = parse_limited_string(row['old_company_name'])
        new_company_name = parse_limited_string(row['new_company_name'])

        if company.name != old_company_name:
            return

        company.name = new_company_name

        if simulate:
            return

        with reversion.create_revision():
            company.save(update_fields=('name', ))
            reversion.set_comment('Company name correction.')
    def _process_row(self, row, simulate=False, **options):
        """Process one single row."""
        pk = parse_uuid(row['id'])
        sector = Sector.objects.get(pk=pk)
        old_sector_segment = parse_limited_string(row['old_sector_segment'])
        new_sector_segment = parse_limited_string(row['new_sector_segment'])

        if any([sector.segment != old_sector_segment, sector.segment == new_sector_segment]):
            logger.warning(f'Not updating sector {sector} as its segment has not changed')
            return

        sector.segment = new_sector_segment

        if simulate:
            return

        with reversion.create_revision():
            sector.save(update_fields=('segment',))
            reversion.set_comment('Sector segment correction.')
Esempio n. 3
0
    def _process_row(self, row, simulate=False, **options):
        """Process one single row."""
        pk = parse_uuid(row['id'])
        company = Company.objects.get(pk=pk)
        company_number = parse_limited_string(row['company_number'])

        if company.company_number == company_number:
            return

        company.company_number = company_number

        if simulate:
            return

        with reversion.create_revision():
            company.save(update_fields=('company_number',))
            reversion.set_comment('Company number updated.')
Esempio n. 4
0
    def _process_row(self, row, simulate=False, **options):
        """Process one single row."""
        pk = parse_uuid(row['id'])
        segment = parse_limited_string(row['segment'])
        sector_cluster_pk = parse_uuid(row['sector_cluster_id'])
        parent_pk = parse_uuid(row['parent_id'])

        sector = Sector(pk=pk, segment=segment)

        if sector_cluster_pk:
            sector.sector_cluster = SectorCluster.objects.get(
                pk=sector_cluster_pk)
        if parent_pk:
            sector.parent = Sector.objects.get(pk=parent_pk)

        if simulate:
            return

        with reversion.create_revision():
            sector.save(update_fields=('segment', ))
            reversion.set_comment('Sector creation.')
Esempio n. 5
0
    def _process_row(self, row, simulate=False, **options):
        """Process one single row."""
        score_dict = {
            value.lower(): key
            for key, value in Company.EXPORT_POTENTIAL_SCORES
        }

        pk = parse_uuid(row['datahub_company_id'])
        company = Company.objects.get(pk=pk)
        raw_potential = parse_limited_string(row['export_propensity'])
        export_potential = score_dict[raw_potential.lower()]

        if company.export_potential == export_potential:
            return

        company.export_potential = export_potential

        if simulate:
            return

        with reversion.create_revision():
            company.save(update_fields=('export_potential', ))
            reversion.set_comment('Export potential updated.')