Commit 585a5f60 authored by Alex Pyrgiotis's avatar Alex Pyrgiotis
Browse files

admin: Make Admin base URL configurable

Add an `ADMIN_BASE_URL` setting, which works roughly the same as the
Cyclades/Astakos base URLs (minus the service registration part). The
main benefit of the `ADMIN_BASE_URL` setting is that it allows the
administrator to define the path for Admin (or lack thereof).

Also, using the `extends_path_with_slash` function, the base URL that
the administrator chooses should work with or without a slash. In the
latter case, a Django-specific redirect view will be used to redirect
the request to the URL with slash.

Finally, the addition of the `ADMIN_BASE_URL` brings also another
change. If the administrator wants to install Admin in a separate node,
he/she no longer has to choose between using as ROOT_URLCONF the
'synnefo_admin.urls' or 'synnefo_admin.admin.urls' (their main
difference was that the former had '/admin/' hard-coded).
Using simply the 'synnefo_admin.urls' should suffice,
since the `BASE_PATH` will be extracted from the `ADMIN_BASE_URL`.

Fixes apyrgio/synnefo#289
parent 84782bc3
......@@ -23,9 +23,14 @@ Settings for the snf-admin-app.
from django.conf import settings
from collections import OrderedDict
from synnefo.lib import parse_base_url
ADMIN_ENABLED = getattr(settings, 'ADMIN_ENABLED', True)
BASE_URL = getattr(settings, 'ADMIN_BASE_URL',
BASE_HOST, BASE_PATH = parse_base_url(BASE_URL)
ADMIN_MEDIA_URL = getattr(settings, 'ADMIN_MEDIA_URL',
settings.MEDIA_URL + 'admin/')
## Boolean option to enable or disable admin
## Top-level URL for deployment.
#ADMIN_BASE_URL = "https://host:port/admin"
## If not set, defaults to MEDIA_URL + 'admin/'. Uncomment it only when you're
## sure.
from django.conf.urls import patterns, include, url
# Copyright (C) 2010-2014 GRNET S.A.
# 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
# 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 <>.
from django.conf.urls import patterns, include
from snf_django.utils.urls import extend_path_with_slash
from snf_django.lib.api.utils import prefix_pattern
from synnefo_admin.admin_settings import BASE_PATH
urlpatterns = patterns(
url(r'^admin/', include('synnefo_admin.admin.urls')),
(prefix_pattern(BASE_PATH), include('synnefo_admin.admin.urls')),
extend_path_with_slash(urlpatterns, BASE_PATH)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment