]> git.parisson.com Git - teleforma.git/commitdiff
Fix class_group pulling
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 21 Jan 2019 17:57:46 +0000 (18:57 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 21 Jan 2019 17:57:46 +0000 (18:57 +0100)
teleforma/views/core.py

index 8acbf2adb87e41ab42946c35a9ecf06f403ff16b..37e9184a94d7a9b380a715d88e24765e192f68ac 100644 (file)
@@ -823,16 +823,17 @@ class ClassGroupView(View):
         class_groups = ClassGroup.objects.all()
         return [w.to_json_dict() for w in class_groups]
 
-    def pull(request, host=None):
-        if host:
-            url = 'http://' + host + '/json/'
-        else:
-            url = 'https://' + settings.TELECASTER_MASTER_SERVER + '/json/'
-        s = ServiceProxy(url)
-
-        remote_list = s.teleforma.get_class_group_list()
-        for class_group_dict in remote_list['result']:
-            class_group, c = ClassGroup.objects.get_or_create(name=class_group_dict['name'])
+    def pull(request, organization_name):
+        from teleforma.models import Organization, Department
+        organization = Organization.objects.get(name=organization_name)
+        departments = Department.objects.filter(organization=organization)
+        for department in departments:
+            url = 'https://' + department.domain + '/json/'
+            s = ServiceProxy(url)
+            remote_list = s.teleforma.get_class_group_list()
+            if remote_list['result']:
+                for class_group_dict in remote_list['result']:
+                    class_group, c = ClassGroup.objects.get_or_create(name=class_group_dict['name'])
 
 
 class HelpView(TemplateView):