Skip to content

Commit

Permalink
Merge pull request #26 from unlimitedlabs/enable_admin
Browse files Browse the repository at this point in the history
Add the admin back in.
  • Loading branch information
thisisdhaas committed Sep 24, 2015
2 parents 6bb78cb + 8e0912e commit f5ebb42
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
37 changes: 37 additions & 0 deletions example_project/example_project/orchestra_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def setup_orchestra(settings_module_name):
# Allow pre-compression independent of user requests
settings.COMPRESS_OFFLINE = True

# Add the Django admin and the Django CMS admin style to make it pretty.
# The CMS style must be listed before the admin, so we do some processing
# of the INSTALLED_APPS list to preserve that property.
settings.INSTALLED_APPS = install_admin(settings.INSTALLED_APPS)

# Tasks and Workflows
######################

Expand Down Expand Up @@ -170,3 +175,35 @@ def setup_orchestra(settings_module_name):
settings.SLACK_INTERNAL_API_KEY = ''
settings.SLACK_EXPERTS_API_KEY = ''
settings.SLACK_INTERNAL_NOTIFICATION_CHANNEL = '#orchestra-tasks'


def install_admin(installed_apps):
admin_installed = 'django.contrib.admin' in installed_apps
cms_installed = 'djangocms_admin_style' in installed_apps

# If admin but not cms is installed, stick the cms in before it.
if admin_installed and not cms_installed:
admin_idx = installed_apps.index('django.contrib.admin')
new_installed_apps = (
tuple(installed_apps[:admin_idx]) +
('djangocms_admin_style',) +
tuple(installed_apps[admin_idx:]))

# If cms but not admin is installed (unlikely!), append the admin.
elif not admin_installed and cms_installed:
new_installed_apps = installed_apps + (
'django.contrib.admin',
)

# If neither are installed, append both.
elif not admin_installed and not cms_installed:
new_installed_apps = installed_apps + (
'djangocms_admin_style',
'django.contrib.admin',
)

# If both are installed, do nothing.
else:
new_installed_apps = installed_apps

return new_installed_apps
5 changes: 5 additions & 0 deletions example_project/example_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
here as well.
"""
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.auth import views as auth_views

urlpatterns = [

# Admin Views
url(r'^orchestra/admin/',
include(admin.site.urls)),

# Registration Views
# Eventually these will be auto-registered with the Orchestra URLs, but for
# now we need to add them separately.
Expand Down
16 changes: 16 additions & 0 deletions orchestra/fixtures/demo_admin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"model": "auth.User",
"pk": 10,
"fields": {
"username": "admin",
"first_name": "Demo",
"last_name": "Admin",
"is_active": true,
"is_superuser": true,
"is_staff": true,
"password": "pbkdf2_sha256$20000$xixBm4UAwAKf$NQIC3Zn2ThtJHsJH4xbuBMdUhPsTAHBgw0pXBY4VAfo=",
"email": "noreply-admin@example.org"
}
}
]

0 comments on commit f5ebb42

Please sign in to comment.