1 # -*- encoding: utf-8 -*-
7 from djangorecipe
.boilerplate
import versions
8 from djangorecipe
.recipe
import Recipe
as OriginalDjangoRecipe
9 from boilerplate
import *
11 djangorecipe
.boilerplate
.versions
['1.2']['settings'] = auf_settings_template
12 djangorecipe
.boilerplate
.versions
['1.2']['urls'] = auf_urls_template
13 djangorecipe
.boilerplate
.versions
['1.2']['production_settings'] = auf_production_settings
14 djangorecipe
.boilerplate
.versions
['1.2']['development_settings'] = auf_development_settings
17 class Recipe(OriginalDjangoRecipe
):
22 location
= self
.options
['location']
23 base_dir
= self
.buildout
['buildout']['directory']
24 self
.options
['project_name'] = os
.path
.basename(base_dir
)
26 project_dir
= os
.path
.join(base_dir
, self
.options
['project'])
28 extra_paths
= self
.get_extra_paths()
29 requirements
, ws
= self
.egg
.working_set(['djangorecipe'])
33 # Create the Django management script
34 script_paths
.extend(self
.create_manage_script(extra_paths
, ws
))
36 # Create the test runner
37 script_paths
.extend(self
.create_test_runner(extra_paths
, ws
))
39 # Make the wsgi and fastcgi scripts if enabled
40 script_paths
.extend(self
.make_scripts(extra_paths
, ws
))
42 # Create default settings if we haven't got a project
43 # egg specified, and if it doesn't already exist
44 if not self
.options
.get('projectegg'):
45 if not os
.path
.exists(project_dir
):
46 self
.create_project(project_dir
)
49 'Skipping creating of project: %(project)s since '
50 'it exists' % self
.options
)
52 return script_paths
+ [location
]
54 def create_project(self
, project_dir
):
55 super(Recipe
, self
).create_project(project_dir
)
57 # fichier de configuration de base de données
58 self
.create_file(os
.path
.join(project_dir
, 'conf.py'), conf_file
, self
.options
)
59 self
.create_file(os
.path
.join(project_dir
, 'conf.py.edit'), conf_file
, self
.options
)
60 self
.create_file(os
.path
.join(project_dir
, 'dashboard.py'), dashboard_file
, self
.options
)
62 os
.mkdir(os
.path
.join(project_dir
, 'media', 'css'))
63 os
.mkdir(os
.path
.join(project_dir
, 'media', 'images'))
64 os
.mkdir(os
.path
.join(project_dir
, 'media', 'js'))
66 # copie des medias django-admin-tools
67 requirements
, ws
= self
.egg
.working_set(['djangorecipe'])
68 req
= pkg_resources
.Requirement
.parse('django-admin-tools')
69 src
= os
.path
.join(ws
.find(req
).location
, 'admin_tools', 'media', 'admin_tools')
70 dst
= os
.path
.join(project_dir
, 'media', 'admin_tools')
71 shutil
.copytree(src
, dst
)
73 # copier les medias de auf.django.skin
74 req
= pkg_resources
.Requirement
.parse('auf.django.skin')
75 src
= os
.path
.join(ws
.find(req
).location
, 'auf', 'django', 'skin', 'media', 'skin')
76 dst
= os
.path
.join(project_dir
, 'media', 'skin')
77 shutil
.copytree(src
, dst
)
79 # copier les medias de Django
80 req
= pkg_resources
.Requirement
.parse('django')
81 src
= os
.path
.join(ws
.find(req
).location
, 'django', 'contrib', 'admin', 'media')
82 dst
= os
.path
.join(project_dir
, 'media', 'django')
83 shutil
.copytree(src
, dst
)