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):