Skip to content

Fix warning from BSModalDeleteView / DeleteMessageMixin with Django 4 #195

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions bootstrap_modal_forms/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ class DeleteMessageMixin(object):
Mixin which adds message to BSModalDeleteView and only calls the delete method if request
is not ajax request.
"""
def delete(self, request, *args, **kwargs):

def post(self, request, *args, **kwargs):
if not is_ajax(request.META):
messages.success(request, self.success_message)
return super(DeleteMessageMixin, self).delete(request, *args, **kwargs)
return super().post(request, *args, **kwargs)
else:
self.object = self.get_object()
return HttpResponseRedirect(self.get_success_url())


class LoginAjaxMixin(object):
"""
Mixin which authenticates user if request is not ajax request.
Expand All @@ -70,4 +71,4 @@ def form_valid(self, form):
if not is_ajax(self.request.META):
auth_login(self.request, form.get_user())
messages.success(self.request, self.success_message)
return HttpResponseRedirect(self.get_success_url())
return HttpResponseRedirect(self.get_success_url())
2 changes: 1 addition & 1 deletion tests/tests_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_signup_login(self):

# User sees error in form
error = self.wait_for(class_name='help-block')
self.assertEqual(error.text, 'The two password fields didnt match.')
self.assertEqual(error.text, 'The two password fields didn\'t match.')

# User fills in and submits sign up form correctly
form = modal.find_element_by_tag_name('form')
Expand Down