move
authorOlivier Larchevêque <olivier.larcheveque@gmail.com>
Tue, 20 Sep 2011 19:25:16 +0000 (15:25 -0400)
committerOlivier Larchevêque <olivier.larcheveque@gmail.com>
Tue, 20 Sep 2011 19:25:16 +0000 (15:25 -0400)
.gitignore [new file with mode: 0644]
CHANGES [new file with mode: 0644]
auf/__init__.py [new file with mode: 0644]
auf/recipe/__init__.py [new file with mode: 0644]
auf/recipe/django/__init__.py [new file with mode: 0644]
auf/recipe/django/boilerplate.py [new file with mode: 0644]
auf/recipe/django/recipe.py [new file with mode: 0644]
setup.cfg [new file with mode: 0644]
setup.py [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..499a075
--- /dev/null
@@ -0,0 +1,4 @@
+*.pyc
+*egg-info
+build
+dist
diff --git a/CHANGES b/CHANGES
new file mode 100644 (file)
index 0000000..6ef9933
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,16 @@
+0.19
+====
+
+* ajout du handler404 pour géré par auf.django.skin
+
+0.18
+====
+
+* report squelette 0.15
+
+* prise en compte du djangorecipe 0.99 qui distingue django 1.2 et 1.3
+
+0.17
+====
+
+* ajustement avec la djangorecipe 0.99 qui ne prend plus de version
diff --git a/auf/__init__.py b/auf/__init__.py
new file mode 100644 (file)
index 0000000..35cf25b
--- /dev/null
@@ -0,0 +1,5 @@
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except:
+    # bootstrapping
+    pass
diff --git a/auf/recipe/__init__.py b/auf/recipe/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/auf/recipe/django/__init__.py b/auf/recipe/django/__init__.py
new file mode 100644 (file)
index 0000000..4214e62
--- /dev/null
@@ -0,0 +1,3 @@
+# -*- encoding: utf-8 -*-
+
+from recipe import Recipe
diff --git a/auf/recipe/django/boilerplate.py b/auf/recipe/django/boilerplate.py
new file mode 100644 (file)
index 0000000..701a8a0
--- /dev/null
@@ -0,0 +1,203 @@
+# -*- encoding: utf-8 -*-
+
+################################################################################
+# SETTINGS
+################################################################################
+
+conf_file = '''# -*- encoding: utf-8 -*
+
+DATABASE_ENGINE = 'mysql'    # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+DATABASE_NAME = ''
+DATABASE_USER = ''           # Not used with sqlite3.
+DATABASE_PASSWORD = ''       # Not used with sqlite3.
+DATABASE_HOST = ''           # Set to empty string for localhost. Not used with sqlite3.
+DATABASE_PORT = ''           # Set to empty string for default. Not used with sqlite3.
+'''
+
+dashboard_file ='''# -*- encoding: utf-8 -*
+
+"""
+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.
+
+To activate your index dashboard add the following to your settings.py::
+    ADMIN_TOOLS_INDEX_DASHBOARD = 'SIGMA.dashboard.CustomIndexDashboard'
+
+And to activate the app index dashboard::
+    ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'SIGMA.dashboard.CustomAppIndexDashboard'
+"""
+
+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
+
+
+class CustomIndexDashboard(Dashboard):
+    """
+    Custom index dashboard for SIGMA.
+    """
+    def init_with_context(self, context):
+        site_name = get_admin_site_name(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))
+'''
+
+
+auf_urls_template = '''# -*- encoding: utf-8 -*
+from django.conf.urls.defaults import patterns, include, handler500, handler404, url
+from django.conf import settings
+from django.contrib import admin
+
+admin.autodiscover()
+
+handler404
+handler500 # Pyflakes
+
+urlpatterns = patterns(
+    '',
+    ######## page d'accueil de demo ######
+    (r'^$', 'auf.django.skin.views.demo'),
+    ######################################
+    url(r'^admin_tools/', include('admin_tools.urls')),
+    (r'^admin/', include(admin.site.urls)),
+    (r'^connexion/$', 'django.contrib.auth.views.login'),
+    (r'^deconnexion/$', 'django.contrib.auth.views.logout'),
+
+)
+
+if settings.DEBUG:
+    urlpatterns += patterns('',
+        (r'^media/(?P<path>.*)$', 'django.views.static.serve',
+         {'document_root': settings.MEDIA_ROOT}),
+    )
+'''
+
+auf_settings_template = '''# -*- encoding: utf-8 -*-
+
+import os
+import socket
+from conf import *
+
+# Rapports d'erreurs
+EMAIL_SUBJECT_PREFIX = '[%(project_name)s - %%s] ' %% socket.gethostname()
+ADMINS = (
+    ('Équipe ARI-SI', 'developpeurs@ca.auf.org'),
+)
+
+MANAGERS = ADMINS
+
+TIME_ZONE = 'Canada/Montreal'
+
+LANGUAGE_CODE = 'fr-ca'
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+MEDIA_ROOT = %(media_root)s
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash if there is a path component (optional in other cases).
+# Examples: "http://media.lawrence.com", "http://example.com/media/"
+MEDIA_URL = '/media/'
+
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+# Examples: "http://foo.com/media/", "/media/".
+ADMIN_MEDIA_PREFIX = '/media/django/'
+
+# Don't share this with anybody.
+SECRET_KEY = '%(secret)s'
+
+MIDDLEWARE_CLASSES = (
+    'django.middleware.common.CommonMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.middleware.doc.XViewMiddleware',
+)
+
+ROOT_URLCONF = '%(urlconf)s'
+
+
+INSTALLED_APPS = (
+    'auf.django.skin',
+    'admin_tools',
+    'admin_tools.theming',
+    'admin_tools.menu',
+    'admin_tools.dashboard',
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.admin',
+    'south',
+)
+
+TEMPLATE_CONTEXT_PROCESSORS = (
+    'django.core.context_processors.auth',
+    'django.core.context_processors.debug',
+    'django.core.context_processors.i18n',
+    'django.core.context_processors.media',
+    'django.contrib.messages.context_processors.messages',
+    'django.core.context_processors.request',
+    'auf.django.skin.context_processors.auf',
+)
+
+
+TEMPLATE_LOADERS = (
+    'django.template.loaders.filesystem.load_template_source',
+    'django.template.loaders.app_directories.load_template_source',
+)
+
+TEMPLATE_DIRS = (
+    os.path.join(os.path.dirname(__file__), "templates"),
+)
+
+SOUTH_TESTS_MIGRATE = False
+
+ADMIN_TOOLS_INDEX_DASHBOARD = 'project.dashboard.CustomIndexDashboard'
+
+'''
+
+################################################################################
+# DEVELOPPEMENT
+################################################################################
+auf_development_settings = '''# -*- encoding: utf-8 -*-
+
+from %(project)s.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
+'''
+
+################################################################################
+# PRODUCTION
+################################################################################
+auf_production_settings = ''' # -*- 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)s.settings import *
+'''
diff --git a/auf/recipe/django/recipe.py b/auf/recipe/django/recipe.py
new file mode 100644 (file)
index 0000000..5e90a90
--- /dev/null
@@ -0,0 +1,86 @@
+# -*- encoding: utf-8 -*-
+
+import os
+import shutil
+import pkg_resources
+import djangorecipe
+from djangorecipe.boilerplate import versions
+from djangorecipe.recipe import Recipe as OriginalDjangoRecipe
+from boilerplate import *
+
+djangorecipe.boilerplate.versions['1.2']['settings'] = auf_settings_template
+djangorecipe.boilerplate.versions['1.2']['urls'] = auf_urls_template
+djangorecipe.boilerplate.versions['1.2']['production_settings'] = auf_production_settings
+djangorecipe.boilerplate.versions['1.2']['development_settings'] = auf_development_settings
+
+
+class Recipe(OriginalDjangoRecipe):
+
+    def install(self):
+        """
+        """
+        location = self.options['location']
+        base_dir = self.buildout['buildout']['directory']
+        self.options['project_name'] = os.path.basename(base_dir)
+
+        project_dir = os.path.join(base_dir, self.options['project'])
+
+        extra_paths = self.get_extra_paths()
+        requirements, ws = self.egg.working_set(['djangorecipe'])
+
+        script_paths = []
+
+        # Create the Django management script
+        script_paths.extend(self.create_manage_script(extra_paths, ws))
+
+        # Create the test runner
+        script_paths.extend(self.create_test_runner(extra_paths, ws))
+
+        # Make the wsgi and fastcgi scripts if enabled
+        script_paths.extend(self.make_scripts(extra_paths, ws))
+
+        # Create default settings if we haven't got a project
+        # egg specified, and if it doesn't already exist
+        if not self.options.get('projectegg'):
+            if not os.path.exists(project_dir):
+                self.create_project(project_dir)
+            else:
+                self.log.info(
+                    'Skipping creating of project: %(project)s since '
+                    'it exists' % self.options)
+
+        return script_paths + [location]
+
+    def create_project(self, project_dir):
+        super(Recipe, self).create_project(project_dir)
+
+        # fichier de configuration de base de données
+        self.create_file(os.path.join(project_dir, 'conf.py'), conf_file, self.options)
+        self.create_file(os.path.join(project_dir, 'conf.py.edit'), conf_file, self.options)
+        self.create_file(os.path.join(project_dir, 'dashboard.py'), dashboard_file, self.options)
+
+        os.mkdir(os.path.join(project_dir, 'media', 'css'))
+        os.mkdir(os.path.join(project_dir, 'media', 'images'))
+        os.mkdir(os.path.join(project_dir, 'media', 'js'))
+
+        # copie des medias django-admin-tools
+        requirements, ws = self.egg.working_set(['djangorecipe'])
+        req = pkg_resources.Requirement.parse('django-admin-tools')
+        src = os.path.join(ws.find(req).location, 'admin_tools', 'media', 'admin_tools')
+        dst = os.path.join(project_dir, 'media', 'admin_tools')
+        shutil.copytree(src, dst)
+
+        # copier les medias de auf.django.skin
+        req = pkg_resources.Requirement.parse('auf.django.skin')
+        src = os.path.join(ws.find(req).location, 'auf', 'django', 'skin', 'media', 'skin')
+        dst = os.path.join(project_dir, 'media', 'skin')
+        shutil.copytree(src, dst)
+
+        # copier les medias de Django
+        req = pkg_resources.Requirement.parse('django')
+        src = os.path.join(ws.find(req).location, 'django', 'contrib', 'admin', 'media')
+        dst = os.path.join(project_dir, 'media', 'django')
+        shutil.copytree(src, dst)
+
+
+
diff --git a/setup.cfg b/setup.cfg
new file mode 100644 (file)
index 0000000..01bb954
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,3 @@
+[egg_info]
+tag_build = dev
+tag_svn_revision = true
diff --git a/setup.py b/setup.py
new file mode 100644 (file)
index 0000000..79e1958
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,32 @@
+from setuptools import setup, find_packages
+import sys, os
+
+name = 'auf.recipe.django'
+version = '0.19'
+
+setup(name=name,
+      version=version,
+      description="Recette Django AUF avec nos pratiques internes",
+      long_description="""\
+""",
+      classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
+      keywords='',
+      author='Olivier Larchev\xc3\xaaque',
+      author_email='olivier.larcheveque@auf.org',
+      url='http://pypi.auf.org/%s' % name,
+      license='GPL',
+      namespace_packages = ['auf'],
+      packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
+      include_package_data=True,
+      zip_safe=False,
+      install_requires=[
+        'zc.buildout',
+        'zc.recipe.egg',
+        'djangorecipe',
+      ],
+      entry_points="""
+      # -*- Entry points: -*-
+      [zc.buildout]
+      default = auf.recipe.django:Recipe
+      """,
+      )