From 889a85e3d6a7bf0e7ea5b6ee6214712e2360da63 Mon Sep 17 00:00:00 2001 From: yomguy Date: Wed, 30 Jan 2013 11:40:45 +0100 Subject: [PATCH] fix no date --- teleforma/models/core.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/teleforma/models/core.py b/teleforma/models/core.py index 6b5ba919..f65013dc 100644 --- a/teleforma/models/core.py +++ b/teleforma/models/core.py @@ -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'], -- 2.39.5