Beispiel #1
0
    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
Beispiel #2
0
    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
Beispiel #3
0
    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
Beispiel #4
0
    def inherit_kv_from(self, folder):
        instances_set = []

        for key in folder.kv.keys():
            instances_set.append(
                KVStoreNode(key=key, kv_inherited=True, node=self))

        # if there is metadata
        if len(instances_set) > 0:
            diff = Diff(operation=Diff.ADD, instances_set=instances_set)

            self.propagate_changes(diffs_set=[diff], apply_to_self=True)