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 false in save function to skip model validation #11642

Closed

Conversation

Jaivignesh-afk
Copy link
Contributor

@Jaivignesh-afk Jaivignesh-afk commented Feb 13, 2024

Fixes #9703

added clean = False to skip model validation during unlocking a page as mentioned by @prgood in #9703

Please check the following:

  • Do the tests still pass?1
  • Does the code comply with the style guide?
    • Run make lint from the Wagtail root.
  • For Python changes: Have you added tests to cover the new/fixed behaviour?
  • For front-end changes: Did you test on all of Wagtail’s supported environments?2
    • Please list the exact browser and operating system versions you tested:
    • Please list which assistive technologies 3 you tested:
  • For new features: Has the documentation been updated accordingly?

Please describe additional details for testing this change.

Footnotes

  1. Development Testing

  2. Browser and device support

  3. Accessibility Target

Copy link

squash-labs bot commented Feb 13, 2024

Manage this branch in Squash

Test this branch here: https://jaivignesh-afkfixadded-false-i-f51v3.squash.io

@gasman
Copy link
Collaborator

gasman commented Feb 13, 2024

Hi @Jaivignesh-afk - thanks for the PR.
It looks like this also contains your changes from #11636 - please make sure you start your PRs from a fresh version of the main branch. Also, please can you add a test for this?

@Jaivignesh-afk
Copy link
Contributor Author

I acknowledge my oversight, I will try to follow that next time. I will be adding the tests asap

@Jaivignesh-afk
Copy link
Contributor Author

Could you please clarify where I should write these tests, like in test_page_model.py or test_edit_handlers.py or some other file? Additionally, what aspects should I focus on when writing tests? For example, should I ensure that model validation is skipped?

@gasman
Copy link
Collaborator

gasman commented Feb 17, 2024

The best way to approach tests is to ask: "what does this change allow an end-user to do, that they couldn't do before?" In this case, they will be able to use the 'Unlock' view in the admin to unlock a page with validation errors. So, we want a test that does the following:

  • creates a locked page containing a validation error
  • calls the "unlock" view
  • verifies that it completes with no errors, and results in the page being unlocked

Tests for the lock/unlock views can be found in wagtail/admin/tests/pages/test_page_locking.py. The test you add will be mostly the same as test_unlock_post, just with some changes to how self.child_page is set up at the start, to introduce a validation error.

@Jaivignesh-afk
Copy link
Contributor Author

Ok, Thank you for the tips!!

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.

Locked page with a mandatory blank field cannot be unlocked
2 participants