mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Fix request.POST checks so that we don't need a dummy value in tests
This commit is contained in:
parent
bf21a0cbe5
commit
41b6a7a9c8
@ -244,9 +244,7 @@ class TestSiteDeleteView(TestCase, WagtailTestUtils):
|
||||
self.assertEqual(self.get(site_id=100000).status_code, 404)
|
||||
|
||||
def test_posting_deletes_site(self):
|
||||
response = self.post({
|
||||
'trivial_key': 'trivial_value'
|
||||
})
|
||||
response = self.post()
|
||||
|
||||
# Should redirect back to index
|
||||
self.assertRedirects(response, reverse('wagtailsites:index'))
|
||||
@ -325,9 +323,7 @@ class TestLimitedPermissions(TestCase, WagtailTestUtils):
|
||||
|
||||
def test_delete(self):
|
||||
delete_url = reverse('wagtailsites:delete', args=(self.localhost.id,))
|
||||
response = self.client.post(delete_url, {
|
||||
'trivial_key': 'trivial_value'
|
||||
})
|
||||
response = self.client.post(delete_url)
|
||||
|
||||
# Should redirect back to index
|
||||
self.assertRedirects(response, reverse('wagtailsites:index'))
|
||||
|
@ -25,7 +25,7 @@ def index(request):
|
||||
|
||||
@permission_required('wagtailcore.add_site')
|
||||
def create(request):
|
||||
if request.POST:
|
||||
if request.method == 'POST':
|
||||
form = SiteForm(request.POST)
|
||||
if form.is_valid():
|
||||
site = form.save()
|
||||
@ -47,7 +47,7 @@ def create(request):
|
||||
def edit(request, site_id):
|
||||
site = get_object_or_404(Site, id=site_id)
|
||||
|
||||
if request.POST:
|
||||
if request.method == 'POST':
|
||||
form = SiteForm(request.POST, instance=site)
|
||||
if form.is_valid():
|
||||
site = form.save()
|
||||
@ -70,7 +70,7 @@ def edit(request, site_id):
|
||||
def delete(request, site_id):
|
||||
site = get_object_or_404(Site, id=site_id)
|
||||
|
||||
if request.POST:
|
||||
if request.method == 'POST':
|
||||
site.delete()
|
||||
messages.success(request, _("Site '{0}' deleted.").format(site.hostname))
|
||||
return redirect('wagtailsites:index')
|
||||
|
Loading…
Reference in New Issue
Block a user