diff options
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/models.py | 11 | ||||
-rw-r--r-- | archaeological_operations/tests.py | 6 |
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") |