summaryrefslogtreecommitdiff
path: root/archaeological_finds/models_finds.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds/models_finds.py')
-rw-r--r--archaeological_finds/models_finds.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index 1fb4f6132..e856cb8ca 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -1348,7 +1348,7 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,
q = q.filter(**fltr)
return q.filter(downstream_treatment__isnull=True).count()
- def duplicate(self, user):
+ def duplicate(self, user, copy_datings=True):
model = self.__class__
new = model.objects.get(pk=self.pk)
@@ -1366,9 +1366,11 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,
m2m = [field.name for field in model._meta.many_to_many
if field.name not in PRIVATE_FIELDS]
for field in m2m:
- if field == 'images':
- for doc in Document.objects.filter(finds__pk=self.pk).all():
- doc.finds.add(new.pk)
+ if field == 'datings' and copy_datings:
+ for dating in self.datings.all():
+ dating.pk = None
+ dating.save()
+ new.datings.add(dating)
else:
for val in getattr(self, field).all():
getattr(new, field).add(val)