passage de grappelli à django-admin-tools

pour assurer une compatibilité avec IE7 et suivants
This commit is contained in:
Thomas NOËL 2012-07-31 10:56:06 +02:00
parent a4442738d1
commit 02c7bcaaf9
10 changed files with 105 additions and 36 deletions

View File

@ -47,7 +47,7 @@ New python executable in virtualenv/bin/python
(...)
Successfully installed django-crispy-forms django-sekizai pypdf
flup django-debug-toolbar gunicorn django-cas
django-grappelli django-classy-tags
django-admin-tools django-classy-tags
Cleaning up...
Creating .pyc files (compileall) ....done

View File

@ -69,7 +69,7 @@ New python executable in virtualenv/bin/python
(...)
Successfully installed django-crispy-forms django-sekizai pypdf
flup django-debug-toolbar gunicorn django-cas
django-grappelli django-classy-tags
django-admin-tools django-classy-tags
Cleaning up...
Creating .pyc files (compileall) ....done

View File

@ -125,10 +125,10 @@ nécessaires.</p>
</tr>
<tr>
<td><p><code>django-cas</code></p></td>
<td><p>prendre la version compatible avec Django 1.4 : <code>https://bitbucket.org/cpcc/django-cas/get/tip.tar.gz</code></p></td>
<td><p></p></td>
</tr>
<tr>
<td><p><code>django-grappelli</code></p></td>
<td><p><code>django-admin-tools</code></p></td>
<td><p></p></td>
</tr>
<tr>

View File

