X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fipsilon.git;a=blobdiff_plain;f=ipsilon%2Fadmin%2Fproviders.py;h=8a21b52a1154273566346c66e9a5070e32bfe94f;hp=8219880ef877e7ca5946179b9deb8f6f50de4d77;hb=cfe24fa3dc15d87f3ace944a2d62a0f4c5ee496c;hpb=73eeae98716c0e25f31cdb2c347c1939525d6ef7 diff --git a/ipsilon/admin/providers.py b/ipsilon/admin/providers.py old mode 100755 new mode 100644 index 8219880..8a21b52 --- a/ipsilon/admin/providers.py +++ b/ipsilon/admin/providers.py @@ -1,90 +1,12 @@ -#!/usr/bin/python -# -# Copyright (C) 2014 Simo Sorce -# -# see file 'COPYING' for use and warranty information -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# Copyright (C) 2014 Ipsilon project Contributors, for license see COPYING - -import cherrypy -from ipsilon.util.page import Page -from ipsilon.util.page import admin_protect, auth_protect +from ipsilon.admin.common import AdminPlugins from ipsilon.providers.common import FACILITY -from ipsilon.admin.common import AdminPluginPage -class ProviderPlugins(Page): +class ProviderPlugins(AdminPlugins): def __init__(self, site, parent): - super(ProviderPlugins, self).__init__(site) - self._master = parent + super(ProviderPlugins, self).__init__('providers', site, parent, + FACILITY, ordered=False) self.title = 'Identity Providers' - self.url = '%s/providers' % parent.url - self.facility = FACILITY - parent.add_subtree('providers', self) - - for plugin in self._site[FACILITY]['available']: - cherrypy.log.error('Admin provider plugin: %s' % plugin) - obj = self._site[FACILITY]['available'][plugin] - page = AdminPluginPage(obj, self._site, self) - if hasattr(obj, 'admin'): - obj.admin.mount(page) - self.add_subtree(plugin, page) - - def root_with_msg(self, message=None, message_type=None): - plugins = self._site[FACILITY] - enabled_plugins = [] - for item in plugins['available']: - plugin = plugins['available'][item] - if plugin.is_enabled: - enabled_plugins.append(item) - return self._template('admin/providers.html', title=self.title, - baseurl=self.url, - message=message, - message_type=message_type, - available=plugins['available'], - enabled=enabled_plugins, - menu=self._master.menu) - - @auth_protect - def root(self, *args, **kwargs): - return self.root_with_msg() - - @admin_protect - def enable(self, plugin): - msg = None - plugins = self._site[FACILITY] - if plugin not in plugins['available']: - msg = "Unknown plugin %s" % plugin - return self.root_with_msg(msg, "error") - obj = plugins['available'][plugin] - if not obj.is_enabled: - obj.enable(self._site) - msg = "Plugin %s enabled" % obj.name - return self.root_with_msg(msg, "success") - enable.exposed = True - - @admin_protect - def disable(self, plugin): - msg = None - plugins = self._site[FACILITY] - if plugin not in plugins['available']: - msg = "Unknown plugin %s" % plugin - return self.root_with_msg(msg, "error") - obj = plugins['available'][plugin] - if obj.is_enabled: - obj.disable(self._site) - msg = "Plugin %s disabled" % obj.name - return self.root_with_msg(msg, "success") - disable.exposed = True + self.template = 'admin/providers.html'