-
Notifications
You must be signed in to change notification settings - Fork 228
Fix validation to allow upload of HTML5 files #5418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,6 +297,7 @@ class ExtraFieldsOptionsSerializer(JSONFieldDictSerializer): | |
required=False, | ||
) | ||
completion_criteria = CompletionCriteriaSerializer(required=False) | ||
entry = CharField(required=False, allow_null=True) | ||
|
||
|
||
class InheritedMetadataSerializer(JSONFieldDictSerializer): | ||
|
@@ -307,7 +308,7 @@ class InheritedMetadataSerializer(JSONFieldDictSerializer): | |
|
||
|
||
class ExtraFieldsSerializer(JSONFieldDictSerializer): | ||
randomize = BooleanField() | ||
randomize = BooleanField(required=False) | ||
options = ExtraFieldsOptionsSerializer(required=False) | ||
suggested_duration_type = ChoiceField( | ||
choices=[completion_criteria.TIME, completion_criteria.APPROX_TIME], | ||
|
@@ -428,11 +429,34 @@ def validate(self, data): | |
raise ValidationError( | ||
{"parent": "This field should only be changed by a move operation"} | ||
) | ||
|
||
# Prevent kind from being changed after creation | ||
if self.instance is not None and "kind" in data: | ||
|
||
raise ValidationError( | ||
{"kind": "Content kind cannot be changed after creation"} | ||
) | ||
|
||
tags = data.get("tags") | ||
if tags is not None: | ||
for tag in tags: | ||
if len(tag) > 30: | ||
raise ValidationError("tag is greater than 30 characters") | ||
|
||
# Conditional validation for randomize field on exercise creation | ||
if self.instance is None: # Only validate on creation | ||
kind = data.get("kind") | ||
if kind.kind == content_kinds.EXERCISE: | ||
extra_fields = data.get("extra_fields", {}) | ||
if "randomize" not in extra_fields: | ||
raise ValidationError( | ||
{ | ||
"extra_fields": { | ||
"randomize": [ | ||
"This field is required for exercise content." | ||
] | ||
} | ||
} | ||
) | ||
return data | ||
|
||
def _check_completion_criteria(self, kind, complete, validated_data): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