import web

from decorators import i18n
from user.userdecorators import admin

class DisableView:
    @admin
    @i18n
    def GET(self, plugin_to_disable):
        disable_plugins = web.ctx.plugin_manager.disable_plugin(plugin_to_disable)

        # If there isn't new disable plugins
        if not disable_plugins:
            raise web.seeother('/pluginmanager')

        plugins_name = (p.name for p in disable_plugins)
        string_name = ', '.join(plugins_name)

        web.ctx.notify(_('The next plugins has been disabled: %s'
            % string_name), 'notification')

        raise web.seeother('/pluginmanager')
