orioai_django cartographie
authorDavin Baragiotta <davin.baragiotta@auf.org>
Mon, 16 Jul 2012 21:10:40 +0000 (17:10 -0400)
committerDavin BARAGIOTTA <davin.baragiotta@auf.org>
Mon, 16 Jul 2012 21:10:40 +0000 (17:10 -0400)
13 files changed:
projets/cartographie/orioai_django/.gitignore [new file with mode: 0644]
projets/cartographie/orioai_django/bootstrap.py [new file with mode: 0644]
projets/cartographie/orioai_django/buildout.cfg [new file with mode: 0644]
projets/cartographie/orioai_django/devel.cfg [new file with mode: 0644]
projets/cartographie/orioai_django/project/__init__.py [new file with mode: 0644]
projets/cartographie/orioai_django/project/conf.py.edit [new file with mode: 0644]
projets/cartographie/orioai_django/project/dashboard.py [new file with mode: 0644]
projets/cartographie/orioai_django/project/development.py [new file with mode: 0644]
projets/cartographie/orioai_django/project/mysql_ram.py [new file with mode: 0644]
projets/cartographie/orioai_django/project/production.py [new file with mode: 0644]
projets/cartographie/orioai_django/project/settings.py [new file with mode: 0644]
projets/cartographie/orioai_django/project/urls.py [new file with mode: 0644]
projets/cartographie/orioai_django/versions.cfg [new file with mode: 0644]

