From: Guillaume Pellerin Date: Mon, 21 Jan 2019 17:57:46 +0000 (+0100) Subject: Fix class_group pulling X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=9b21b92e0c12840910277cb7fa35ce03ffb2da0f;p=teleforma.git Fix class_group pulling --- diff --git a/teleforma/views/core.py b/teleforma/views/core.py index 8acbf2ad..37e9184a 100644 --- a/teleforma/views/core.py +++ b/teleforma/views/core.py @@ -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):