def _perform_delete_multiple(self, user_identifier, resources): """ """ oids = [] ids = [] for resource in resources: oids.append(ObjectId(resource.id)) ids.append(resource.id) data = self.db[resource.rest_name].find_one({'_id': ObjectId(resource.id)}) if not data: return ids for children_rest_name in resource.children_rest_names: children_key = '_%s' % children_rest_name if children_key not in data or not len(data[children_key]): # pragma: no cover continue klass = NURESTModelController.get_first_model_with_rest_name(children_rest_name) child_resources = [klass(id=identifier) for identifier in data[children_key]] # recursively delete children ids += self._perform_delete_multiple(user_identifier=user_identifier, resources=child_resources) self.db[resources[0].rest_name].remove({'_id': {'$in': oids}}) return ids
def from_dict(cls, data): """ """ instance = super(GAPushEvent, cls).from_dict(data=data) instance.entities = [NURESTModelController.get_first_model_with_rest_name(data['entityType'])(data=data['entities'][0])] return instance
def from_dict(cls, data): """ """ instance = super(GAPushEvent, cls).from_dict(data=data) instance.entities = [ NURESTModelController.get_first_model_with_rest_name( data['entityType'])(data=data['entities'][0]) ] return instance
def _perform_delete_multiple(self, user_identifier, resources): """ """ oids = [] ids = [] for resource in resources: oids.append(ObjectId(resource.id)) ids.append(resource.id) data = self.db[resource.rest_name].find_one( {'_id': ObjectId(resource.id)}) if not data: return ids for children_rest_name in resource.children_rest_names: children_key = '_%s' % children_rest_name if children_key not in data or not len( data[children_key]): # pragma: no cover continue klass = NURESTModelController.get_first_model_with_rest_name( children_rest_name) child_resources = [ klass(id=identifier) for identifier in data[children_key] ] # recursively delete children ids += self._perform_delete_multiple( user_identifier=user_identifier, resources=child_resources) self.db[resources[0].rest_name].remove({'_id': {'$in': oids}}) return ids
def class_from_rest_name(self, rest_name): """ """ return NURESTModelController.get_first_model_with_rest_name( rest_name=rest_name)
def class_from_rest_name(self, rest_name): """ """ return NURESTModelController.get_first_model_with_rest_name(rest_name=rest_name)
def instantiate(self, resource_name): """ """ klass = NURESTModelController.get_first_model_with_rest_name( resource_name) return klass()
def instantiate(self, resource_name): """ """ klass = NURESTModelController.get_first_model_with_rest_name(resource_name) return klass()