57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
# hobo - portal to configure and deploy applications
|
|
# Copyright (C) 2015 Entr'ouvert
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU Affero 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 Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
from django.apps import AppConfig
|
|
from django.db.models.signals import pre_save, pre_delete, m2m_changed, post_save
|
|
from django.conf import settings
|
|
|
|
|
|
class Plugin:
|
|
def get_before_urls(self):
|
|
from . import urls
|
|
return urls.urlpatterns
|
|
|
|
|
|
class Authentic2AgentConfig(AppConfig):
|
|
name = 'hobo.agent.authentic2'
|
|
label = 'authentic2_agent'
|
|
verbose_name = 'Authentic2 Agent'
|
|
|
|
def get_a2_plugin(self):
|
|
return Plugin()
|
|
|
|
def ready(self):
|
|
from . import provisionning
|
|
|
|
engine = provisionning.Provisionning()
|
|
provisionning.provisionning = engine
|
|
|
|
if getattr(settings, 'HOBO_PROVISIONNING', True):
|
|
pre_save.connect(engine.pre_save)
|
|
post_save.connect(engine.post_save)
|
|
pre_delete.connect(engine.pre_delete)
|
|
m2m_changed.connect(engine.m2m_changed)
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
old_execute = BaseCommand.execute
|
|
|
|
def new_execute(self, *args, **kwargs):
|
|
with engine:
|
|
return old_execute(self, *args, **kwargs)
|
|
|
|
BaseCommand.execute = new_execute
|