]> git.parisson.com Git - teleforma.git/commitdiff
add department to conf API
authoryomguy <yomguy@parisson.com>
Wed, 30 Jan 2013 12:05:13 +0000 (13:05 +0100)
committeryomguy <yomguy@parisson.com>
Wed, 30 Jan 2013 12:05:13 +0000 (13:05 +0100)
teleforma/models/core.py

index 786bd256fc62f600e36b3819d5dd44f45257c0e9..aac9426ec106338e7cf4c2e1a90579d534a76109 100644 (file)
@@ -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()