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

1694: added stipulations to program electives causes 500 error in Django admin #1751

Conversation

collinpreston
Copy link
Contributor

@collinpreston collinpreston commented Jul 14, 2023

What are the relevant tickets?

#1694

Description (What does it do?)

Add validations to the Program Django Admin page to display error messages instead of throwing a 500 error if the requirements tree contains misconfigurations.

How can this be tested?

  1. Ensure you have a couple courses created in your MITx Online instance.
  2. Click "ADD PROGRAM" from http://mitxonline.odl.local:8013/admin/courses/program/
  3. Define the title and readable ID to be anything unique.
  4. Expand the "Required Courses" section.
  5. Change the Operation from "All of" to "Minimum # of".
  6. Verify that the Value field is displayed.
  7. Enter 1 in the Value field.
  8. Delete the Elective Courses section.
  9. Change the Title to "Elective Courses".
  10. Add a course to the Elective Courses section.
  11. Verify that the program can be saved.
  12. Select the program saved during step 11.
  13. Change the Value field to 2.
  14. Verify that the program cannot be saved because the value is larger than the number of courses in the Elective Courses section.
  15. Change the Value field to be empty.
  16. Verify that the program cannot be saved if the Value field is empty.
  17. Change the Value field to be 1.
  18. Change the Title field to be empty.
  19. Verify that the program cannot be saved if the Title field is empty.
  20. Set the Title field back to "Elective Courses".
  21. Add a nested operation to the Elective Courses section by selecting "Add requirement".
  22. Change the nested operation Type from "Course" to "Operator".
  23. Verify that the program cannot be saved if the Title of the nested operation is blank.
  24. Set the Title field of the nested operation to "Elective stipulation".
  25. Verify that the program can be saved if the Title of the nested operation is filled in.
  26. Add a course to the nested operation by clicking "Add course".
  27. Change the "Operation" field in the nested operation to "Minimum # of".
  28. Set the Value field of the nested operation to 2.
  29. Verify that the program cannot be saved if the nested operation's Value field's value is larger than the number of courses in the nested operation.
  30. Change the Value field of the nested operation to be blank.
  31. Verify that the program cannot be saved if the nested operation's Value field's value is empty.
  32. Set the Value field of the nested operation to 1.
  33. Set the Title field of the nested operation to be blank.
  34. Verify that the program cannot be saved if the Title of the nested operation is blank.
  35. Set the Title of the nested operation back to "Elective stipulation".
  36. Verify that the program can be saved.

Errors messages are displayed for:
- Minimum # of" operator must have Value equal to 1 or more.
- Minimum # of" operator must have Value equal to 1 or more.
- Minimum # of" operator must have Value equal to or less than the number of elective courses in the section.
- Section must have a Title.
This also adds operator_value and elective_flag to the default requirements section in order to allow the user to change the section to an elective section.
@collinpreston collinpreston marked this pull request as ready for review July 17, 2023 15:25
@collinpreston collinpreston changed the title 1694: added stipulations to program electives causes 500 error in django admin 1694: added stipulations to program electives causes 500 error in Django admin Jul 17, 2023
@annagav annagav self-requested a review July 18, 2023 13:23
@annagav annagav self-assigned this Jul 18, 2023
Copy link
Contributor

@annagav annagav left a comment

Choose a reason for hiding this comment

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

LGTM 👍

The only issue I ran into is that if the form error shows up then when you select operation "minimum of" it doesn't show the value value.

@collinpreston collinpreston merged commit 5698a0d into main Jul 19, 2023
3 checks passed
@collinpreston collinpreston deleted the 1694-added-stipulations-to-program-electives-causes-500-error-in-django-admin branch July 19, 2023 10:24
@collinpreston
Copy link
Contributor Author

Created a new issue for the problem that Anna mentioned in her comment, #1757

@odlbot odlbot mentioned this pull request Jul 20, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Added stipulations to program electives causes 500 error in Django Admin
2 participants