diff options
| -rw-r--r-- | archaeological_finds/tests.py | 17 | ||||
| -rw-r--r-- | ishtar_common/utils.py | 2 | 
2 files changed, 9 insertions, 10 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index a4a1ad471..c62922499 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -459,9 +459,8 @@ class FindTest(FindInit, TestCase):                        response.content)          c = Client()          response = c.get(reverse('show-find', kwargs={'pk': obj.pk})) -        self.assertEqual(response.status_code, 200)          # empty content when not allowed -        self.assertEqual(response.content, "") +        self.assertRedirects(response, "/")          c.login(username=self.username, password=self.password)          response = self.client.get(reverse('show-find', kwargs={'pk': obj.pk})) @@ -508,8 +507,8 @@ class FindSearchTest(FindInit, TestCase):          # no result when no authentication          response = c.get(reverse('get-find'), search) -        self.assertEqual(response.status_code, 200) -        self.assertTrue(not json.loads(response.content)) +        self.assertRedirects(response, "/") +          c.login(username=self.username, password=self.password)          # one result for exact search @@ -569,8 +568,7 @@ class FindSearchTest(FindInit, TestCase):          # no result when no authentication          response = c.get(reverse('get-find'), search) -        self.assertEqual(response.status_code, 200) -        self.assertTrue(not json.loads(response.content)) +        self.assertRedirects(response, "/")          # one result for exact search          c.login(username=self.username, password=self.password) @@ -612,8 +610,8 @@ class FindSearchTest(FindInit, TestCase):          # no result when no authentication          response = c.get(reverse('get-find'), search) -        self.assertEqual(response.status_code, 200) -        self.assertTrue(not json.loads(response.content)) +        self.assertRedirects(response, "/") +          c.login(username=self.username, password=self.password)          # one result for exact search @@ -706,7 +704,8 @@ class FindPermissionTest(FindInit, TestCase):          # no result when no authentification          c = Client()          response = c.get(reverse('get-find')) -        self.assertTrue(not json.loads(response.content)) +        self.assertTrue(not response.content or +                        not json.loads(response.content))          # possession          c = Client() diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 6331766e1..c3a297174 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -796,7 +796,7 @@ def get_urls_for_model(model, views, own=False, autocomplete=False):      Generate get and show url for a model      """      urls = [ -        url(r'show-{}/(?P<pk>.+)/(?P<type>.+)?$'.format(model.SLUG), +        url(r'show-{}(?:/(?P<pk>.+))?/(?P<type>.+)?$'.format(model.SLUG),              check_rights(['view_' + model.SLUG, 'view_own_' + model.SLUG])(                  getattr(views, 'show_' + model.SLUG)),              name="show-" + model.SLUG),  | 
