def replace_access(self, diff): # delete exiting self.access_set.all().delete() # replace with new ones for access in diff: Access.create(node=self, access_inherited=True, access=access)
def _apply_diff_add(self, diff): model = diff.first() if isinstance(model, Access): for _model in diff: Access.create( node=self, access_inherited=True, access=_model ) elif isinstance(model, KVStoreNode): array_to_apply = [] for _model in diff: array_to_apply.append( { 'kv_inherited': True, 'key': _model.key, 'kv_type': _model.kv_type, 'kv_format': _model.kv_format } ) self.kv.apply_additions(array_to_apply) elif isinstance(model, KVStoreCompNode): pass else: raise ValueError( f"Don't know how to replace {model} (found in {diff})" )
def _apply_diff_add(self, diff): model = diff.first() if isinstance(model, Access): for _model in diff: Access.create( node=self, access_inherited=True, access=_model ) elif isinstance(model, KVStoreNode): self.kv.apply_additions( [ {'kv_inherited': True, 'key': _model.key} for _model in diff ] ) elif isinstance(model, KVStoreCompNode): pass else: raise ValueError( f"Don't know how to replace {model} (found in {diff})" )
def _apply_access_diff_add(self, access_diff): if access_diff.is_add(): for access in access_diff: Access.create(node=self, access_inherited=True, access=access)