Example #1
0
def restore_config(zip_config):
    from merengue.action.models import RegisteredAction
    from merengue.block.models import RegisteredBlock
    from merengue.registry import RegisteredItem
    from merengue.pluggable.models import RegisteredPlugin
    from merengue.pluggable.utils import install_plugin
    from merengue.theming.models import Theme
    config = get_config(zip_config)
    restore_all = (config.get("mode", "fixtures") == "all")
    version = config.get("version", "MERENGUE_VERSION")
    # TODO: Implement method to get current merengue version
    if "MERENGUE_VERSION" != version:
        raise CommandError("Merengue version error"
                           )  # To fix. CommandError can not be displayed TTW.
    models_to_restore = (
        (RegisteredItem, "registry"),  # this has to be first in tuple
        (RegisteredAction, "actions"),
        (RegisteredBlock, "blocks"),
        (RegisteredPlugin, "plugins"),
        (Theme, "themes"),
    )
    restore_models(zip_config, models_to_restore)
    if restore_all:
        # TODO: Implement "all" mode restore
        pass
    for plugin in RegisteredPlugin.objects.filter(installed=True):
        install_plugin(plugin)
    zip_config.close()
    print 'File restored successfully'
Example #2
0
def restore_config(zip_config):
    from merengue.action.models import RegisteredAction
    from merengue.block.models import RegisteredBlock
    from merengue.registry import RegisteredItem
    from merengue.pluggable.models import RegisteredPlugin
    from merengue.pluggable.utils import install_plugin
    from merengue.theming.models import Theme
    config = get_config(zip_config)
    restore_all = (config.get("mode", "fixtures") == "all")
    version = config.get("version", "MERENGUE_VERSION")
    # TODO: Implement method to get current merengue version
    if "MERENGUE_VERSION" != version:
        raise CommandError("Merengue version error")  # To fix. CommandError can not be displayed TTW.
    models_to_restore = (
        (RegisteredItem, "registry"),  # this has to be first in tuple
        (RegisteredAction, "actions"),
        (RegisteredBlock, "blocks"),
        (RegisteredPlugin, "plugins"),
        (Theme, "themes"),
    )
    restore_models(zip_config, models_to_restore)
    if restore_all:
        # TODO: Implement "all" mode restore
        pass
    for plugin in RegisteredPlugin.objects.filter(installed=True):
        install_plugin(plugin)
    zip_config.close()
    print 'File restored successfully'
Example #3
0
def active_plugin_with_deps(plugin_dir):
    """ active plugins with its dependences """
    from merengue.pluggable.utils import install_plugin
    registered_plugin = register_plugin(plugin_dir)
    plugin = registered_plugin.get_registry_item()
    for dep in getattr(plugin, 'required_plugins', []):
        active_plugin_with_deps(dep)
    registered_plugin.installed = True
    registered_plugin.active = True
    registered_plugin.save()
    install_plugin(registered_plugin)
Example #4
0
def active_plugin_with_deps(plugin_dir):
    """ active plugins with its dependences """
    from merengue.pluggable.utils import install_plugin
    registered_plugin = register_plugin(plugin_dir)
    plugin = registered_plugin.get_registry_item()
    for dep in getattr(plugin, 'required_plugins', []):
        active_plugin_with_deps(dep)
    registered_plugin.installed = True
    registered_plugin.active = True
    registered_plugin.save()
    install_plugin(registered_plugin)
Example #5
0
 def save_form(self, request, form, change):
     change_installed_field = 'installed' in form.changed_data
     if 'installed' in form.cleaned_data:
         is_installed = form.cleaned_data['installed'] == True
     registered_plugin = form.save(commit=False)
     if change_installed_field:
         if is_installed:
             registered_plugin.active = True
             install_plugin(registered_plugin)
         else:
             registered_plugin.active = False
     return registered_plugin
Example #6
0
 def save_form(self, request, form, change):
     change_installed_field = "installed" in form.changed_data
     if "installed" in form.cleaned_data:
         is_installed = form.cleaned_data["installed"] == True
     registered_plugin = form.save(commit=False)
     if change_installed_field:
         if is_installed:
             registered_plugin.active = True
             install_plugin(registered_plugin)
         else:
             registered_plugin.active = False
     return registered_plugin
 def forwards(self, orm):
     "Write your forwards methods here."
     from django.conf import settings
     from johnny import cache
     from merengue.pluggable import register_plugin
     from merengue.pluggable.utils import install_plugin
     # Unpatch cache backend to disable johnny cache. Johny does weird things
     query_cache_backend = cache.get_backend()
     query_cache_backend.unpatch()
     from django.db import transaction
     for plug_dir in settings.DEMO_PLUGINS:
         plugin = register_plugin(plug_dir)
         plugin.installed = True
         plugin.active = True
         plugin.save()
         install_plugin(plugin)
         transaction.commit()
Example #8
0
 def handle(self, app=None, target=None, **options):
     load_plugins()
     plugins = RegisteredPlugin.objects.actives()
     for plugin_registered in plugins:
         print 'Reactivating plugin %s...' % plugin_registered.directory_name
         install_plugin(plugin_registered)