diff --git a/projets/cartographie/orioai_django/.gitignore b/projets/cartographie/orioai_django/.gitignore
new file mode 100644 (file)
index 0000000..c8c4403
--- /dev/null
@@ -0,0 +1,31 @@
+# binaires
+*.pyc
+*.pyo
+
+# Fichier temporaires:
+.*.swp
+*~
+\#*#
+src/*
+
+# DB de dev
+*.db
+
+# restants de merge
+*.orig
+*.rej
+
+# Configuration du projet - par environnement
+conf.py
+django.wsgi
+
+# buildout
+.installed.cfg
+bin
+develop-eggs
+downloads
+eggs
+log
+parts
+tmp
+sitestatic
diff --git a/projets/cartographie/orioai_django/bootstrap.py b/projets/cartographie/orioai_django/bootstrap.py
new file mode 100644 (file)
index 0000000..7728587
--- /dev/null
@@ -0,0 +1,77 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+is_jython = sys.platform.startswith('java')
+
+try:
+    import pkg_resources
+except ImportError:
+    ez = {}
+    exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+                         ).read() in ez
+    ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+    import pkg_resources
+
+if sys.platform == 'win32':
+    def quote(c):
+        if ' ' in c:
+            return '"%s"' % c # work around spawn lamosity on windows
+        else:
+            return c
+else:
+    def quote (c):
+        return c
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+ws  = pkg_resources.working_set
+
+if is_jython:
+    import subprocess
+    
+    assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd', 
+           quote(tmpeggs), 'zc.buildout'], 
+           env=dict(os.environ,
+               PYTHONPATH=
+               ws.find(pkg_resources.Requirement.parse('setuptools')).location
+               ),
+           ).wait() == 0
+
+else:
+    assert os.spawnle(
+        os.P_WAIT, sys.executable, quote (sys.executable),
+        '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout',
+        dict(os.environ,
+            PYTHONPATH=
+            ws.find(pkg_resources.Requirement.parse('setuptools')).location
+            ),
+        ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
diff --git a/projets/cartographie/orioai_django/buildout.cfg b/projets/cartographie/orioai_django/buildout.cfg
new file mode 100644 (file)
index 0000000..8801c03
--- /dev/null
@@ -0,0 +1,25 @@
+
+[buildout]
+extends = versions.cfg
+extensions = buildout-versions
+buildout_versions_file = versions.cfg
+versions = versions
+unzip = true
+parts = django
+versions = versions
+
+find-links = http://pypi.auf.org/simple/auf.recipe.django
+
+eggs =
+    auf.recipe.django
+    django
+    south
+    django-admin-tools
+
+[django]  
+recipe = auf.recipe.django 
+wsgi=true  
+settings=production 
+project = project
+extra-paths = project
+eggs = ${buildout:eggs}
diff --git a/projets/cartographie/orioai_django/devel.cfg b/projets/cartographie/orioai_django/devel.cfg
new file mode 100644 (file)
index 0000000..dfece77
--- /dev/null
@@ -0,0 +1,9 @@
+[buildout]
+extends=buildout.cfg
+
+[django]
+wsgi=false
+settings=development
+eggs = ${buildout:eggs}
+    django-debug-toolbar
+
diff --git a/projets/cartographie/orioai_django/project/__init__.py b/projets/cartographie/orioai_django/project/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/projets/cartographie/orioai_django/project/conf.py.edit b/projets/cartographie/orioai_django/project/conf.py.edit
new file mode 100644 (file)
index 0000000..023d8de
--- /dev/null
@@ -0,0 +1,13 @@
+# -*- encoding: utf-8 -*
+
+DATABASES = {
+    'default': {
+        #'ENGINE': 'django.db.backends.mysql',
+        'ENGINE': 'django.db.backends.sqlite3',
+        'NAME': 'db.sqlite',
+        'USER': '',
+        'PASSWORD': '',
+        'HOST': '',
+        'PORT': '',
+    }
+}
diff --git a/projets/cartographie/orioai_django/project/dashboard.py b/projets/cartographie/orioai_django/project/dashboard.py
new file mode 100644 (file)
index 0000000..649674a
--- /dev/null
@@ -0,0 +1,27 @@
+# -*- encoding: utf-8 -*
+
+from django.utils.translation import ugettext_lazy as _
+from admin_tools.dashboard import modules, Dashboard
+
+
+class CustomIndexDashboard(Dashboard):
+    """
+    Custom index dashboard
+    """
+
+    def init_with_context(self, context):
+
+        # append an app list module for "Applications"
+        self.children.append(modules.AppList(
+            _('Applications'),
+            exclude=('django.contrib.*',),
+        ))
+
+        # append an app list module for "Administration"
+        self.children.append(modules.AppList(
+            _('Administration'),
+            models=('django.contrib.*',),
+        ))
+
+        # append a recent actions module
+        self.children.append(modules.RecentActions(_('Recent Actions'), 5))
diff --git a/projets/cartographie/orioai_django/project/development.py b/projets/cartographie/orioai_django/project/development.py
new file mode 100644 (file)
index 0000000..ce0c0f8
--- /dev/null
@@ -0,0 +1,13 @@
+# -*- encoding: utf-8 -*-
+
+from project.settings import *
+DEBUG=True
+TEMPLATE_DEBUG=DEBUG
+
+# Décommentez ces lignes pour activer la debugtoolbar
+#INTERNAL_IPS = ('127.0.0.1',)
+#INSTALLED_APPS += ('debug_toolbar',)
+#MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
+
+AUTH_PASSWORD_REQUIRED = False
+
diff --git a/projets/cartographie/orioai_django/project/mysql_ram.py b/projets/cartographie/orioai_django/project/mysql_ram.py
new file mode 100644 (file)
index 0000000..71e73e4
--- /dev/null
@@ -0,0 +1,47 @@
+#encoding UTF-8
+# -*- encoding: utf-8 -*-
+
+"""
+Configuration du site pour faire fonctionner les tests unitaires avec
+MySQL en RAM.
+"""
+
+from production import *
+
+DATABASES['default']['HOST'] = '/var/run/mysqld/mysqld-ram.sock'
+
+host = "mysql --socket=%s -uroot -e" % DATABASES['default']['HOST']
+db = "unittests_%s" % DATABASES['default']['NAME']
+DATABASES['default']['NAME'] = db
+DATABASES['default']['TEST_NAME'] = db
+user = DATABASES['default']['USER']
+pwd = DATABASES['default']['PASSWORD']
+
+cmd_creer_bd = "%(host)s \
+        'CREATE DATABASE %(db)s;'" % {
+                'host': host,
+                'db': db,
+                }
+
+cmd_creer_user = """%(host)s \
+        "GRANT USAGE ON *.* TO %(user)s@localhost \
+        IDENTIFIED BY '%(pwd)s';" """ % {
+                'host': host,
+                'user': user,
+                'pwd': pwd,
+                }
+
+cmd_creer_privileges = "%(host)s \
+        'GRANT ALL PRIVILEGES ON *.* TO %(user)s@localhost ;'" % {
+                'host': host,
+                'user': user,
+                }
+
+
+# La bd non préfixée par "test_" a besoin d'exister pour lancer les tests.
+# Cette commande ne modifie rien, si la table existe déjà.
+os.system(cmd_creer_bd)
+
+# Création de l'accès à la base "test_xxx" en fonction de conf.py
+os.system(cmd_creer_user)
+os.system(cmd_creer_privileges)
diff --git a/projets/cartographie/orioai_django/project/production.py b/projets/cartographie/orioai_django/project/production.py
new file mode 100644 (file)
index 0000000..ee6bb2e
--- /dev/null
@@ -0,0 +1,9 @@
+# -*- encoding: utf-8 -*-
+
+# En production, rediriger la sortie terminal on disponible en WSGI
+# vers la sortie fichier errorlog.
+import sys
+sys.stdout = sys.stderr
+
+from project.settings import *
+
diff --git a/projets/cartographie/orioai_django/project/settings.py b/projets/cartographie/orioai_django/project/settings.py
new file mode 100644 (file)
index 0000000..f237523
--- /dev/null
@@ -0,0 +1,62 @@
+# -*- encoding: utf-8 -*-
+
+import os
+import socket
+from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as \
+        DEFAULT_TEMPLATE_CONTEXT_PROCESSORS
+
+# Rapports d'erreurs
+SERVER_EMAIL = 'ne-pas-repondre@auf.org'
+EMAIL_SUBJECT_PREFIX = '[orioai_django - %s] ' % socket.gethostname()
+ADMINS = (
+    ('Équipe ARI-SI', 'developpeurs@ca.auf.org'),
+)
+
+MANAGERS = ADMINS
+
+TIME_ZONE = 'America/Montreal'
+
+LANGUAGE_CODE = 'fr-ca'
+
+PROJECT_ROOT = os.path.dirname(__file__)
+SITE_ROOT = os.path.dirname(PROJECT_ROOT)
+
+MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
+MEDIA_URL = '/media/'
+
+STATIC_ROOT = os.path.join(SITE_ROOT, 'sitestatic')
+STATIC_URL = '/static/'
+STATICFILES_DIRS = (
+    os.path.join(PROJECT_ROOT, 'static'),
+)
+
+ROOT_URLCONF = 'project.urls'
+
+INSTALLED_APPS = (
+    'admin_tools',
+    'admin_tools.theming',
+    'admin_tools.menu',
+    'admin_tools.dashboard',
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.admin',
+    'django.contrib.staticfiles',
+    'south',
+)
+
+TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_TEMPLATE_CONTEXT_PROCESSORS + (
+    'django.core.context_processors.static',
+    'django.core.context_processors.request',
+)
+
+
+TEMPLATE_DIRS = (
+    os.path.join(os.path.dirname(__file__), "templates"),
+)
+
+SOUTH_TESTS_MIGRATE = False
+
+ADMIN_TOOLS_INDEX_DASHBOARD = 'project.dashboard.CustomIndexDashboard'
+
+from conf import *
diff --git a/projets/cartographie/orioai_django/project/urls.py b/projets/cartographie/orioai_django/project/urls.py
new file mode 100644 (file)
index 0000000..c29c8f2
--- /dev/null
@@ -0,0 +1,27 @@
+# -*- encoding: utf-8 -*
+
+from django.conf.urls.defaults import patterns, include, \
+        handler500, handler404, url
+from django.conf import settings
+from django.contrib import admin
+from django.contrib.staticfiles.urls import staticfiles_urlpatterns
+
+admin.autodiscover()
+
+handler404
+handler500 # Pyflakes
+
+urlpatterns = patterns(
+    '',
+    # admin
+    url(r'^admin_tools/', include('admin_tools.urls')),
+    (r'^admin/', include(admin.site.urls)),
+)
+
+if settings.DEBUG:
+    urlpatterns += staticfiles_urlpatterns()
+    urlpatterns += patterns('',
+        url(r'^media/(?P<path>.*)$',
+        'django.views.static.serve', {
+        'document_root': settings.MEDIA_ROOT, }),
+        )
diff --git a/projets/cartographie/orioai_django/versions.cfg b/projets/cartographie/orioai_django/versions.cfg
new file mode 100644 (file)
index 0000000..96f915b
--- /dev/null
@@ -0,0 +1,3 @@
+[versions]
+Django = 1.3.1
+django-admin-tools = 0.4.1