def _process_row(self, row, simulate=False, **options):
        """
        Process one single row.
        """
        pk = parse_uuid(row['datahub_company_id'])
        company = Company.objects.get(pk=pk)
        has_profile = parse_bool(row['has_find_a_supplier_profile'])
        is_published = parse_bool(row['is_published_find_a_supplier'])

        profile_status = None
        if has_profile and is_published:
            profile_status = Company.GreatProfileStatus.PUBLISHED
        elif has_profile:
            profile_status = Company.GreatProfileStatus.UNPUBLISHED

        if company.great_profile_status == profile_status:
            return

        company.great_profile_status = profile_status

        if simulate:
            return

        with reversion.create_revision():
            company.save(update_fields=('great_profile_status', ))
            reversion.set_comment('GREAT profile status updated.')
示例#2
0
    def _process_row(self, row, simulate=False, ignore_old_regions=False, **options):
        """Process one single row."""
        pk = parse_uuid(row['id'])
        investment_project = InvestmentProject.objects.get(pk=pk)
        allow_blank_possible_uk_regions = parse_bool(row['allow_blank_possible_uk_regions'])
        uk_region_locations = parse_uuid_list(row['uk_region_locations'])

        current_regions = investment_project.uk_region_locations.all()
        current_region_ids = set(region.pk for region in current_regions)
        if (investment_project.allow_blank_possible_uk_regions == allow_blank_possible_uk_regions
                and current_region_ids == set(uk_region_locations)):
            return

        if not ignore_old_regions:
            old_uk_region_locations = parse_uuid_list(row['old_uk_region_locations'])

            if current_region_ids != set(old_uk_region_locations):
                return

        investment_project.allow_blank_possible_uk_regions = allow_blank_possible_uk_regions

        if simulate:
            return

        with reversion.create_revision():
            investment_project.save(
                update_fields=('allow_blank_possible_uk_regions',),
            )
            investment_project.uk_region_locations.set(uk_region_locations)
            reversion.set_comment('Possible UK regions data migration correction.')
    def _process_row(self, row, simulate=False, **options):
        """Process one single row."""
        contact = Contact.objects.get(pk=parse_uuid(row['id']))
        new_accepts_dit_email_marketing = parse_bool(
            row['accepts_dit_email_marketing'])

        if contact.accepts_dit_email_marketing == new_accepts_dit_email_marketing:
            return

        contact.accepts_dit_email_marketing = new_accepts_dit_email_marketing

        if not simulate:
            with reversion.create_revision():
                contact.save(update_fields=('accepts_dit_email_marketing', ))
                reversion.set_comment(
                    'Accepts DIT email marketing correction.')
    def _process_row(self, row, simulate=False, **options):
        """Process one single row."""
        pk = parse_uuid(row['id'])
        investment_project = InvestmentProject.objects.get(pk=pk)
        allow_blank_estimated_land_date = parse_bool(
            row['allow_blank_estimated_land_date'])
        estimated_land_date = parse_date(row['estimated_land_date'])

        if (investment_project.allow_blank_estimated_land_date
                == allow_blank_estimated_land_date and
                investment_project.estimated_land_date == estimated_land_date):
            return

        investment_project.allow_blank_estimated_land_date = allow_blank_estimated_land_date
        investment_project.estimated_land_date = estimated_land_date

        if simulate:
            return

        with reversion.create_revision():
            investment_project.save(
                update_fields=('estimated_land_date',
                               'allow_blank_estimated_land_date'), )
            reversion.set_comment('Estimated land date migration correction.')