From: yomguy Date: Wed, 30 Jan 2013 12:05:13 +0000 (+0100) Subject: add department to conf API X-Git-Tag: 1.1~643 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=4fef414f6c8f08296e4783904256ac00831ad846;p=teleforma.git add department to conf API --- diff --git a/teleforma/models/core.py b/teleforma/models/core.py index 786bd256..aac9426e 100644 --- a/teleforma/models/core.py +++ b/teleforma/models/core.py @@ -270,6 +270,7 @@ class Conference(Model): 'course_code': self.course.code, 'course_type': self.course_type.name, 'department': self.department.name if self.department else 'None', + 'organization': self.department.organization.name if self.department else 'None', 'professor_id': self.professor.user.username if self.professor else 'None', 'period': self.period.name if self.period else 'None', 'session': self.session if self.session else 'None', @@ -295,7 +296,12 @@ 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']) - self.department = Department.objects.get(name=data['department']) + + organization, c = Organization.objects.get_or_create(name=data['organization']) + + if data['department'] != 'None': + self.department, c = Department.objects.get_or_create(name=data['department'], + organization=organization) if data['professor_id'] != 'None': user, c = User.objects.get_or_create(username=data['professor_id']) @@ -319,7 +325,7 @@ class Conference(Model): 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, c = Organization.objects.get_or_create(name=data['organization']) + self.room, c = Room.objects.get_or_create(name=data['room'], organization=organization) self.save()