def move_to_commited(log_action, *args, **kwargs): sl = data.SL() item = next((i for i in sl if i.log_action == log_action), None) if item: resource_obj = resource.load(item.resource) commited = CommitedResource.get_or_create(item.resource) updated = resource_obj.db_obj.updated if item.action == CHANGES.remove.name: resource_obj.delete() commited.state = resource.RESOURCE_STATE.removed.name else: resource_obj.set_operational() commited.state = resource.RESOURCE_STATE.operational.name commited.base_path = item.base_path updated = resource_obj.db_obj.updated # required to update `updated` field resource_obj.db_obj.save() commited.inputs = patch(item.diff, commited.inputs) # TODO fix TagsWrp to return list # commited.tags = resource_obj.tags sorted_connections = sorted(commited.connections) commited.connections = patch(item.connections_diff, sorted_connections) commited.save() item.log = 'history' item.state = 'success' item.updated = updated item.save()
def commit_log_item(item): resource_obj = resource.load(item.resource) commited = CommitedResource.get_or_create(item.resource) if item.action == CHANGES.remove.name: resource_obj.delete() commited.state = resource.RESOURCE_STATE.removed.name else: resource_obj.set_operational() commited.state = resource.RESOURCE_STATE.operational.name commited.base_path = item.base_path resource_obj.db_obj.save_lazy() commited.inputs = patch(item.diff, commited.inputs) # TODO fix TagsWrp to return list # commited.tags = resource_obj.tags sorted_connections = sorted(commited.connections) commited.connections = patch(item.connections_diff, sorted_connections) commited.save_lazy() item.to_history().save_lazy() item.delete()
def load_commited(self): return CommitedResource.get_or_create(self.name)
def load_commited(self): return CommitedResource.get_or_create(self.name)