Skip to content
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

Added: Add (dynamic) playlist validation to rules files #995

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

drikusroor
Copy link
Contributor

@drikusroor drikusroor commented May 3, 2024

This pull request adds playlist validation to the rules files in order to ensure that the playlists used with each rule file meet the specific requirements. The validation is implemented by updating the rule base class with a validate function. Additionally, an API endpoint is added for validating the experiment playlist based on the rules. The experiment form in the admin interface is updated to use the validation endpoint and display warnings and errors for playlist incompatibility. The pull request also includes test cases for playlist validation.

It looks like this:

Screen.Recording.2024-05-03.at.15.06.27.mov

Resolves #978

@drikusroor drikusroor self-assigned this May 3, 2024
Copy link
Collaborator

@BeritJanssen BeritJanssen left a comment

Choose a reason for hiding this comment

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

Can we override the field's clean method to achieve this? Cf. Django documentation. This does seem like a situation where Django could handle the logic, but I'm not sure if it gets more involved because Playlist is a ManyToManyField.

@albertas-jn
Copy link
Contributor

Although I find it OK as it is, indeed, using built-in django form validation might be a simpler solution.

@drikusroor
Copy link
Contributor Author

Can we override the field's clean method to achieve this? Cf. Django documentation. This does seem like a situation where Django could handle the logic, but I'm not sure if it gets more involved because Playlist is a ManyToManyField.

Although I find it OK as it is, indeed, using built-in django form validation might be a simpler solution.

I explicitly did not use Django's built-in form validation because I wanted to add dynamic validation (which happens before you submit the form already). What you y'all think: Would it be better to rewrite it to use Django's built-in form validation and risking it not to be a dynamic validation, or should we keep it like this?

@drikusroor drikusroor force-pushed the feat/live-validate-experiment-rules-playlist branch from 49bfc8c to a8ffdd0 Compare May 17, 2024 09:35
@BeritJanssen
Copy link
Collaborator

My two cents would be that it's not too big a deal for the user if they clicked "save" and then get feedback about the playlist. It's a different story with things like uploading sections, where we'd have to repeat a rather involved process before fixing the problem, but here it's a checkmark that would need to be changed, so my preference would be Django built-in over custom Javascript, which is hard to unit test, and therefore hard to maintain.

@drikusroor drikusroor force-pushed the feat/live-validate-experiment-rules-playlist branch from a8ffdd0 to 6987ec8 Compare May 27, 2024 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Playlist validation to rules files
3 participants