From ab97c7687c562768db99da1e0de50104a721d9ea Mon Sep 17 00:00:00 2001 From: yomguy Date: Tue, 2 Aug 2016 18:54:44 +0200 Subject: [PATCH] delete old professors while pulling --- teleforma/views/core.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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): -- 2.39.5