@ -70,8 +70,6 @@ STATICFILES_DIRS = (
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# grappelli admin -- see http://readthedocs.org/docs/django-grappelli
GRAPPELLI_ADMIN_TITLE = 'Administration de PolyNum'
# templates
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".

View File

@ -0,0 +1,18 @@
{% extends "admin/base.html" %}
{% load i18n %}
{% load url from future %}
{% block title %}PolyNum :: Administration{% endblock %}
{% block branding %}
<h1 id="site-name">PolyNum &mdash; Administration</h1>
{% endblock %}
{% block userlinks %}
<a href="/">{% trans 'Return to site' %}</a> |
<a href="http://doc.entrouvert.org/polynum/stable/">{% trans 'Documentation' %}</a> |
<a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
{% endblock %}
{% block nav-global %}{% endblock %}

View File

@ -1,19 +1,38 @@
# -*- encoding: utf-8 -*-
from django.utils.translation import ugettext_lazy as _
"""
django-admin-tools : this file was generated with the customdashboard
management command, it contains the two classes for the main dashboard and app
index dashboard. You can customize these classes as you want.
See http://django-admin-tools.readthedocs.org/en/latest/dashboard.html
"""
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard
from admin_tools.utils import get_admin_site_name
from grappelli.dashboard import modules, Dashboard
class CustomIndexDashboard(Dashboard):
"""
Custom index dashboard for polynum
Custom index dashboard for PolyNum
"""
columns = 2
title = None
def init_with_context(self, context):
self.children.append(modules.ModelList(
site_name = get_admin_site_name(context)
self.children.append(modules.ModelList(
_(u'Groupes, utilisateurs et rôles'),
column=1,
collapsible=False,
layout='inline',
draggable=True,
collapsible=True,
deletable=False,
models=('polynum.base.models.user.PolynumUser',
'django.contrib.auth.models.User',
'django.contrib.auth.models.Group',
@ -23,18 +42,19 @@ class CustomIndexDashboard(Dashboard):
self.children.append(modules.ModelList(
_(u'Demandes'),
column=1,
collapsible=False,
draggable=True,
collapsible=True,
deletable=False,
models=('polynum.base.models.request.Request',
),
))
self.children.append(modules.ModelList(
_(u'Paramètres des documents'),
column=1,
collapsible=True,
css_classes=['grp-closed'],
models=(
_(u'Paramètres des documents'),
draggable=True,
collapsible=True,
deletable=False,
models=(
'polynum.base.models.request.DeliveryPlace',
'polynum.base.models.request.DocumentUsage',
'polynum.base.models.request.DocumentLicence',),
@ -42,9 +62,9 @@ class CustomIndexDashboard(Dashboard):
self.children.append(modules.ModelList(
_(u'Profils de reprographie'),
column=1,
draggable=True,
collapsible=True,
css_classes=['grp-closed'],
deletable=False,
models=('polynum.base.models.profile.Profile',
'polynum.base.models.profile.ProfileOption',
#'polynum.base.models.profile.ProfileOptionChoice',
@ -53,9 +73,9 @@ class CustomIndexDashboard(Dashboard):
self.children.append(modules.ModelList(
_(u'Gestion du workflow'),
column=1,
draggable=True,
collapsible=True,
css_classes=['grp-closed'],
deletable=False,
models=('polynum.base.models.workflow.Status',
'polynum.base.models.workflow.Action',
'polynum.base.models.workflow.Transition',
@ -65,10 +85,39 @@ class CustomIndexDashboard(Dashboard):
self.children.append(modules.ModelList(
_(u'Entités'),
column=1,
draggable=True,
collapsible=True,
css_classes=['grp-closed'],
deletable=False,
models=('polynum.base.models.entity.Entity',
'polynum.base.models.entity.EntityType',),
))
class CustomAppIndexDashboard(AppIndexDashboard):
"""
Custom app index dashboard for git.
"""
# we disable title because its redundant with the model list module
title = ''
columns = 2
def __init__(self, *args, **kwargs):
AppIndexDashboard.__init__(self, *args, **kwargs)
# append a model list module and a recent actions module
self.children += [
modules.ModelList(self.app_title, self.models,
draggable=True, collapsible=True, deletable=False),
modules.RecentActions(
_('Recent Actions'),
include_list=self.get_app_content_types(),
limit=5
)
]
def init_with_context(self, context):
"""
Use this method if you need to access the request context.
"""
return super(CustomAppIndexDashboard, self).init_with_context(context)

View File

@ -127,20 +127,18 @@ TEMPLATE_DIRS = (
TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS + (
'sekizai.context_processors.sekizai',
'django.core.context_processors.request', # needed by grappelli
'django.core.context_processors.request', # needed by django-admin-tools
)
INSTALLED_APPS = (
# note: 'south' will be added here only if database is not sqlite (see below)
#
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'grappelli.dashboard',
'grappelli',
'django.contrib.admin',
'django.contrib.formtools',
#'django.contrib.admindocs',
'sekizai',
@ -152,6 +150,10 @@ INSTALLED_APPS = (
'polynum.editor',
'polynum.delegation',
'polynum.oai',
# admin
'admin_tools',
'admin_tools.dashboard',
'django.contrib.admin',
)
# From http://django-crispy-forms.readthedocs.org/en/d-0/install.html
@ -194,10 +196,12 @@ AUTHENTICATION_BACKENDS = ('polynum.base.backends.ModelBackend',)
AUTH_PROFILE_MODULE = 'base.PolynumProfile'
CAS_SERVER_URL = None # 'https://www.ent.dauphine.fr/cas/'
# grappelli -- see http://readthedocs.org/docs/django-grappelli
GRAPPELLI_ADMIN_TITLE = 'Administration de PolyNum'
GRAPPELLI_INDEX_DASHBOARD = 'polynum.dashboard.CustomIndexDashboard'
# django-admin-tools
# see http://django-admin-tools.readthedocs.org/en/latest/customization.html
ADMIN_TOOLS_INDEX_DASHBOARD = 'polynum.dashboard.CustomIndexDashboard'
ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'polynum.dashboard.CustomAppIndexDashboard'
# Session cookies
SESSION_COOKIE_AGE = 3600*24 # 1 day
SESSION_EXPIRE_AT_BROWSER_CLOSE = True

View File

@ -23,7 +23,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_tools/', include('admin_tools.urls')), # django-admin-tools
url(r'^admin/', include(admin.site.urls)),
url(r'^request/',

View File

@ -4,7 +4,7 @@ south
django-crispy-forms
django-sekizai
https://bitbucket.org/cpcc/django-cas/get/tip.tar.gz
django-grappelli
django-admin-tools
pypdf
flup
django-debug-toolbar

View File

@ -22,8 +22,8 @@ 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-grappelli >= 2.4', # not in pypi => pip install git+https://github.com/sehmaschine/django-grappelli@grappelli_2_4
'django-cas >= 2.1.1',
'django-admin-tools',
'flup',
'psycopg2',
],