예제 #1
0
def custom_app_registry(request):
    """Put custom Django apps into the context."""
    custom_apps = settings.CUSTOM_DJANGO_APPS.copy()
    custom_apps = [enhance_custom_app_config(app) for app in custom_apps
                   if (getattr(app, 'enabled', None) is None or
                       app.enabled(request)
                       )]
    custom_apps.sort(key=lambda app: app.verbose_name.lower())
    current_custom_app = _get_current_app(request, custom_apps)
    return {
        # 'custom_apps': list(map(_app_to_dict, custom_apps)),
        'custom_apps': custom_apps,
        'current_custom_app': current_custom_app,
        'custom_app_nav': (_get_app_nav(request, current_custom_app)
                           if current_custom_app else None)
    }
예제 #2
0
# Add any custom apps installed in the virtual environment
# Essentially this looks for the entry_points metadata in all installed Python packages. The format of the metadata in setup.py is the following:
#
#    setuptools.setup(
#        ...
#        entry_points="""
#    [airavata.djangoapp]
#    dynamic_djangoapp = dynamic_djangoapp.apps:DynamicDjangoAppConfig
#    """,
#        ...
#    )
#
for entry_point in iter_entry_points(group='airavata.djangoapp'):
    custom_app_class = entry_point.load()
    custom_app_class = enhance_custom_app_config(custom_app_class)
    custom_app_instance = custom_app_class(entry_point.name, import_module(entry_point.module_name))
    CUSTOM_DJANGO_APPS.append(custom_app_instance)
    # Create path to AppConfig class (otherwise the ready() method doesn't get
    # called)
    INSTALLED_APPS.append("{}.{}".format(entry_point.module_name,
                                         entry_point.attrs[0]))

OUTPUT_VIEW_PROVIDERS = {}
for entry_point in iter_entry_points(group='airavata.output_view_providers'):
    OUTPUT_VIEW_PROVIDERS[entry_point.name] = entry_point.load()()

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
CUSTOM_DJANGO_APPS = []

# Add any custom apps installed in the virtual environment
# Essentially this looks for the entry_points metadata in all installed Python packages. The format of the metadata in setup.py is the following:
#
#    setuptools.setup(
#        ...
#        entry_points="""
#    [airavata.djangoapp]
#    dynamic_djangoapp = dynamic_djangoapp.apps:DynamicDjangoAppConfig
#    """,
#        ...
#    )
#
for entry_point in iter_entry_points(group='airavata.djangoapp'):
    custom_app = enhance_custom_app_config(entry_point.load())
    CUSTOM_DJANGO_APPS.append(custom_app)
    # Create path to AppConfig class (otherwise the ready() method doesn't get
    # called)
    INSTALLED_APPS.append("{}.{}".format(entry_point.module_name,
                                         entry_point.attrs[0]))

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django_airavata.apps.auth.middleware.authz_token_middleware',