def unregister_plugin_blocks(plugin_name): plugin = get_plugin(plugin_name, prepend_plugins_dir=False) if not plugin: return plugin_blocks = plugin.get_blocks() if plugin_blocks: unregister_items(plugin_blocks) clear_lookup_cache()
def pre_delete_handler(sender, instance, **kwargs): content = instance.content clear_lookup_cache() if content: other_content_blocks = RegisteredBlock.objects.filter( content=content).exclude(pk=instance.pk) if not other_content_blocks: # we unmark that base content has relateds block content.has_related_blocks = False content.save()
def post_save_handler(sender, instance, **kwargs): if kwargs.get('raw', False): return # when loading from fixtures, the registry model data maybe is not present # invalidate block cache if exists block = instance.get_registry_item() block.invalidate_cache() clear_lookup_cache() # marking related blocks content = instance.content if content and not content.has_related_blocks: # we mark that base content has related blocks, for performance reason content.has_related_blocks = True content.save()
def register_plugin_blocks(plugin_name): plugin = get_plugin(plugin_name, prepend_plugins_dir=False) if not plugin: return plugin_blocks = plugin.get_blocks() if plugin_blocks: register_items(plugin_blocks) from merengue.block.utils import _blocks_models_cache for plugin_block in plugin_blocks: for model in plugin_block.get_models_refresh_cache(): if not _blocks_models_cache[model]: _blocks_models_cache[model] = [] if not plugin_block in _blocks_models_cache[model]: _blocks_models_cache[model].append(plugin_block) clear_lookup_cache()