From 9d80c05f9040a90bf6e36b052d90827fec0c2618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Mon, 21 Oct 2013 22:43:09 +0200 Subject: [PATCH] Fix url_name_args bug. Fix delete view for motion categories. Add test for custom slide delete view. --- openslides/motion/views.py | 1 + tests/motion/test_views.py | 11 +++++++++++ tests/projector/test_views.py | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/openslides/motion/views.py b/openslides/motion/views.py index adf46644b..c5af07543 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -773,6 +773,7 @@ class CategoryDeleteView(DeleteView): permission_required = 'motion.can_manage_motion' model = Category question_url_name = 'motion_category_list' + url_name_args = [] success_url_name = 'motion_category_list' category_delete = CategoryDeleteView.as_view() diff --git a/tests/motion/test_views.py b/tests/motion/test_views.py index 526f3e70c..a7b9cbc09 100644 --- a/tests/motion/test_views.py +++ b/tests/motion/test_views.py @@ -491,3 +491,14 @@ class CategoryViewsTest(TestCase): response = self.admin_client.post(url, {'name': 'test_title_jaiShae1sheingahlee2'}) self.assertRedirects(response, '/motion/category/') self.assertEqual(Category.objects.get(pk=1).name, 'test_title_jaiShae1sheingahlee2') + + def test_delete(self): + # Setup + url = '/motion/category/1/del/' + Category.objects.create(name='test_title_nei1wooHes2aiquuraep') + # Test + response = self.admin_client.get(url) + self.assertRedirects(response, '/motion/category/') + response = self.admin_client.post(url, {'yes': 'true'}) + self.assertRedirects(response, '/motion/category/') + self.assertFalse(Category.objects.exists()) diff --git a/tests/projector/test_views.py b/tests/projector/test_views.py index 468081242..e769667b0 100644 --- a/tests/projector/test_views.py +++ b/tests/projector/test_views.py @@ -40,3 +40,14 @@ class CustomSlidesTest(TestCase): response = self.admin_client.post(url, {'title': 'test_title_ai8Ooboh5bahr6Ee7goo', 'weight': '0'}) self.assertRedirects(response, '/projector/dashboard/') self.assertEqual(ProjectorSlide.objects.get(pk=1).title, 'test_title_ai8Ooboh5bahr6Ee7goo') + + def test_delete(self): + # Setup + url = '/projector/1/del/' + ProjectorSlide.objects.create(title='test_title_oyie0em1chieM7YohX4H') + # Test + response = self.admin_client.get(url) + self.assertRedirects(response, '/projector/1/edit/') + response = self.admin_client.post(url, {'yes': 'true'}) + self.assertRedirects(response, '/projector/dashboard/') + self.assertFalse(ProjectorSlide.objects.exists())