Commit | Line | Data |
---|---|---|
4be9d9da OL |
1 | # -*- encoding: utf-8 -*- |
2 | ||
3 | import os | |
4 | import shutil | |
5 | import pkg_resources | |
6 | import djangorecipe | |
7 | from djangorecipe.boilerplate import versions | |
8 | from djangorecipe.recipe import Recipe as OriginalDjangoRecipe | |
9 | from boilerplate import * | |
10 | ||
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 | |
15 | ||
16 | ||
17 | class Recipe(OriginalDjangoRecipe): | |
18 | ||
19 | def install(self): | |
20 | """ | |
21 | """ | |
22 | location = self.options['location'] | |
23 | base_dir = self.buildout['buildout']['directory'] | |
24 | self.options['project_name'] = os.path.basename(base_dir) | |
25 | ||
26 | project_dir = os.path.join(base_dir, self.options['project']) | |
27 | ||
28 | extra_paths = self.get_extra_paths() | |
29 | requirements, ws = self.egg.working_set(['djangorecipe']) | |
30 | ||
31 | script_paths = [] | |
32 | ||
33 | # Create the Django management script | |
34 | script_paths.extend(self.create_manage_script(extra_paths, ws)) | |
35 | ||
36 | # Create the test runner | |
37 | script_paths.extend(self.create_test_runner(extra_paths, ws)) | |
38 | ||
39 | # Make the wsgi and fastcgi scripts if enabled | |
40 | script_paths.extend(self.make_scripts(extra_paths, ws)) | |
41 | ||
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) | |
47 | else: | |
48 | self.log.info( | |
49 | 'Skipping creating of project: %(project)s since ' | |
50 | 'it exists' % self.options) | |
51 | ||
52 | return script_paths + [location] | |
53 | ||
54 | def create_project(self, project_dir): | |
55 | super(Recipe, self).create_project(project_dir) | |
56 | ||
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) | |
61 | ||
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')) | |
65 | ||
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) | |
72 | ||
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) | |
78 | ||
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) | |
84 | ||
85 | ||
86 |