]> git.parisson.com Git - teleforma.git/commitdiff
Merge branch 'dev' into tc202
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 20 Jul 2017 00:06:41 +0000 (02:06 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 20 Jul 2017 00:06:41 +0000 (02:06 +0200)
1  2 
teleforma/views/core.py

index 28e5004920943b2fbd106cb84f2d90a897bef32b,d3b634fe10c4e2d7809ef9448351594a7ddcfb1c..8b54250de330468d8750c84f4dd66c19270a7857
@@@ -746,43 -747,35 +746,43 @@@ class ProfessorListView(View)
          return [p.to_json_dict() for p in professors]
  
      def pull(request, host=None):
 -        if host:
 -            url = 'http://' + host + '/json/'
 -        else:
 -            url = 'http://' + settings.TELECASTER_MASTER_SERVER + '/json/'
 -        s = ServiceProxy(url)
 -
 -        remote_list = s.teleforma.get_professor_list()
 -        for professor_dict in remote_list['result']:
 -            user, c = User.objects.get_or_create(username=professor_dict['username'])
 -            user.first_name = professor_dict['first_name']
 -            user.last_name = professor_dict['last_name']
 -            user.email = professor_dict['email']
 -            user.save()
 +        from teleforma.models import Organization, Department
 +        departments = Department.objects.all()
 +        professors_old = Professor.objects.all()
 +        professors_new = []
  
 -            professor, c = Professor.objects.get_or_create(user=user)
 -            for course_code in professor_dict['courses']:
 -                course = Course.objects.filter(code=course_code)
 -                if course:
 -                    if not course[0] in professor.courses.all():
 -                        professor.courses.add(course[0])
 -            professor.save()
 +        for department in departments:
 +            url = 'http://' + department.domain + '/json/'
 +            s = ServiceProxy(url)
 +            remote_list = s.teleforma.get_professor_list()
 +            for professor_dict in remote_list['result']:
 +                user, c = User.objects.get_or_create(username=professor_dict['username'])
 +                user.first_name = professor_dict['first_name']
 +                user.last_name = professor_dict['last_name']
 +                user.email = professor_dict['email']
 +                user.save()
 +
 +                professor, c = Professor.objects.get_or_create(user=user)
 +                for course_code in professor_dict['courses']:
 +                    course = Course.objects.filter(code=course_code)
 +                    if course:
 +                        if not course[0] in professor.courses.all():
 +                            professor.courses.add(course[0])
 +                professor.save()
 +                professors_new.append(professor)
 +                #print professor
 +
 +        for professor in professors_old:
 +            if not professor in professors_new:
 +                professor.delete()
  
  
- class WebClassGroupView(View):
+ class ClassGroupView(View):
  
-     @jsonrpc_method('teleforma.get_web_class_group_list')
-     def get_web_class_group_list(request):
-         web_class_groups = WebClassGroup.objects.all()
-         return [w.to_json_dict() for w in web_class_groups]
+     @jsonrpc_method('teleforma.get_class_group_list')
+     def get_class_group_list(request):
+         class_groups = ClassGroup.objects.all()
+         return [w.to_json_dict() for w in class_groups]
  
      def pull(request, host=None):
          if host: