def __sub__(self, other): if self.grade != other.grade: ns = NS() ns.status = 'course_grade_changed' ns.left = self ns.right = other ns.param = other.grade yield ns
def __sub__(self, other): if self.children != other.children: for to_add in set(other.children) - set(self.children): ns = NS() ns.status = "associate_child_to_parent" ns.left = self ns.right = other ns.param = NS() ns.param.child = to_add ns.param.parent = self.parent_idnumber yield ns for to_remove in set(self.children) - set(other.children): ns = NS() ns.status = "deassociate_child_from_parent" ns.left = self ns.right = other ns.param = NS() ns.param.child = to_remove ns.param.parent = self.parent_idnumber yield ns
def __sub__(self, other): for item in super().__sub__(other): yield item # Handle cohorts (site-wide groups) for to_add in set(other.cohort_idnumbers) - set(self.cohort_idnumbers): ns = NS() ns.status = 'add_to_cohort' ns.left = self ns.right = other ns.param = to_add yield ns for to_remove in set(self.cohort_idnumbers) - set(other.cohort_idnumbers): ns = NS() ns.status = 'remove_from_cohort' ns.left = self ns.right = other ns.param = to_remove yield ns # Other things attrs = ['username', 'email', 'homeroom'] for attr in attrs: if not getattr(self, attr) == getattr(other, attr): ns = NS() ns.status = attr+'_changed' ns.left = self ns.right = other ns.param = getattr(other, attr) yield ns for course in set(other.enrollments.keys()) - set(self.enrollments.keys()): for group in other.enrollments[course]: ns = NS() ns.status = 'enrol_parent_into_course' ns.left = self ns.right = other to_add = NS() to_add.course = course to_add.group = group ns.param = to_add yield ns for course in set(self.enrollments.keys()) and set(other.enrollments.keys()): #TODO: Check that parents are being put into courses as well as the groups self_groups = self.enrollments.get(course, []) other_groups = other.enrollments.get(course, []) for group in other_groups: if not group.idnumber in [g.idnumber for g in self_groups]: ns = NS() ns.status = 'add_to_group' ns.left = self ns.right = other to_add = NS() to_add.course = course to_add.group = group ns.param = to_add yield ns for group in self_groups: if not group.idnumber in [g.idnumber for g in other_groups]: ns = NS() ns.status = 'remove_from_group' ns.left = self ns.right = other to_remove = NS() to_remove.course = course to_remove.group = group ns.param = to_remove yield ns for course in set(self.enrollments.keys()) - set(other.enrollments.keys()): for group in self.enrollments.get(course, []): ns = NS() ns.status = 'deenrol_parent_from_course' ns.left = self ns.right = other to_remove = NS() to_remove.course = course to_remove.group = group ns.param = to_remove yield ns
def __sub__(self, other): for item in super().__sub__(other): yield item # Handle cohorts (site-wide groups) for to_add in set(other.cohort_idnumbers) - set(self.cohort_idnumbers): ns = NS() ns.status = 'add_to_cohort' ns.left = self ns.right = other ns.param = to_add yield ns # for to_remove in set(self.cohort_idnumbers) - set(other.cohort_idnumbers): # ns = NS() # ns.status = 'remove_from_cohort' # ns.left = self # ns.right = other # ns.param = to_remove # yield ns # Other things attrs = ['username'] for attr in attrs: if not getattr(self, attr) == getattr(other, attr): ns = NS() ns.status = attr+'_changed' ns.left = self ns.right = other ns.param = getattr(other, attr) yield ns for course in set(other.enrollments.keys()) - set(self.enrollments.keys()): for group in other.enrollments[course]: ns = NS() ns.status = 'enrol_teacher_into_course' ns.left = self ns.right = other to_add = NS() to_add.course = course to_add.group = group ns.param = to_add yield ns # Go through each course that they share, and check that # they have the same groups, if not, do what's right for course in set(self.enrollments.keys()) and set(other.enrollments.keys()): self_groups = self.enrollments[course] other_groups = other.enrollments[course] for group in other_groups: if not group.idnumber in [g.idnumber for g in self_groups]: ns = NS() ns.status = 'add_to_group' ns.left = self ns.right = other to_add = NS() to_add.course = course to_add.group = group ns.param = to_add yield ns