def add_mapping_version(self, mapping_version): from mappings.models import MappingVersion # Using raw query to atomically add item to the list MappingVersion.objects.raw_update({'_id': ObjectId(mapping_version.id)}, {'$push': {'source_version_ids': self.id}}) updated_at = datetime.now() MappingVersion.objects.filter(id=mapping_version.id).update(updated_at=updated_at) SourceVersion.objects.filter(id=self.id).update(active_mappings=F('active_mappings')+1, last_mapping_update=updated_at, last_child_update=updated_at, updated_at=updated_at) update_search_index(mapping_version)
def update_mapping_version(self, mapping_version): mapping_previous_version = mapping_version.previous_version if mapping_previous_version: from mappings.models import MappingVersion #Using raw query to atomically remove item from the list MappingVersion.objects.raw_update({'_id': ObjectId(mapping_previous_version.id)},{'$pull': {'source_version_ids': self.id}}) MappingVersion.objects.filter(id=mapping_previous_version.id).update(updated_at=datetime.now()) update_search_index(mapping_previous_version) self.add_mapping_version(mapping_version)
def add_mapping_version(self, mapping_version): from mappings.models import MappingVersion # Using raw query to atomically add item to the list MappingVersion.objects.raw_update( {'_id': ObjectId(mapping_version.id)}, {'$push': { 'source_version_ids': self.id }}) MappingVersion.objects.filter(id=mapping_version.id).update( updated_at=datetime.now()) self.save() # save to update counts update_search_index(mapping_version)
def add_concept_version(self, concept_version): from concepts.models import ConceptVersion # Using raw query to atomically add item to the list ConceptVersion.objects.raw_update( {'_id': ObjectId(concept_version.id)}, {'$push': { 'source_version_ids': self.id }}) ConceptVersion.objects.filter(id=concept_version.id).update( updated_at=datetime.now()) self.save() #save to update counts update_search_index(concept_version)
def update_concept_version(self, concept_version): concept_previous_version = concept_version.previous_version if concept_previous_version: from concepts.models import ConceptVersion # Using raw query to atomically remove item from the list ConceptVersion.objects.raw_update({'_id': ObjectId(concept_previous_version.id)}, {'$pull': {'source_version_ids': self.id}}) ConceptVersion.objects.filter(id=concept_previous_version.id).update(updated_at=datetime.now()) update_search_index(concept_previous_version) self.add_concept_version(concept_version)
def add_concept_version(self, concept_version): from concepts.models import ConceptVersion # Using raw query to atomically add item to the list ConceptVersion.objects.raw_update({'_id': ObjectId(concept_version.id)}, {'$push': {'source_version_ids': self.id}}) updated_at = datetime.now() ConceptVersion.objects.filter(id=concept_version.id).update(updated_at=updated_at) SourceVersion.objects.filter(id=self.id).update(active_concepts=F('active_concepts')+1, last_concept_update=updated_at, last_child_update=updated_at, updated_at=updated_at) update_search_index(concept_version)