summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-03-25 19:10:36 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-06-17 13:21:27 +0200
commitc8831c9334f86b163b91bbb98c27d0cd3dc41882 (patch)
treeea15696b3e5e0d34d158131fb22c72fdf8ea3df5 /ishtar_common
parent951c06308d822f420083d00734b84206fa3bc1d7 (diff)
downloadIshtar-c8831c9334f86b163b91bbb98c27d0cd3dc41882.tar.bz2
Ishtar-c8831c9334f86b163b91bbb98c27d0cd3dc41882.zip
Fix new author creation when no cached label is calculated
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models.py5
-rw-r--r--ishtar_common/tests.py31
2 files changed, 32 insertions, 4 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 083da4cff..c246380d5 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -4367,10 +4367,7 @@ class Author(FullSearch):
)
def __str__(self):
- if self.cached_label:
- return self.cached_label
- self.save()
- return self.cached_label
+ return self.cached_label or ""
def natural_key(self):
return self.person.natural_key() + (self.author_type.txt_idx,)
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 7cc802ec9..01aba1f5b 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -1747,6 +1747,37 @@ class GeomaticTest(TestCase):
self.assertIsNotNone(obj.point)
+class NewItems(TestCase):
+ fixtures = COMMON_FIXTURES
+
+ def setUp(self):
+ self.username, self.password, self.user = create_superuser()
+
+ def test_new_author(self):
+ url = 'new-author'
+ person = models.Person.objects.create(
+ name="Hop", surname="Oups"
+ )
+
+ c = Client()
+ # TODO
+ # response = c.get(reverse(url))
+ # self.assertEqual(response.status_code, 404)
+ c.login(username=self.username, password=self.password)
+ response = c.get(reverse(url))
+ self.assertEqual(response.status_code, 200)
+
+ response = c.post(
+ reverse(url),
+ {"person": person.id,
+ "author_type": models.AuthorType.objects.all()[0].pk}
+ )
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(person.author.count(), 1)
+
+
+
+
class AccountWizardTest(WizardTest, TestCase):
fixtures = [settings.ROOT_PATH +
'../fixtures/initial_data-auth-fr.json',