]> git.parisson.com Git - teleforma.git/commitdiff
try better duplicate
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 19 Dec 2013 16:57:13 +0000 (17:57 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 19 Dec 2013 16:57:13 +0000 (17:57 +0100)
teleforma/management/commands/teleforma-copy-seminars.py
teleforma/models/core.py

index 3028ea76d3cace0d01e4e76c3c3be77b0db2d69a..888dfade6d248df9ee00eac23a0c773ba526a589 100644 (file)
@@ -45,7 +45,6 @@ class Command(BaseCommand):
                                 item.period = from_period
                                 item.save()
                                 item_clone = item.clone()
-                                item_clone.save()
                                 item_clone.readers = []
                                 item_clone.period = to_period
                                 item_clone.save()
@@ -56,7 +55,6 @@ class Command(BaseCommand):
                     questions = seminar.question.all()
                     for question in questions:
                         question_clone = question.clone()
-                        question_clone.save()
                         question_clone.seminar = clone
                         question.save()
                         print ("cloned and assigned:", question)
index f5816d4eef34ec16df68b163424718de736435ea..0ba9191551ffd5120a97000e2fb0d34e69b74101 100755 (executable)
@@ -99,7 +99,7 @@ class ClonableMixin(object):
         """Return an identical copy of the instance with a new ID."""
         if not self.pk:
             raise ValueError('Instance must be saved before it can be cloned.')
-        duplicate = copy.copy(self)
+        duplicate = self
         # Setting pk to None tricks Django into thinking this is a new object.
         duplicate.pk = None
         duplicate.save()