bouture 2026.11.19.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 treto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.4
2
+ Name: bouture
3
+ Version: 2026.11.19.1
4
+ Summary: Crée un nouveau site à partir de Sites Conformes, comme on bouture une plante.
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Dist: django>=5.2
8
+ Requires-Dist: questionary>=2.1
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+
12
+ # bouture
13
+
14
+ Crée un nouveau site à partir de [Sites Conformes][sc] : un projet Django/Wagtail minimal, déjà configuré, sur le modèle de
15
+ `wagtail start`.
16
+
17
+ [sc]: https://github.com/numerique-gouv/sites-conformes
18
+
19
+ ```sh
20
+ uvx bouture start monsite
21
+ cd monsite
22
+ uv run python manage.py migrate
23
+ uv run python manage.py collectstatic --noinput
24
+ uv run python manage.py create_starter_pages
25
+ uv run python manage.py createsuperuser
26
+ uv run python manage.py runserver
27
+ ```
28
+
29
+ La commande pose quelques questions : titre et sous-titre du site, intitulé
30
+ officiel, base de données, puis les fonctionnalités à activer. Le
31
+ `config/settings.py` généré ne contient que les réglages des fonctionnalités
32
+ choisies :
33
+
34
+ - connexion à l’administration avec ProConnect ;
35
+ - double authentification obligatoire ;
36
+ - stockage des médias : fichiers locaux, base de données ou S3 ;
37
+ - langues en plus du français ;
38
+ - suivi des erreurs avec Sentry.
39
+
40
+ `--no-input` passe les questions et crée le projet le plus simple : SQLite,
41
+ fichiers locaux, aucune de ces fonctionnalités.
42
+
43
+ ## Développer
44
+
45
+ ```sh
46
+ uv run pytest
47
+ ```
48
+
49
+ Les tests génèrent des projets et lancent `check` et `migrate` dessus avec le
50
+ paquet `sites-conformes` installé.
@@ -0,0 +1,39 @@
1
+ # bouture
2
+
3
+ Crée un nouveau site à partir de [Sites Conformes][sc] : un projet Django/Wagtail minimal, déjà configuré, sur le modèle de
4
+ `wagtail start`.
5
+
6
+ [sc]: https://github.com/numerique-gouv/sites-conformes
7
+
8
+ ```sh
9
+ uvx bouture start monsite
10
+ cd monsite
11
+ uv run python manage.py migrate
12
+ uv run python manage.py collectstatic --noinput
13
+ uv run python manage.py create_starter_pages
14
+ uv run python manage.py createsuperuser
15
+ uv run python manage.py runserver
16
+ ```
17
+
18
+ La commande pose quelques questions : titre et sous-titre du site, intitulé
19
+ officiel, base de données, puis les fonctionnalités à activer. Le
20
+ `config/settings.py` généré ne contient que les réglages des fonctionnalités
21
+ choisies :
22
+
23
+ - connexion à l’administration avec ProConnect ;
24
+ - double authentification obligatoire ;
25
+ - stockage des médias : fichiers locaux, base de données ou S3 ;
26
+ - langues en plus du français ;
27
+ - suivi des erreurs avec Sentry.
28
+
29
+ `--no-input` passe les questions et crée le projet le plus simple : SQLite,
30
+ fichiers locaux, aucune de ces fonctionnalités.
31
+
32
+ ## Développer
33
+
34
+ ```sh
35
+ uv run pytest
36
+ ```
37
+
38
+ Les tests génèrent des projets et lancent `check` et `migrate` dessus avec le
39
+ paquet `sites-conformes` installé.
File without changes
@@ -0,0 +1,285 @@
1
+ """
2
+ Entry point of the `bouture` command.
3
+
4
+ `bouture start <name>` creates a minimal Django/Wagtail project using the
5
+ sites-conformes package, the way `wagtail start` does: Django's `startproject` with our template.
6
+ """
7
+
8
+ import json
9
+ import sys
10
+ import time
11
+ from html import escape
12
+ from pathlib import Path
13
+
14
+ from django.conf.locale import LANG_INFO
15
+ from django.core.management.commands.startproject import Command as StartProject
16
+ from django.core.management.utils import get_random_secret_key
17
+
18
+ # The version the project template is written for and tested against (see pyproject.toml).
19
+ SITES_CONFORMES_VERSION = "4.4.0"
20
+
21
+ USAGE = "Usage : bouture start <nom_du_projet> [dossier]"
22
+
23
+ # Offered as checkboxes; any other language is one more line in LANGUAGES of the settings.
24
+ EXTRA_LANGUAGES = ("en", "de", "es", "it", "pt", "nl")
25
+ # What `--no-input` generates: the smallest working project.
26
+ DEFAULT_FEATURES = {"proconnect": False, "two_fa": False, "media_storage": "files", "languages": [], "sentry": False}
27
+
28
+ # Values to fill in, appended to the `.env` of the project for the chosen features.
29
+ ENV_PROCONNECT = """
30
+ # ProConnect : identifiants fournis par https://partenaires.proconnect.gouv.fr/
31
+ PROCONNECT_CLIENT_ID=
32
+ PROCONNECT_CLIENT_SECRET=
33
+ PROCONNECT_DOMAIN=fca.integ01.dev-agentconnect.fr
34
+ """
35
+ ENV_S3 = """
36
+ # Stockage S3 des médias
37
+ S3_HOST=
38
+ S3_KEY_ID=
39
+ S3_KEY_SECRET=
40
+ S3_BUCKET_NAME=
41
+ S3_BUCKET_REGION=
42
+ S3_LOCATION=medias
43
+ """
44
+ ENV_SENTRY = """
45
+ # Sentry : sans DSN, rien n’est envoyé
46
+ SENTRY_DSN=
47
+ SENTRY_ENVIRONMENT=development
48
+ """
49
+
50
+ # Keep in sync with project_template/README.md.
51
+ NEXT_STEPS = """
52
+ Pour lancer le site :
53
+
54
+ cd {target}
55
+ uv run python manage.py migrate
56
+ uv run python manage.py collectstatic --noinput
57
+ uv run python manage.py create_starter_pages
58
+ uv run python manage.py createsuperuser
59
+ uv run python manage.py runserver
60
+
61
+ Le site sera sur http://localhost:8000/ et l’administration sur http://localhost:8000/cms-admin/
62
+ """
63
+
64
+
65
+ class Command(StartProject):
66
+ help = "Crée un projet Sites Conformes minimal."
67
+
68
+ def add_arguments(self, parser) -> None:
69
+ super().add_arguments(parser)
70
+ parser.add_argument(
71
+ "--no-input",
72
+ action="store_false",
73
+ dest="interactive",
74
+ help="Ne pose aucune question.",
75
+ )
76
+
77
+ def ask_customisations(self, name: str) -> dict:
78
+ # Only needed here, not by the sites that install the package.
79
+ import questionary
80
+
81
+ style = questionary.Style(
82
+ [
83
+ ("qmark", "fg:#6a6af4 bold"),
84
+ ("question", "bold"),
85
+ ("answer", "fg:#6a6af4"),
86
+ ("pointer", "fg:#6a6af4 bold"),
87
+ ("highlighted", "fg:#6a6af4"),
88
+ ("selected", "fg:#6a6af4"),
89
+ ("instruction", "fg:#888888"),
90
+ ]
91
+ )
92
+
93
+ def ask(prompt, question: str, **kwargs):
94
+ # unsafe_ask: let Ctrl+C reach handle(), which stops before creating anything.
95
+ return prompt(question, style=style, qmark="?", **kwargs).unsafe_ask()
96
+
97
+ self.stdout.write("")
98
+ animate_minitel()
99
+ questionary.print(f"\n Sites Conformes {SITES_CONFORMES_VERSION}", style="bold fg:#6a6af4")
100
+ questionary.print(" Quelques questions pour créer votre site.\n", style="fg:#888888")
101
+
102
+ answers = {
103
+ "site_title": ask(questionary.text, "Titre du site", default=name),
104
+ "site_tagline": ask(questionary.text, "Sous-titre du site", instruction="(facultatif) "),
105
+ "brand": ask(questionary.text, "Intitulé officiel sous la Marianne", default="République française"),
106
+ }
107
+ postgres = ask(
108
+ questionary.select,
109
+ "Base de données",
110
+ instruction="(flèches pour choisir)",
111
+ choices=[
112
+ questionary.Choice("SQLite, rien à installer", False),
113
+ questionary.Choice("PostgreSQL", True),
114
+ ],
115
+ )
116
+ answers["database_url"] = (
117
+ ask(questionary.text, "URL de la base", default="postgres://utilisateur:motdepasse@localhost:5432/" + name)
118
+ if postgres
119
+ else ""
120
+ )
121
+ answers["media_storage"] = ask(
122
+ questionary.select,
123
+ "Stockage des images et documents",
124
+ instruction="(flèches pour choisir)",
125
+ choices=[
126
+ questionary.Choice("Fichiers locaux, pour le développement uniquement", "files"),
127
+ questionary.Choice("Base de données, pratique sur un PaaS jusqu’à 1 Go", "db"),
128
+ questionary.Choice("Bucket S3", "s3"),
129
+ ],
130
+ )
131
+ features = ask(
132
+ questionary.checkbox,
133
+ "Fonctionnalités à activer",
134
+ instruction="(espace pour cocher, entrée pour valider)",
135
+ choices=[
136
+ questionary.Choice("Connexion à l’administration avec ProConnect", "proconnect"),
137
+ questionary.Choice("Double authentification obligatoire", "two_fa"),
138
+ questionary.Choice("Suivi des erreurs avec Sentry", "sentry"),
139
+ ],
140
+ )
141
+ answers["languages"] = ask(
142
+ questionary.checkbox,
143
+ "Langues en plus du français",
144
+ instruction="(espace pour cocher, entrée pour valider)",
145
+ choices=[questionary.Choice(LANG_INFO[code]["name_local"].capitalize(), code) for code in EXTRA_LANGUAGES],
146
+ )
147
+ return answers | {feature: feature in features for feature in ("proconnect", "two_fa", "sentry")}
148
+
149
+ def handle(self, **options) -> None:
150
+ name = options["name"]
151
+ target = Path(options["directory"] or name)
152
+ # Asked before creating anything, so that Ctrl+C leaves no half-made project.
153
+ interactive = options["interactive"] and sys.stdin.isatty()
154
+ try:
155
+ answers = self.ask_customisations(name) if interactive else {}
156
+ except KeyboardInterrupt:
157
+ sys.exit("\nCréation annulée : rien n’a été créé.")
158
+ features = {key: answers.get(key, default) for key, default in DEFAULT_FEATURES.items()}
159
+
160
+ options["template"] = str(Path(__file__).parent / "project_template")
161
+ options["files"] = ["pyproject.toml", "README.md"] # rendered like the .py files
162
+ options["sites_conformes_version"] = SITES_CONFORMES_VERSION
163
+ # The settings and URLs only contain the blocks of the chosen features.
164
+ options |= features
165
+ # The ProConnect button lives in the login page of the dashboard app, like the 2FA screens.
166
+ options["dashboard"] = features["proconnect"] or features["two_fa"]
167
+ options["languages"] = [(code, LANG_INFO[code]["name_local"].capitalize()) for code in features["languages"]]
168
+ super().handle(**options)
169
+
170
+ # Not a template file: a `.env` inside the package would be git-ignored.
171
+ env = f"DEBUG=True\nSECRET_KEY={get_random_secret_key()}\n"
172
+ if answers.get("database_url"):
173
+ env += f"DATABASE_URL={answers['database_url']}\n"
174
+ if features["proconnect"]:
175
+ env += ENV_PROCONNECT
176
+ if features["media_storage"] == "s3":
177
+ env += ENV_S3
178
+ if features["sentry"]:
179
+ env += ENV_SENTRY
180
+ (target / ".env").write_text(env)
181
+
182
+ if answers:
183
+ # Read by `set_config`, which `create_starter_pages` runs on a new site.
184
+ brand = answers["brand"]
185
+ config = {
186
+ "site_title": answers["site_title"],
187
+ "site_tagline": answers["site_tagline"],
188
+ "header_brand": brand,
189
+ "header_brand_html": escape(brand),
190
+ "footer_brand": brand,
191
+ "footer_brand_html": escape(brand),
192
+ }
193
+ (target / "config.json").write_text(json.dumps(config, ensure_ascii=False, indent=2) + "\n")
194
+
195
+ if options["verbosity"] > 0:
196
+ self.stdout.write(self.style.SUCCESS(f"\n✔ Projet créé dans {target}/"))
197
+ for line in created_summary(features):
198
+ self.stdout.write(f" {line}")
199
+ self.stdout.write(NEXT_STEPS.format(target=target))
200
+
201
+
202
+ SCREEN_WIDTH = 22
203
+ SCREEN_HEIGHT = 4
204
+ FLAG_BANDS = (("0;0;145", 7), ("255;255;255", 8), ("225;0;15", 7)) # DSFR blue France, white, red Marianne
205
+ MINITEL = """\
206
+ ╭──────────────────────────╮
207
+ │ ╭──────────────────────╮ │
208
+ {screen}
209
+ │ ╰──────────────────────╯ │
210
+ │ ▪ ▪ ▪ │
211
+ ╰──────────────────────────╯
212
+ ╱ ▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫ ▫▫▫ ╲
213
+ ╱ ▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫ ▫▫▫ ╲
214
+ ╰────────────────────────────╯
215
+ """
216
+
217
+
218
+ def flag_row(columns: int) -> str:
219
+ """One screen row with the first `columns` cells of the blue, white and red bands."""
220
+ row, start = "", 0
221
+ for colour, width in FLAG_BANDS:
222
+ row += f"\x1b[38;2;{colour}m{'█' * max(0, min(width, columns - start))}"
223
+ start += width
224
+ return f"{row}\x1b[0m{' ' * (SCREEN_WIDTH - columns)}"
225
+
226
+
227
+ def text_rows(typed: str) -> list[str]:
228
+ """The screen showing what has been typed so far of "3615 / SITES CONFORMES", with a cursor."""
229
+ first, _, second = typed.partition("\n")
230
+ rows = ["", f" {first}", f" {second}", ""]
231
+ rows[2 if "\n" in typed else 1] += "█"
232
+ return [f"\x1b[1m{row.ljust(SCREEN_WIDTH)}\x1b[0m" for row in rows]
233
+
234
+
235
+ def minitel_frames() -> list[tuple[list[str], float]]:
236
+ """Screen rows and duration of each frame: the flag wipes in, then the service name is typed."""
237
+ frames = [([flag_row(columns)] * SCREEN_HEIGHT, 0.02) for columns in range(1, SCREEN_WIDTH + 1)]
238
+ frames[-1] = (frames[-1][0], 0.4)
239
+ message = "3615\nSITES CONFORMES"
240
+ frames += [(text_rows(message[:length]), 0.04) for length in range(len(message) + 1)]
241
+ return frames
242
+
243
+
244
+ def animate_minitel(stream=sys.stdout, sleep=time.sleep) -> None:
245
+ """Draws a Minitel whose screen plays the flag, then shows "3615 SITES CONFORMES"."""
246
+ height = MINITEL.count("\n") + SCREEN_HEIGHT - 1
247
+ stream.write("\x1b[?25l") # hide the cursor while redrawing
248
+ try:
249
+ for index, (rows, duration) in enumerate(minitel_frames()):
250
+ if index:
251
+ stream.write(f"\x1b[{height}A") # back to the top of the previous frame
252
+ stream.write(MINITEL.format(screen="\n".join(f" │ │{row}│ │" for row in rows)))
253
+ stream.flush()
254
+ sleep(duration)
255
+ finally:
256
+ stream.write("\x1b[?25h")
257
+
258
+
259
+ def created_summary(features: dict) -> list[str]:
260
+ """What the generated project contains, so that the choices can be checked at a glance."""
261
+ storage = {
262
+ "files": "fichiers locaux (développement uniquement)",
263
+ "db": "base de données",
264
+ "s3": "bucket S3 (variables S3_* à remplir)",
265
+ }
266
+ lines = [f"Médias : {storage[features['media_storage']]}"]
267
+ if features["proconnect"]:
268
+ lines.append("ProConnect : variables PROCONNECT_* à remplir dans .env")
269
+ if features["two_fa"]:
270
+ lines.append("Double authentification obligatoire")
271
+ if features["languages"]:
272
+ lines.append(f"Langues : fr, {', '.join(features['languages'])}")
273
+ if features["sentry"]:
274
+ lines.append("Sentry : SENTRY_DSN à remplir dans .env")
275
+ return lines
276
+
277
+
278
+ def main() -> None:
279
+ if len(sys.argv) < 2 or sys.argv[1] != "start":
280
+ sys.exit(USAGE)
281
+ Command().run_from_argv(sys.argv)
282
+
283
+
284
+ if __name__ == "__main__":
285
+ main()
@@ -0,0 +1,6 @@
1
+ .env
2
+ .venv/
3
+ __pycache__/
4
+ db.sqlite3
5
+ medias/
6
+ staticfiles/
@@ -0,0 +1,31 @@
1
+ # {{ project_name }}
2
+
3
+ Site créé avec [Sites Conformes][sc] {{ sites_conformes_version }}.
4
+
5
+ [sc]: https://github.com/numerique-gouv/sites-conformes
6
+
7
+ ## Démarrer
8
+
9
+ ```sh
10
+ uv run python manage.py migrate
11
+ uv run python manage.py collectstatic --noinput
12
+ uv run python manage.py create_starter_pages
13
+ uv run python manage.py createsuperuser
14
+ uv run python manage.py runserver
15
+ ```
16
+
17
+ Le site est sur <http://localhost:8000/>, l’administration sur
18
+ <http://localhost:8000/cms-admin/>. `collectstatic` doit précéder
19
+ `create_starter_pages`, qui y lit les pictogrammes.
20
+
21
+ ## Configurer
22
+
23
+ Les réglages sont dans `config/settings.py`. Ceux qui changent d’un
24
+ environnement à l’autre se lisent dans le fichier `.env` (non versionné) :
25
+
26
+ | Variable | Rôle |
27
+ | --- | --- |
28
+ | `SECRET_KEY` | Clé secrète de Django, générée à la création du projet |
29
+ | `DEBUG` | `True` en développement, à retirer en production |
30
+ | `DATABASE_URL` | Base PostgreSQL (`postgres://…`). Sans elle, le site utilise SQLite |
31
+ | `ALLOWED_HOSTS`, `HOST_URL` | Nom de domaine du site en production |
@@ -0,0 +1,237 @@
1
+ """
2
+ Settings of the {{ project_name }} project, generated by `sites-conformes start`
3
+ (sites-conformes {{ sites_conformes_version }}).
4
+
5
+ Values that change between environments are read from the environment or from
6
+ the `.env` file. Reference of the sites-conformes settings:
7
+ https://sites-conformes.readthedocs.io/
8
+ """
9
+
10
+ import os
11
+ from pathlib import Path
12
+
13
+ import dj_database_url
14
+ from dotenv import load_dotenv
15
+
16
+ import sites_conformes
17
+
18
+ load_dotenv()
19
+
20
+ BASE_DIR = Path(__file__).resolve().parent.parent
21
+ PACKAGE_DIR = Path(sites_conformes.__file__).resolve().parent
22
+
23
+ SECRET_KEY = os.environ["SECRET_KEY"]
24
+ DEBUG = os.getenv("DEBUG", "").casefold() in ("1", "true")
25
+ ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "127.0.0.1,.localhost").replace(" ", "").split(",")
26
+
27
+ INSTALLED_APPS = [{% if media_storage == "s3" %}
28
+ "storages",{% endif %}
29
+ # sites-conformes
30
+ "dsfr",
31
+ "sites_conformes",
32
+ "sites_conformes.customimages",
33
+ "sites_conformes.core",
34
+ "sites_conformes.blog",
35
+ "sites_conformes.events",
36
+ "sites_conformes.forms",
37
+ "sites_conformes.menus",{% if dashboard %}
38
+ "sites_conformes.dashboard",
39
+ "widget_tweaks",{% endif %}{% if media_storage == "db" %}
40
+ "sites_conformes.db_storage",{% endif %}{% if proconnect %}
41
+ "sites_conformes.proconnect",
42
+ "mozilla_django_oidc",{% endif %}
43
+ "wagtailmenus",
44
+ "wagtailmarkdown",
45
+ "wagtail_honeypot",
46
+ # Wagtail
47
+ "wagtail.contrib.forms",
48
+ "wagtail.contrib.redirects",
49
+ "wagtail.contrib.routable_page",
50
+ "wagtail.contrib.settings",
51
+ "wagtail.contrib.typed_table_block",
52
+ "wagtail.embeds",
53
+ "wagtail.sites",
54
+ "wagtail.users",
55
+ "wagtail.snippets",
56
+ "wagtail.documents",
57
+ "wagtail.images",
58
+ "wagtail.search",
59
+ "wagtail.admin",{% if dashboard %}
60
+ "wagtail_2fa",
61
+ "django_otp",
62
+ "django_otp.plugins.otp_totp",{% endif %}{% if languages %}
63
+ "wagtail_localize",
64
+ "wagtail_localize.locales",{% endif %}
65
+ "wagtail",
66
+ "modelcluster",
67
+ "taggit",
68
+ # Django
69
+ "django.contrib.auth",
70
+ "django.contrib.contenttypes",
71
+ "django.contrib.sessions",
72
+ "django.contrib.messages",
73
+ "django.contrib.sitemaps",
74
+ "django.contrib.staticfiles",
75
+ ]
76
+
77
+ MIDDLEWARE = [
78
+ "django.middleware.security.SecurityMiddleware",
79
+ "django.contrib.sessions.middleware.SessionMiddleware",
80
+ "django.middleware.common.CommonMiddleware",
81
+ "django.middleware.csrf.CsrfViewMiddleware",
82
+ "django.middleware.locale.LocaleMiddleware",
83
+ "django.contrib.auth.middleware.AuthenticationMiddleware",{% if dashboard %}
84
+ "sites_conformes.dashboard.middleware.VerifyUserStaticFilesMiddleware",{% endif %}
85
+ "django.contrib.messages.middleware.MessageMiddleware",
86
+ "django.middleware.clickjacking.XFrameOptionsMiddleware",
87
+ "wagtail.contrib.redirects.middleware.RedirectMiddleware",
88
+ ]
89
+
90
+ ROOT_URLCONF = "config.urls"
91
+ WSGI_APPLICATION = "config.wsgi.application"
92
+
93
+ TEMPLATES = [
94
+ {
95
+ "BACKEND": "django.template.backends.django.DjangoTemplates",
96
+ # Put your own templates in templates/ to override the ones of the package.
97
+ "DIRS": [BASE_DIR / "templates", PACKAGE_DIR / "templates"],
98
+ "APP_DIRS": True,
99
+ "OPTIONS": {
100
+ "context_processors": [
101
+ "django.template.context_processors.debug",
102
+ "django.template.context_processors.request",
103
+ "django.contrib.auth.context_processors.auth",
104
+ "django.contrib.messages.context_processors.messages",
105
+ "wagtail.contrib.settings.context_processors.settings",
106
+ "wagtailmenus.context_processors.wagtailmenus",
107
+ "sites_conformes.core.context_processors.skiplinks",
108
+ "sites_conformes.core.context_processors.mega_menus",
109
+ ],
110
+ },
111
+ },
112
+ ]
113
+
114
+ # SQLite by default, to start without installing anything.
115
+ # Set DATABASE_URL (postgres://user:password@host:5432/name) to use PostgreSQL.
116
+ DATABASES = {"default": dj_database_url.config(default=f"sqlite:///{BASE_DIR / 'db.sqlite3'}")}
117
+ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
118
+
119
+ AUTH_PASSWORD_VALIDATORS = [
120
+ {"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
121
+ {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
122
+ {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
123
+ {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
124
+ ]
125
+
126
+ LANGUAGE_CODE = "fr"
127
+ TIME_ZONE = "Europe/Paris"
128
+ USE_I18N = True
129
+ USE_TZ = True
130
+ WAGTAIL_I18N_ENABLED = True
131
+ WAGTAIL_CONTENT_LANGUAGES = LANGUAGES = [
132
+ ("fr", "Français"),{% for code, language in languages %}
133
+ ("{{ code }}", "{{ language }}"),{% endfor %}
134
+ ]
135
+
136
+ STATIC_URL = "static/"
137
+ STATIC_ROOT = BASE_DIR / "staticfiles"
138
+ STATICFILES_DIRS = [PACKAGE_DIR / "static"]
139
+ {% if media_storage == "db" %}
140
+ # Media stored in the database: nothing to keep on disk, fine up to about 1 GB.
141
+ STORAGES = {
142
+ "default": {"BACKEND": "sites_conformes.db_storage.storage.DatabaseStorage"},
143
+ "staticfiles": {"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"},
144
+ }
145
+ MEDIA_URL = "db-storage/"
146
+ MEDIA_ROOT = BASE_DIR
147
+ {% elif media_storage == "s3" %}
148
+ # Media stored in an S3 bucket, configured with the S3_* variables.
149
+ # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html
150
+ S3_ENDPOINT_URL = f"https://{os.environ['S3_HOST']}"
151
+ STORAGES = {
152
+ "default": {
153
+ "BACKEND": "storages.backends.s3.S3Storage",
154
+ "OPTIONS": {
155
+ "bucket_name": os.environ["S3_BUCKET_NAME"],
156
+ "access_key": os.environ["S3_KEY_ID"],
157
+ "secret_key": os.environ["S3_KEY_SECRET"],
158
+ "endpoint_url": S3_ENDPOINT_URL,
159
+ "region_name": os.getenv("S3_BUCKET_REGION", "fr"),
160
+ "location": os.getenv("S3_LOCATION", ""),
161
+ "file_overwrite": False,
162
+ },
163
+ },
164
+ "staticfiles": {"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"},
165
+ }
166
+ MEDIA_URL = f"{S3_ENDPOINT_URL}/"
167
+ MEDIA_ROOT = BASE_DIR
168
+ {% else %}
169
+ MEDIA_URL = "medias/"
170
+ MEDIA_ROOT = BASE_DIR / "medias"
171
+ {% endif %}
172
+ # Page models with many blocks exceed Django's default of 1000 form fields.
173
+ DATA_UPLOAD_MAX_NUMBER_FIELDS = 10_000
174
+
175
+ # Wagtail
176
+ WAGTAIL_SITE_NAME = "{{ project_name }}"
177
+ WAGTAILADMIN_PATH = "cms-admin/"
178
+ WAGTAILSEARCH_BACKENDS = {"default": {"BACKEND": "wagtail.search.backends.database"}}
179
+ # Required: the migrations of the package depend on it.
180
+ WAGTAILIMAGES_IMAGE_MODEL = "sites_conformes_customimages.CustomImage"
181
+
182
+ # sites-conformes: host, protocol and port used to build absolute URLs.
183
+ HOST_URL = os.getenv("HOST_URL", "localhost")
184
+ HOST_PROTO = os.getenv("HOST_PROTO", "http" if DEBUG else "https")
185
+ HOST_PORT = os.getenv("HOST_PORT", "8000" if DEBUG else "")
186
+ WAGTAILADMIN_BASE_URL = f"{HOST_PROTO}://{HOST_URL}" + (f":{HOST_PORT}" if HOST_PORT else "")
187
+ {% if dashboard %}
188
+ # Admin dashboard of sites-conformes: DSFR login page, notifications, tutorials, 2FA screens.
189
+ WAGTAILADMIN_USER_PASSWORD_RESET_FORM = "sites_conformes.dashboard.forms.DsfrPasswordResetForm" # nosec B105
190
+ WAGTAIL_ENABLE_UPDATE_CHECK = False # replaced by the check of the latest sites-conformes release below
191
+ NOTIFICATIONS_FILE_URL = (
192
+ "https://raw.githubusercontent.com/numerique-gouv/sites-conformes/refs/heads/main/notifications.json"
193
+ )
194
+ LATEST_RELEASE_URL = "https://api.github.com/repos/numerique-gouv/sites-conformes/releases/latest"
195
+ RELEASES_URL = "https://github.com/numerique-gouv/sites-conformes/releases"
196
+ ADVERTISE_LATEST_VERSION = True
197
+ SF_DISABLE_TUTORIALS = False
198
+
199
+ # Two-factor authentication of the admin users. https://wagtail-2fa.readthedocs.io/
200
+ WAGTAIL_2FA_REQUIRED = {{ two_fa }}
201
+ WAGTAIL_2FA_OTP_TOTP_NAME = WAGTAIL_SITE_NAME
202
+ PROCONNECT_ACTIVATED = {{ proconnect }}
203
+ {% endif %}{% if proconnect %}
204
+ # ProConnect login for the admin, next to the password login.
205
+ # The identifiers are read from the PROCONNECT_* variables.
206
+ AUTHENTICATION_BACKENDS = [
207
+ "django.contrib.auth.backends.ModelBackend",
208
+ "sites_conformes.proconnect.backends.OIDCAuthenticationBackend",
209
+ ]
210
+ PROCONNECT_DOMAIN = os.getenv("PROCONNECT_DOMAIN", "fca.integ01.dev-agentconnect.fr")
211
+ PROCONNECT_API_ROOT = f"https://{PROCONNECT_DOMAIN}/api/v2"
212
+ OIDC_RP_CLIENT_ID = os.getenv("PROCONNECT_CLIENT_ID", "")
213
+ OIDC_RP_CLIENT_SECRET = os.getenv("PROCONNECT_CLIENT_SECRET", "")
214
+ OIDC_RP_SCOPES = "openid given_name usual_name email siret uid"
215
+ OIDC_RP_SIGN_ALGO = "RS256"
216
+ OIDC_STORE_ID_TOKEN = True
217
+ OIDC_CREATE_USER = True
218
+ OIDC_OP_JWKS_ENDPOINT = f"{PROCONNECT_API_ROOT}/jwks"
219
+ OIDC_OP_AUTHORIZATION_ENDPOINT = f"{PROCONNECT_API_ROOT}/authorize"
220
+ OIDC_OP_TOKEN_ENDPOINT = f"{PROCONNECT_API_ROOT}/token"
221
+ OIDC_OP_USER_ENDPOINT = f"{PROCONNECT_API_ROOT}/userinfo"
222
+ OIDC_OP_LOGOUT_ENDPOINT = f"{PROCONNECT_API_ROOT}/session/end"
223
+ OIDC_AUTH_REQUEST_EXTRA_PARAMS = {"acr_values": "eidas1"}
224
+ OIDC_REDIRECT_ALLOWED_HOSTS = ALLOWED_HOSTS
225
+ USER_OIDC_ESSENTIAL_CLAIMS = ["email"]
226
+ PROCONNECT_USER_CREATION_FILTER = None
227
+ LASUITE_DOMAINE_API_KEY = os.getenv("LASUITE_DOMAINE_API_KEY")
228
+ LOGIN_URL = f"/{WAGTAILADMIN_PATH}login/"
229
+ LOGOUT_URL = "/oidc/logout/"
230
+ LOGIN_REDIRECT_URL = LOGOUT_REDIRECT_URL = "/"
231
+ {% endif %}{% if sentry %}
232
+ # Sentry: nothing is sent while SENTRY_DSN is empty.
233
+ if sentry_dsn := os.getenv("SENTRY_DSN"):
234
+ import sentry_sdk
235
+
236
+ sentry_sdk.init(dsn=sentry_dsn, environment=os.getenv("SENTRY_ENVIRONMENT", "production"))
237
+ {% endif %}
@@ -0,0 +1,32 @@
1
+ from django.conf import settings
2
+ from django.conf.urls.i18n import i18n_patterns
3
+ from django.conf.urls.static import static
4
+ from django.urls import include, path
5
+ from django.views.generic.base import RedirectView
6
+ from wagtail.admin import urls as wagtailadmin_urls
7
+ from wagtail.contrib.sitemaps.views import sitemap
8
+ from wagtail.documents import urls as wagtaildocs_urls
9
+ {% if dashboard %}
10
+ from sites_conformes.dashboard.views import PasswordResetConfirmView
11
+ {% endif %}
12
+ urlpatterns = [
13
+ path("sitemap.xml", sitemap, name="xml_sitemap"),{% if dashboard %}
14
+ path(
15
+ f"{settings.WAGTAILADMIN_PATH}password_reset/confirm/<uidb64>/<token>/",
16
+ PasswordResetConfirmView.as_view(),
17
+ name="wagtailadmin_password_reset_confirm",
18
+ ),{% endif %}
19
+ path(settings.WAGTAILADMIN_PATH, include(wagtailadmin_urls)),
20
+ path("documents/", include(wagtaildocs_urls)),{% if media_storage == "db" %}
21
+ path("db-storage/", include("sites_conformes.db_storage.urls")),{% endif %}{% if proconnect %}
22
+ path("oidc/", include("sites_conformes.proconnect.urls")),{% endif %}
23
+ path("favicon.ico", RedirectView.as_view(url="/static/dsfr/dist/favicon/favicon.ico", permanent=True)),
24
+ ]
25
+
26
+ urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
27
+
28
+ # Pages, search and sitemap provided by sites-conformes. Keep last: it catches every other URL.
29
+ urlpatterns += i18n_patterns(
30
+ path("", include("sites_conformes.core.urls")),
31
+ prefix_default_language=False,
32
+ )
@@ -0,0 +1,16 @@
1
+ """
2
+ WSGI config for {{ project_name }} project.
3
+
4
+ It exposes the WSGI callable as a module-level variable named ``application``.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/
8
+ """
9
+
10
+ import os
11
+
12
+ from django.core.wsgi import get_wsgi_application
13
+
14
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
15
+
16
+ application = get_wsgi_application()
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env python
2
+ """Django's command-line utility for administrative tasks."""
3
+
4
+ import os
5
+ import sys
6
+
7
+
8
+ def main():
9
+ """Run administrative tasks."""
10
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
11
+ try:
12
+ from django.core.management import execute_from_command_line
13
+ except ImportError as exc:
14
+ raise ImportError(
15
+ "Couldn't import Django. Are you sure it's installed and "
16
+ "available on your PYTHONPATH environment variable? Did you "
17
+ "forget to activate a virtual environment?"
18
+ ) from exc
19
+ execute_from_command_line(sys.argv)
20
+
21
+
22
+ if __name__ == "__main__":
23
+ main()
@@ -0,0 +1,7 @@
1
+ [project]
2
+ name = "{{ project_name }}"
3
+ version = "0.1.0"
4
+ requires-python = ">=3.12"
5
+ dependencies = [
6
+ "sites-conformes>={{ sites_conformes_version }}",
7
+ ]
@@ -0,0 +1,35 @@
1
+ [project]
2
+ name = "bouture"
3
+ version = "2026.11.19.1"
4
+ description = "Crée un nouveau site à partir de Sites Conformes, comme on bouture une plante."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ dependencies = [
10
+ "django>=5.2",
11
+ "questionary>=2.1",
12
+ ]
13
+
14
+ [project.scripts]
15
+ bouture = "bouture.cli:main"
16
+
17
+ [dependency-groups]
18
+ dev = [
19
+ "pytest>=8",
20
+ "sites-conformes",
21
+ ]
22
+
23
+ [tool.uv.sources.sites-conformes]
24
+ git = "https://github.com/numerique-gouv/sites-conformes"
25
+ rev = "34bc99c887f15ff949e5bc16d8b8e020b7c00e2e"
26
+
27
+ [tool.uv.build-backend]
28
+ module-root = ""
29
+
30
+ [tool.pytest.ini_options]
31
+ testpaths = ["tests"]
32
+
33
+ [build-system]
34
+ requires = ["uv_build>=0.8,<0.14"]
35
+ build-backend = "uv_build"
@@ -0,0 +1,30 @@
1
+ [project]
2
+ name = "bouture"
3
+ version = "2026.11.19.1"
4
+ description = "Crée un nouveau site à partir de Sites Conformes, comme on bouture une plante."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ dependencies = ["django>=5.2", "questionary>=2.1"]
10
+
11
+ [project.scripts]
12
+ bouture = "bouture.cli:main"
13
+
14
+ [dependency-groups]
15
+ # The generated project is checked against the real package.
16
+ dev = ["pytest>=8", "sites-conformes"]
17
+
18
+ [tool.uv.sources]
19
+ # ponytail: pinned to the commit carrying the SQLite migration fix; back to PyPI once 4.4.0 is released with it.
20
+ sites-conformes = { git = "https://github.com/numerique-gouv/sites-conformes", rev = "34bc99c887f15ff949e5bc16d8b8e020b7c00e2e" }
21
+
22
+ [build-system]
23
+ requires = ["uv_build>=0.8,<0.14"]
24
+ build-backend = "uv_build"
25
+
26
+ [tool.uv.build-backend]
27
+ module-root = ""
28
+
29
+ [tool.pytest.ini_options]
30
+ testpaths = ["tests"]