From: yomguy Date: Tue, 2 Aug 2016 16:54:44 +0000 (+0200) Subject: delete old professors while pulling X-Git-Tag: 1.3-TC~2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=ab97c7687c562768db99da1e0de50104a721d9ea;p=teleforma.git delete old professors while pulling --- diff --git a/teleforma/views/core.py b/teleforma/views/core.py index 8ba80c6c..0817a0e6 100644 --- a/teleforma/views/core.py +++ b/teleforma/views/core.py @@ -661,6 +661,9 @@ class ProfessorListView(View): def pull(request, host=None): from teleforma.models import Organization, Department departments = Department.objects.all() + professors_old = Professor.objects.all() + professors_new = [] + for department in departments: url = 'http://' + department.domain + '/json/' s = ServiceProxy(url) @@ -679,6 +682,12 @@ class ProfessorListView(View): 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 HelpView(TemplateView):