diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-09-16 14:24:56 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-09-16 17:32:03 +0200 |
commit | e295d2e5e6f62a722c42d08f6156d5a785264420 (patch) | |
tree | d5ec8afdf6df5eeeb8b0ac0318f5fae93557a1a2 | |
parent | f0634c7b720cc8813ec738efe84e10cb2b309387 (diff) | |
download | Ishtar-e295d2e5e6f62a722c42d08f6156d5a785264420.tar.bz2 Ishtar-e295d2e5e6f62a722c42d08f6156d5a785264420.zip |
🐛 base find: on associated find label change, if only one base find change base find label
-rw-r--r-- | archaeological_finds/models_finds.py | 6 | ||||
-rw-r--r-- | archaeological_finds/tests.py | 6 |
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): |