From 6313a988d76b997744043faec412370d43d0ec5f Mon Sep 17 00:00:00 2001 From: Michaela Date: Mon, 8 Feb 2021 19:23:19 +0100 Subject: [PATCH] Do not validate license for topics --- .../management/commands/mark_incomplete.py | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/contentcuration/contentcuration/management/commands/mark_incomplete.py b/contentcuration/contentcuration/management/commands/mark_incomplete.py index 589cc55453..8df69f3691 100644 --- a/contentcuration/contentcuration/management/commands/mark_incomplete.py +++ b/contentcuration/contentcuration/management/commands/mark_incomplete.py @@ -31,23 +31,33 @@ def handle(self, *args, **options): # Mark invalid licenses licensestart = time.time() logging.info('Marking blank licenses...') - count = ContentNode.objects.exclude(complete=False, kind_id=content_kinds.TOPIC).filter(license__isnull=True).order_by().update(complete=False) + count = ContentNode.objects.exclude(kind_id=content_kinds.TOPIC) \ + .exclude(complete=False) \ + .filter(license__isnull=True) \ + .order_by() \ + .update(complete=False) logging.info('Marked {} invalid licenses (finished in {})'.format(count, time.time() - licensestart)) licensestart = time.time() logging.info('Marking blank license descriptions...') custom_licenses = list(License.objects.filter(is_custom=True).values_list("pk", flat=True)) - count = ContentNode.objects.exclude(complete=False, kind_id=content_kinds.TOPIC)\ - .filter(license_id__in=custom_licenses).filter(Q(license_description__isnull=True) | Q(license_description=''))\ - .order_by().update(complete=False) + count = ContentNode.objects.exclude(kind_id=content_kinds.TOPIC) \ + .exclude(complete=False) \ + .filter(license_id__in=custom_licenses) \ + .filter(Q(license_description__isnull=True) | Q(license_description='')) \ + .order_by() \ + .update(complete=False) logging.info('Marked {} invalid license descriptions (finished in {})'.format(count, time.time() - licensestart)) licensestart = time.time() logging.info('Marking blank copyright holders...') copyright_licenses = list(License.objects.filter(copyright_holder_required=True).values_list("pk", flat=True)) - count = ContentNode.objects.exclude(complete=False, kind_id=content_kinds.TOPIC)\ - .filter(license_id__in=copyright_licenses).filter(Q(copyright_holder__isnull=True) | Q(copyright_holder=''))\ - .order_by().update(complete=False) + count = ContentNode.objects.exclude(kind_id=content_kinds.TOPIC) \ + .exclude(complete=False) \ + .filter(license_id__in=copyright_licenses) \ + .filter(Q(copyright_holder__isnull=True) | Q(copyright_holder=''))\ + .order_by() \ + .update(complete=False) logging.info('Marked {} invalid copyright holders (finished in {})'.format(count, time.time() - licensestart)) # Mark invalid file resources