def add_or_update(self, *items): """ Given an item, adds it to the index, or updates it if it's already in the index. """ self.stdout.write("Adding or updating item(s): %s\n" % list(items)) # Use Celery to add or update the item asynchronously if self.type == Opinion: add_or_update_opinions.delay(items) elif self.type == Audio: add_or_update_audio_files.delay(items)
def save(self, index=True, force_commit=False, *args, **kwargs): """ Overrides the normal save method, but provides integration with the bulk files and with Solr indexing. :param index: Should the item be added to the Solr index? :param commit: Should a commit be performed after adding it? """ super(Audio, self).save(*args, **kwargs) if index: from cl.search.tasks import add_or_update_audio_files add_or_update_audio_files.delay([self.pk], force_commit)