Fix validation to allow upload of HTML5 files#5418
Fix validation to allow upload of HTML5 files#5418marcellamaki merged 2 commits intolearningequality:hotfixesfrom
Conversation
Make randomize no longer required. Prevent contentnodes from having their kind updated after creation. Ensure randomize is set at exercise creation. Add tests for the above behaviours.
marcellamaki
left a comment
There was a problem hiding this comment.
Code changes look good, and confirmation manual QA on publishing and testing content in Kolibri checks out.
I ran into some other weirdness around channel publishing as discussed in slack , but at this stage, I don't think it's related to these changes, at least not in a way I can figure out. So, I think this is okay to merge into hotfixes for Peter's review, and we can continue to investigate the other error I found separately
|
|
||
| class ExtraFieldsSerializer(JSONFieldDictSerializer): | ||
| randomize = BooleanField() | ||
| randomize = BooleanField(required=False) |
| ) | ||
|
|
||
| # Prevent kind from being changed after creation | ||
| if self.instance is not None and "kind" in data: |
There was a problem hiding this comment.
While I do prefer the strict sense of rejecting any request that includes kind for an update, it seems less risky to just have this check whether kind included in the request is indeed different. I wouldn't expect the inclusion of kind in the request, considering how frontend syncing functions, but this strictness could cascade into more required changes if there are surprises.
There was a problem hiding this comment.
Fair enough, I can loosen it!
…anged, not just when included in the payload.
There was a problem hiding this comment.
Latest commit updates to loosen the check, but also make it more specific -- so only when the kind is changed via comparing kind to the kind included in the payload. I'm going to go ahead and merge so Peter can QA tomorrow, but if @bjester has any additional feedback about the approach we can do that in follow up.
Summary
Add regression test for erroneous randomize validation on HTML5.
Make randomize no longer required.
Prevent contentnodes from having their kind updated after creation. Ensure randomize is set at exercise creation.
Add tests for the above behaviours.
References
Fixes #5417
Reviewer guidance
Upload an HTML5 zip. Ensure that it gets properly saved into the channel, and that the channel is then publishable.
I used Claude Code to write the tests here, and I don't think I had to modify them at all. Production code was also implemented by Claude Code, but I checked and reviewed every line closely, and it was in accordance with my specific implementation plan, I just verified that it did it as I intended.