Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def handle(self, *args, **options):
# Mark invalid titles
titlestart = time.time()
logging.info('Marking blank titles...')
count = ContentNode.objects.exclude(complete=False).filter(title='').order_by().update(complete=False)
count = ContentNode.objects.exclude(complete=False).filter(title='', parent__isnull=False).order_by().update(complete=False)
logging.info('Marked {} invalid titles (finished in {})'.format(count, time.time() - titlestart))

# Mark invalid licenses
Expand Down
8 changes: 7 additions & 1 deletion contentcuration/contentcuration/utils/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from django.db.models import Count
from django.db.models import Q
from django.db.models import Sum
from django.db.utils import IntegrityError
from django.template.loader import render_to_string
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -125,7 +126,7 @@ def assign_license_to_contentcuration_nodes(channel, license):
channel.main_tree.get_family().update(license_id=license.pk)


def map_content_nodes(
def map_content_nodes( # noqa: C901
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's how to do it with a multi-line arguments list

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a couple of tries...

root_node,
default_language,
channel_id,
Expand All @@ -140,6 +141,9 @@ def map_content_nodes(
# make sure we process nodes higher up in the tree first, or else when we
# make mappings the parent nodes might not be there

if not root_node.complete:
raise ValueError("Attempted to publish a channel with an incomplete root node")

node_queue = collections.deque()
node_queue.append(root_node)

Expand Down Expand Up @@ -566,6 +570,8 @@ def map_prerequisites(root_node):
target_node.has_prerequisite.add(n['prerequisite__node_id'])
except kolibrimodels.ContentNode.DoesNotExist as e:
logging.error('Unable to find prerequisite {}'.format(str(e)))
except IntegrityError as e:
logging.error('Unable to find source node for prerequisite relationship {}'.format(str(e)))


def map_channel_to_kolibri_channel(channel):
Expand Down