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
2 changes: 1 addition & 1 deletion contentcuration/contentcuration/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,7 @@ def mark_complete(self): # noqa C901
except completion_criteria.ValidationError:
errors.append("Mastery criterion is defined but is invalid")
else:
criterion = self.extra_fields.get("options", {}).get("completion_criteria", {})
criterion = self.extra_fields and self.extra_fields.get("options", {}).get("completion_criteria", {})
if criterion:
try:
completion_criteria.validate(criterion, kind=self.kind_id)
Expand Down
18 changes: 18 additions & 0 deletions contentcuration/contentcuration/tests/test_contentnodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,3 +1171,21 @@ def test_create_exercise_bad_new_extra_fields(self):
AssessmentItem.objects.create(contentnode=new_obj, question="This is a question", answers="[{\"correct\": true, \"text\": \"answer\"}]")
new_obj.mark_complete()
self.assertFalse(new_obj.complete)

def test_create_video_null_extra_fields(self):
licenses = list(License.objects.filter(copyright_holder_required=False, is_custom=False).values_list("pk", flat=True))
channel = testdata.channel()
new_obj = ContentNode(
title="yes",
kind_id=content_kinds.VIDEO,
parent=channel.main_tree,
license_id=licenses[0],
copyright_holder="Some person",
extra_fields=None,
)
new_obj.save()
File.objects.create(contentnode=new_obj, preset_id=format_presets.VIDEO_HIGH_RES, checksum=uuid.uuid4().hex)
try:
new_obj.mark_complete()
except AttributeError:
self.fail("Null extra_fields not handled")