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

Fixed #21734 -- Handled ProtectedError on POST to admin's delete_selected action #6348

Closed
wants to merge 1 commit into from

Conversation

akki
Copy link
Contributor

@akki akki commented Mar 28, 2016

https://code.djangoproject.com/ticket/21734

Approach is similar to that used to solve #26235 in 49ac10b.

@akki akki changed the title Fixed #26235 -- Handled ProtectedError on POST to admin's delete_selected action Fixed #21734 -- Handled ProtectedError on POST to admin's delete_selected action Mar 28, 2016
@akki akki force-pushed the ticket_21734 branch 2 times, most recently from 4090b61 to 8361776 Compare March 28, 2016 06:29
response = self.client.post(reverse('admin:admin_views_question_delete', args=(q.pk,)), {'post': 'yes'})
self.assertEqual(Question.objects.count(), 1)
self.assertContains(response, "would require deleting the following protected related objects")

# If the protected object is tried to be deleted using the delete_selected action.
Copy link
Member

Choose a reason for hiding this comment

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

Please put the test in AdminActionsTest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. Done.

q = Question.objects.create(question='Why?')
Answer.objects.create(question=q, answer='Because.')

response = self.client.post(reverse('admin:admin_views_question_changelist'), {
Copy link
Member

Choose a reason for hiding this comment

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

I think you could add this to test_model_admin_default_delete_action_protected so you don't have to repeat the setup steps.

@akki
Copy link
Contributor Author

akki commented Mar 29, 2016

Done.

@timgraham
Copy link
Member

merged in a7c813b, thanks!

@timgraham timgraham closed this Mar 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants