summaryrefslogtreecommitdiff
path: root/archaeological_operations
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-03-18 19:48:55 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-06-17 13:21:27 +0200
commite2ec8a3bf016f1cc1e86a9ddd8cfc6e4eadbc35f (patch)
tree45e9ef5617a75ecdbe9f3dab0e6d8be095b69e79 /archaeological_operations
parente50b4030deb722c3c7d2ba79a7b7d0545ccd24f8 (diff)
downloadIshtar-e2ec8a3bf016f1cc1e86a9ddd8cfc6e4eadbc35f.tar.bz2
Ishtar-e2ec8a3bf016f1cc1e86a9ddd8cfc6e4eadbc35f.zip
Fix stats cache for integer values
Diffstat (limited to 'archaeological_operations')
-rw-r--r--archaeological_operations/models.py11
-rw-r--r--archaeological_operations/tests.py6
2 files changed, 6 insertions, 11 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index d900913e1..fbc36dcef 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -302,10 +302,7 @@ class ArchaeologicalSite(DocumentItem, BaseHistorizedItem, QRCodeItem,
)
def __str__(self):
- if self.cached_label:
- return self.cached_label
- self.save()
- return self.cached_label
+ return self.cached_label or ''
@property
def short_class_name(self):
@@ -984,11 +981,7 @@ class Operation(ClosedItem, DocumentItem, BaseHistorizedItem, QRCodeItem,
return cls._return_get_owns(owns, values, get_short_menu_class)
def __str__(self):
- if self.cached_label or getattr(self, "_label_checked", False):
- return self.cached_label
- self._label_checked = True
- self.save()
- return self.cached_label
+ return self.cached_label or ""
def get_values(self, prefix='', no_values=False):
values = super(Operation, self).get_values(prefix=prefix,
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 7867116fb..b773977a8 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -514,7 +514,7 @@ class ImportOperationTest(ImportTest, TestCase):
sorted([p.parcel_number for p in last_parcels]))
self.assertEqual(sections,
sorted([p.section for p in last_parcels]))
- ope1 = models.Operation.objects.filter(code_patriarche='4200').all()[0]
+ ope1 = models.Operation.objects.get(code_patriarche='4200')
towns_ope = ope1.towns.all()
imported = [imp for acc, imp in impt.get_all_imported()]
for p in last_parcels:
@@ -527,7 +527,7 @@ class ImportOperationTest(ImportTest, TestCase):
operation_id=ope1.pk).external_id,
'4200-59350-YY55')
# cached_label update
- ope2 = models.Operation.objects.filter(code_patriarche='4201').all()[0]
+ ope2 = models.Operation.objects.get(code_patriarche='4201')
self.assertIn('LILLE', ope2.cached_label.upper())
# delete associated parcel with the import deletion
parcel_count = models.Parcel.objects.count()
@@ -1434,6 +1434,7 @@ class OperationTest(TestCase, OperationInitTest):
"color": u"Red"},
"frog_number": 32303}
operation.save()
+ operation = models.Operation.objects.get(pk=operation.pk)
for key in ('marmott',):
self.assertIn(key, operation.search_vector)
for key in ('32303', 'red', 'Red'):
@@ -1793,6 +1794,7 @@ class OperationSearchTest(TestCase, OperationInitTest):
self._test_search(c, search_year_q, '2042";"2020', 2, "Many integer")
search_town_q = str(pgettext("key for text search", u"town"))
+ town = Town.objects.get(pk=town.pk)
self._test_search(c, search_town_q, town.cached_label, 1,
"String search with parenthesis and minus")