def _get_access_diff_updated(self, new_access_list=[]): """ gathers Diff with updated operation """ updates = Diff(op=Diff.UPDATE) for current in self.access_set.all(): for new_access in new_access_list: if new_access == current and current.perm_diff(new_access): updates.add(new_access) return updates
def _get_access_diff_deleted(self, new_access_list=[]): """ gathers Diff with deleted operation """ dels = Diff(op=Diff.DELETE) # if current access is not in the new list # it means current access was deleted. for current in self.access_set.all(): if current not in new_access_list: dels.add(current) return dels
def _get_access_diff_added(self, new_access_list=[]): """ gathers Diff with added operation """ adds = Diff(op=Diff.ADDED) # if current access is not in the new list # it means current access was deleted. all_current = self.access_set.all() # if new access is not in current access list of the # node - it means it will be added. for new_access in new_access_list: if new_access not in all_current: adds.add(new_access) return adds