diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-11-19 20:18:38 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-11-28 11:40:17 +0100 | 
| commit | 66c8c7fa80e2e1494a37503e86ccf2bb3188b87c (patch) | |
| tree | 2013c75ddcb53a525f17d55626ede968d18f4ad6 /archaeological_finds/models_finds.py | |
| parent | 72593b0dabfba41e5da8e5b7e1f6c786b58ba151 (diff) | |
| download | Ishtar-66c8c7fa80e2e1494a37503e86ccf2bb3188b87c.tar.bz2 Ishtar-66c8c7fa80e2e1494a37503e86ccf2bb3188b87c.zip | |
Manage 1<->n treatments wizard
Diffstat (limited to 'archaeological_finds/models_finds.py')
| -rw-r--r-- | archaeological_finds/models_finds.py | 10 | 
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) | 
