summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_finds/models_finds.py6
-rw-r--r--archaeological_finds/tests.py6
2 files changed, 8 insertions, 4 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index 07c09bde2..09387e1a5 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -3701,11 +3701,15 @@ class Find(
if changed:
self._cached_label_checked = False
self.save()
+ bf_nb = self.base_finds.count()
for base_find in self.base_finds.filter(
context_record__operation__pk__isnull=False
).all():
+ # initialize / modify base find attributes
modified = False
- if self.label and not base_find.label:
+ if self.label and (not base_find.label or
+ (bf_nb == 1 and base_find.label != self.label)):
+ # change label of base find if label not provided or only one base find
base_find.label = self.label
modified = True
if not base_find.index:
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index 8e1c3f970..babaf4380 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -1032,15 +1032,15 @@ class ExportTest(FindInit, TestCase):
rows = list(csv.reader(StringIO(response.content.decode(ENCODING))))
# one header + two find
self.assertEqual(len(rows), 3)
- row_cr = rows[1]
- for row in rows[1:]:
+ for idx, row in enumerate(rows[1:]):
self.assertEqual(row[0], "1")
self.assertEqual(row[1], "12345")
self.assertEqual(row[2], "A1")
self.assertEqual(row[3], "Context record")
- self.assertEqual(row[4], "Base find")
self.assertEqual(rows[1][11], "1234")
self.assertEqual(rows[2][11], "567")
+ self.assertEqual(rows[1][4], "1234") # "Base find" in data source but overload by find label
+ self.assertEqual(rows[2][4], "567") # "Base find" in data source but overload by find label
class ImportFindLiveServerTest(LiveServerTestCase, BaseImportFindTest):