add grappelli (admin customisation)

This commit is contained in:
Thomas NOËL 2012-05-23 17:24:15 +02:00
parent 4ececeaaf0
commit 4b3841b32f
4 changed files with 83 additions and 3 deletions

72
polynum/dashboard.py Normal file
View File

@ -0,0 +1,72 @@
# -*- encoding: utf-8 -*-
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
from grappelli.dashboard import modules, Dashboard
from grappelli.dashboard.utils import get_admin_site_name
class CustomIndexDashboard(Dashboard):
"""
Custom index dashboard for polynum
"""
def init_with_context(self, context):
site_name = get_admin_site_name(context)
self.children.append(modules.ModelList(
_(u'Groupes et utilisateurs'),
column=1,
collapsible=False,
models=('django.contrib.*',),
))
self.children.append(modules.ModelList(
_(u'Demandes'),
column=1,
collapsible=False,
models=('polynum.base.models.request.Request',
#'polynum.base.models.request.RequestStatus',
'polynum.base.models.request.DeliveryPlace',
),
))
self.children.append(modules.ModelList(
_(u'Documents'),
column=1,
collapsible=False,
models=('polynum.base.models.request.Document',
'polynum.base.models.request.DocumentUsage',
'polynum.base.models.request.DocumentLicence',
),
))
self.children.append(modules.ModelList(
_(u'Profils de reprographie'),
column=1,
collapsible=False,
models=('polynum.base.models.profile.Profile',
'polynum.base.models.profile.ProfileOption',
#'polynum.base.models.profile.ProfileOptionChoice',
),
))
self.children.append(modules.ModelList(
_(u'Gestion des rôles'),
column=1,
collapsible=False,
models=('polynum.base.models.rbac.RoleAssociation',
'polynum.base.models.rbac.ActionAssociation',
'polynum.base.models.request.RequestStatus',
'django.contrib.auth.models.Group',
),
))
self.children.append(modules.ModelList(
_(u'Entités'),
column=1,
collapsible=False,
models=('polynum.base.models.entity.Entity',
),
))

View File

@ -119,6 +119,7 @@ TEMPLATE_DIRS = (
TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS + (
'sekizai.context_processors.sekizai',
'django.core.context_processors.request', # needed by grappelli
)
INSTALLED_APPS = (
@ -128,9 +129,11 @@ INSTALLED_APPS = (
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'grappelli.dashboard',
'grappelli',
'django.contrib.admin',
'django.contrib.formtools',
# 'django.contrib.admindocs',
#'django.contrib.admindocs',
'sekizai',
'crispy_forms',
'polynum.pages',
@ -177,12 +180,15 @@ CAS_SERVER_URL = 'https://www.ent.dauphine.fr/cas/'
DOCUMENTS_UPLOAD_DIRECTORY = '/tmp/pdf/'
# grappelli -- see http://readthedocs.org/docs/django-grappelli
GRAPPELLI_ADMIN_TITLE = 'Administration de PolyNum'
GRAPPELLI_INDEX_DASHBOARD = 'polynum.dashboard.CustomIndexDashboard'
try:
from local_settings import *
except:
pass
# CAS
if CAS_SERVER_URL:
AUTHENTICATION_BACKENDS += ( 'django_cas.backends.CASBackend', )

View File

@ -9,6 +9,7 @@ urlpatterns = patterns('',
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^grappelli/', include('grappelli.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^request/', include('polynum.request.urls')),

View File

@ -22,6 +22,7 @@ setup(name="Polynum",
'django-crispy-forms',
'django-sekizai',
'pypdf',
'django-cas >= 2.1.1' # not in pypi => pip install https://bitbucket.org/cpcc/django-cas/get/tip.tar.gz
'django-cas >= 2.1.1', # not in pypi => pip install https://bitbucket.org/cpcc/django-cas/get/tip.tar.gz
'django-grappelli >= 2.4', # not in pypi => pip install git+https://github.com/sehmaschine/django-grappelli@grappelli_2_4
],
)