diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-14 20:13:24 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-14 20:13:24 +0200 |
commit | d79e336aec531f9c1b776dd2e16b9ec71119d89a (patch) | |
tree | f719190a8521bc349dbb22dd4f436f5c345ac507 | |
parent | 673e5dd34784e8a628ef01bea7799c45d8090bac (diff) | |
download | Ishtar-d79e336aec531f9c1b776dd2e16b9ec71119d89a.tar.bz2 Ishtar-d79e336aec531f9c1b776dd2e16b9ec71119d89a.zip |
Duplicate action : deassociate documents
-rw-r--r-- | archaeological_finds/models_finds.py | 2 | ||||
-rw-r--r-- | archaeological_finds/tests.py | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 8d4c65f1a..157841ab7 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1999,6 +1999,8 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem, if bf: new.base_finds.add(bf.duplicate( user=user, data={"label": new.label, "external_id": None})) + # remove documents for this kind of duplicate (data entry) + new.documents.clear() return new @classmethod diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index 178a5f035..e39ebda32 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -1211,6 +1211,9 @@ class FindQATest(FindInit, TestCase): default_desc = "Description for duplicate" find.description = default_desc find.save() + d = Document.objects.create() + d.finds.add(find) + c = Client() url = reverse('find-qa-duplicate', args=[find.pk]) response = c.get(url) @@ -1241,6 +1244,7 @@ class FindQATest(FindInit, TestCase): new_bf = models.BaseFind.objects.order_by('-pk').all()[0] base_bf = find.get_first_base_find() self.assertEqual(new_bf.context_record, base_bf.context_record) + self.assertNotIn(d, list(new.documents.all())) def test_bulk_update(self): c = Client() |