]> git.parisson.com Git - teleforma.git/commitdiff
fix no course
authoryomguy <yomguy@parisson.com>
Fri, 23 Nov 2012 14:13:22 +0000 (15:13 +0100)
committeryomguy <yomguy@parisson.com>
Fri, 23 Nov 2012 14:13:22 +0000 (15:13 +0100)
teleforma/management/commands/teleforma-import-professors.py

index a69bd9de1f5d032d3ab1259dd3e5f3965607eeee..44536bf654dadc9fbd824e97507c3f8d3c7f0bb3 100644 (file)
@@ -27,8 +27,9 @@ class Command(BaseCommand):
                 p = Professor(user=user)
                 p.save()
                 for code in professor['courses']:
-                    course = Course.objects.get(code=code)
-                    p.courses.add(course)
+                    course = Course.objects.filter(code=code)
+                    if course:
+                        p.courses.add(course[0])
                 print 'imported: ' + user.first_name + ' ' + user.last_name + ' ' + user.username
 
     def handle(self, *args, **options):