]> git.parisson.com Git - teleforma.git/commitdiff
fix no date
authoryomguy <yomguy@parisson.com>
Wed, 30 Jan 2013 10:40:45 +0000 (11:40 +0100)
committeryomguy <yomguy@parisson.com>
Wed, 30 Jan 2013 10:40:45 +0000 (11:40 +0100)
teleforma/models/core.py

index 6b5ba91961cda1639451b339f393435849d3956d..f65013dcfbb02d1264d975896093a303815ac635 100644 (file)
@@ -273,8 +273,8 @@ class Conference(Model):
                 'period': self.period.name if self.period else 'None',
                 'session': self.session if self.session else 'None',
                 'streams': [],
-                'date_begin': self.date_begin.strftime('%Y %m %d %H %M %S'),
-                'date_end': self.date_end.strftime('%Y %m %d %H %M %S'),
+                'date_begin': self.date_begin.strftime('%Y %m %d %H %M %S') if self.date_begin else 'None',
+                'date_end': self.date_end.strftime('%Y %m %d %H %M %S') if self.date_end else 'None',
                  }
 
         if self.room:
@@ -294,21 +294,28 @@ class Conference(Model):
         self.public_id = data['id']
         self.course, c = Course.objects.get_or_create(code=data['course_code'])
         self.course_type, c = CourseType.objects.get_or_create(name=data['course_type'])
+
         if data['professor_id'] != 'None':
             user, c = User.objects.get_or_create(username=data['professor_id'])
             self.professor, c = Professor.objects.get_or_create(user=user)
             if c:
                 self.professor.courses.add(self.course)
+
         if data['period'] != 'None':
             self.period, c = Period.objects.get_or_create(name=data['period'])
+
         if data['session'] != 'None':
             self.session = data['session']
-        dl = data['date_begin'].split(' ')
-        self.date_begin = datetime.datetime(int(dl[0]), int(dl[1]), int(dl[2]),
-                                            int(dl[3]), int(dl[4]), int(dl[5]))
-        dl = data['date_end'].split(' ')
-        self.date_end = datetime.datetime(int(dl[0]), int(dl[1]), int(dl[2]),
-                                            int(dl[3]), int(dl[4]), int(dl[5]))
+
+        if data['date_begin'] != 'None':
+            dl = data['date_begin'].split(' ')
+            self.date_begin = datetime.datetime(int(dl[0]), int(dl[1]), int(dl[2]),
+                                                int(dl[3]), int(dl[4]), int(dl[5]))
+
+        if data['end'] != 'None':
+            dl = data['date_end'].split(' ')
+            self.date_end = datetime.datetime(int(dl[0]), int(dl[1]), int(dl[2]),
+                                                int(dl[3]), int(dl[4]), int(dl[5]))
         if 'room' in data.keys():
             organization = Organization.objects.get(name=data['organization'])
             self.room, c = Room.objects.get_or_create(name=data['room'],