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

index cef1b19b53abf469b4725f6b51d7000f48da4c6b..df1ee1fac149a50d525de1589fe22586a2c2840c 100644 (file)
@@ -23,6 +23,8 @@ class Command(BaseCommand):
     def handle(self, *args, **kwargs):
         to_year = int(args[-1])
         from_year = int(args[-2])
+        to_period = Period.objects.get_or_create(name=str(to_year))
+        from_period = Period.objects.get_or_create(name=str(from_year))
 
         for seminar in Seminar.objects.all():
             if seminar.expiry_date:
@@ -39,16 +41,19 @@ class Command(BaseCommand):
                             source = getattr(seminar, field.attname)
                             destination = getattr(clone, field.attname)
                             for item in source.all():
+                                item.period = from_period
+                                item.save()
                                 item_clone = item.clone()
                                 item_clone.readers = []
+                                item_clone.period = to_period
                                 item_clone.save()
                                 destination.remove(item)
                                 destination.add(item_clone)
-                    print ("documents and medias cloned and assigned:", clone)
+                                print ("cloned and assigned:", item_clone)
 
                     questions = seminar.question.all()
                     for question in questions:
                         question_clone = question.clone()
                         question_clone.seminar = clone
                         question.save()
-                        print ("updated:", question)
+                        print ("cloned and assigned:", question)
index 3878dbecd320b03db8ef41b61b5d4103655ea663..f5816d4eef34ec16df68b163424718de736435ea 100755 (executable)
@@ -395,6 +395,8 @@ class Document(MediaBase):
 
     def __unicode__(self):
         strings = []
+        if self.period:
+            strings.append(self.period)
         if self.course:
             strings.append(self.course.code)
         if self.course_type.all():
@@ -450,7 +452,8 @@ class Media(MediaBase):
 
     def __unicode__(self):
         strings = []
-
+        if self.period:
+            strings.append(self.period)
         if self.course and self.course_type:
             strings.append(self.course.code + ' ' + self.course_type.name)
         elif self.course:
index 62a70a7755c9b8e3ce0f8907d7c126efcda55cca..6ecf4b6e2139f3e0e3dd07ef21f42a2745232fd9 100755 (executable)
@@ -104,7 +104,10 @@ class Seminar(ClonableMixin, Displayable):
     objects = DisplayableManager()
 
     def __unicode__(self):
-        return ' - '.join([self.course.title, str(self.rank), self.title])
+        if self.publish_date:
+            return ' - '.join([self.publish_date.year, self.course.title, str(self.rank), self.title])
+        else:
+            return ' - '.join([self.course.title, str(self.rank), self.title])
 
     @property
     def pretty_title(self):