From 6618613c9210fb44d36d90f5f2404b435f10dfc8 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Fri, 8 Aug 2014 17:17:13 +0100 Subject: toaster: enable admin interface on select models We enable the admin interface in Toaster. We add admin models for Build Environments (where the sysadmin can configure where the builds take place) and for Layer Sources (marking the upstream provider for layer information). The admin interface and associated data are enabled only for the MANAGED version. Signed-off-by: Alexandru DAMIAN --- lib/toaster/bldcontrol/admin.py | 8 ++++++++ lib/toaster/orm/admin.py | 17 +++++++++++++++++ lib/toaster/toastermain/settings.py | 10 +++++----- lib/toaster/toastermain/urls.py | 18 +++++++++++++----- 4 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 lib/toaster/bldcontrol/admin.py create mode 100644 lib/toaster/orm/admin.py diff --git a/lib/toaster/bldcontrol/admin.py b/lib/toaster/bldcontrol/admin.py new file mode 100644 index 000000000..fcbe5f593 --- /dev/null +++ b/lib/toaster/bldcontrol/admin.py @@ -0,0 +1,8 @@ +from django.contrib import admin +from django.contrib.admin.filters import RelatedFieldListFilter +from .models import BuildEnvironment + +class BuildEnvironmentAdmin(admin.ModelAdmin): + pass + +admin.site.register(BuildEnvironment, BuildEnvironmentAdmin) diff --git a/lib/toaster/orm/admin.py b/lib/toaster/orm/admin.py new file mode 100644 index 000000000..938363048 --- /dev/null +++ b/lib/toaster/orm/admin.py @@ -0,0 +1,17 @@ +from django.contrib import admin +from django.contrib.admin.filters import RelatedFieldListFilter +from .models import Branch, LayerSource, ToasterSetting + +class LayerSourceAdmin(admin.ModelAdmin): + pass + +class BranchAdmin(admin.ModelAdmin): + pass + +class ToasterSettingAdmin(admin.ModelAdmin): + pass + +admin.site.register(LayerSource, LayerSourceAdmin) +admin.site.register(Branch, BranchAdmin) +admin.site.register(ToasterSetting, ToasterSettingAdmin) + diff --git a/lib/toaster/toastermain/settings.py b/lib/toaster/toastermain/settings.py index 1dab25aa6..42581f2df 100644 --- a/lib/toaster/toastermain/settings.py +++ b/lib/toaster/toastermain/settings.py @@ -232,17 +232,13 @@ TEMPLATE_CONTEXT_PROCESSORS = ('django.contrib.auth.context_processors.auth', INSTALLED_APPS = ( #'django.contrib.sites', - #'django.contrib.messages', 'django.contrib.staticfiles', - # Uncomment the next line to enable the admin: - # 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'django.contrib.humanize', 'orm', 'toastermain', 'south', - 'bldcontrol', ) SOUTH_TESTS_MIGRATE = False @@ -251,7 +247,11 @@ SOUTH_TESTS_MIGRATE = False if MANAGED: INSTALLED_APPS = ('django.contrib.auth', 'django.contrib.contenttypes', - 'django.contrib.sessions',) + INSTALLED_APPS + 'django.contrib.messages', + 'django.contrib.sessions', + # Uncomment the next line to enable the admin: + 'django.contrib.admin', + ) + INSTALLED_APPS # We automatically detect and install applications here if diff --git a/lib/toaster/toastermain/urls.py b/lib/toaster/toastermain/urls.py index 0e7b5c2d7..1ae6245cc 100644 --- a/lib/toaster/toastermain/urls.py +++ b/lib/toaster/toastermain/urls.py @@ -25,11 +25,12 @@ from django.views.decorators.cache import never_cache # Uncomment the next two lines to enable the admin: -# from django.contrib import admin -# admin.autodiscover() +from django.contrib import admin +admin.autodiscover() + urlpatterns = patterns('', + # the api-s are not auto-discoverable url(r'^api/1.0/', include('bldviewer.api')), - url(r'^$', never_cache(RedirectView.as_view(url='/toastergui/'))), # Examples: # url(r'^toaster/', include('toaster.foo.urls')), @@ -37,10 +38,17 @@ urlpatterns = patterns('', # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - # Uncomment the next line to enable the admin: - # url(r'^admin/', include(admin.site.urls)), + + # if no application is selected, we have the magic toastergui app here + url(r'^$', never_cache(RedirectView.as_view(url='/toastergui/'))), ) +import toastermain.settings +if toastermain.settings.MANAGED: + urlpatterns = urlpatterns + [ + # Uncomment the next line to enable the admin: + url(r'^admin/', include(admin.site.urls)), + ] # Automatically discover urls.py in various apps, beside our own # and map module directories to the patterns -- cgit 1.2.3-korg