Skip to content

Commit

Permalink
Merge pull request #138 from numerique-gouv/main
Browse files Browse the repository at this point in the history
Mise en production
  • Loading branch information
LucienMLD authored Jan 24, 2025
2 parents 5850f6e + ad50f78 commit 720d85c
Show file tree
Hide file tree
Showing 30 changed files with 2,917 additions and 736 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ MEDIA_ROOT=medias

# USE_DOCKER: Set 1 to use Docker
USE_DOCKER=0
# Set 1 to use Poetry
USE_POETRY=0

DATABASE_NAME=djdb
DATABASE_USER=dju
Expand Down
3 changes: 2 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ DATABASE_USER=dju
DATABASE_PASSWORD=djpwd
DATABASE_HOST=127.0.0.1
DATABASE_PORT=5432
DEBUG=True
DEBUG=False
DATABASE_URL=postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}
USE_POETRY=1
2 changes: 1 addition & 1 deletion .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
python -m pip install --upgrade pip
pip install poetry
pip install ruff
poetry install --no-root
poetry install --no-root --with dev
- name: 📄 Copy empty .env.test to .env
run: |
cp .env.test .env
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10
FROM python:3.13

EXPOSE ${CONTAINER_PORT}

Expand All @@ -8,7 +8,7 @@ ENV GECKODRIVER_URL=https://github.com/mozilla/geckodriver/releases/download/v0.
ENV APP_DIR="/app"

# Configure Poetry
ENV POETRY_VERSION=1.8.2
ENV POETRY_VERSION=2.0.1
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VENV=/opt/poetry-venv
ENV POETRY_CACHE_DIR=/opt/.cache
Expand All @@ -32,7 +32,7 @@ ENV PATH="${PATH}:${POETRY_VENV}/bin"
WORKDIR $APP_DIR

COPY pyproject.toml poetry.lock ./
RUN poetry install
RUN poetry install --no-root

COPY --chown=app:app . .

Expand Down
56 changes: 32 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,80 +10,88 @@ else
EXEC_CMD :=
endif

ifeq ($(USE_POETRY),1)
POETRY_CMD := poetry run
else
POETRY_CMD :=
endif

.PHONY: web-prompt
web-prompt:
$(EXEC_CMD) bash

.PHONY: collectstatic
collectstatic:
$(EXEC_CMD) poetry run python manage.py collectstatic --noinput --ignore=*.sass

$(EXEC_CMD) $(POETRY_CMD) python manage.py collectstatic --noinput --ignore=*.sass

.PHONY: messages
messages:
$(EXEC_CMD) poetry run django-admin makemessages -l fr --ignore=manage.py --ignore=config --ignore=medias --ignore=__init__.py --ignore=setup.py --ignore=staticfiles
$(EXEC_CMD) $(POETRY_CMD) django-admin makemessages -l fr --ignore=manage.py --ignore=config --ignore=medias --ignore=__init__.py --ignore=setup.py --ignore=staticfiles

.PHONY: sass
sass:
$(EXEC_CMD) poetry run python manage.py compilescss
$(EXEC_CMD) $(POETRY_CMD) python manage.py compilescss
make collectstatic

.PHONY: quality
quality:
$(EXEC_CMD) ruff check .
$(EXEC_CMD) poetry run black --check --exclude=venv .
$(EXEC_CMD) $(POETRY_CMD) black --check --exclude=venv .

.PHONY: fix
fix:
$(EXEC_CMD) ruff check . --fix
$(EXEC_CMD) poetry run black --exclude=venv .
$(EXEC_CMD) $(POETRY_CMD) black --exclude=venv .

.PHONY: index
index:
$(EXEC_CMD) poetry run python manage.py update_index
$(EXEC_CMD) $(POETRY_CMD) python manage.py update_index

.PHONY: init
init:
$(EXEC_CMD) poetry install --without dev
$(EXEC_CMD) poetry run python manage.py migrate
$(EXEC_CMD) poetry install --no-root --without dev
$(EXEC_CMD) $(POETRY_CMD) python manage.py migrate
make collectstatic
$(EXEC_CMD) poetry run python manage.py set_config
$(EXEC_CMD) poetry run python manage.py import_dsfr_pictograms
$(EXEC_CMD) poetry run python manage.py create_starter_pages
$(EXEC_CMD) poetry run python manage.py import_page_templates
$(EXEC_CMD) $(POETRY_CMD) python manage.py set_config
$(EXEC_CMD) $(POETRY_CMD) python manage.py import_dsfr_pictograms
$(EXEC_CMD) $(POETRY_CMD) python manage.py create_starter_pages
$(EXEC_CMD) $(POETRY_CMD) python manage.py import_page_templates
make index

.PHONY: init-dev
init-dev:
make init
$(EXEC_CMD) poetry install
$(EXEC_CMD) poetry run pre-commit install
$(EXEC_CMD) poetry install --no-root
$(EXEC_CMD) $(POETRY_CMD) pre-commit install


.PHONY: update
update:
$(EXEC_CMD) poetry install --without dev
$(EXEC_CMD) poetry run python manage.py migrate
$(EXEC_CMD) poetry install --no-root --without dev
$(EXEC_CMD) $(POETRY_CMD) python manage.py migrate
make collectstatic
$(EXEC_CMD) poetry run python manage.py import_dsfr_pictograms
$(EXEC_CMD) poetry run python manage.py import_page_templates
$(EXEC_CMD) $(POETRY_CMD) python manage.py import_dsfr_pictograms
$(EXEC_CMD) $(POETRY_CMD) python manage.py import_page_templates
make index


.PHONY: demo
demo:
make init
$(EXEC_CMD) poetry run python manage.py create_demo_pages
$(EXEC_CMD) $(POETRY_CMD) python manage.py create_demo_pages

.PHONY: runserver
runserver:
$(EXEC_CMD) poetry run python manage.py runserver $(HOST_URL):$(HOST_PORT)
$(EXEC_CMD) $(POETRY_CMD) python manage.py runserver $(HOST_URL):$(HOST_PORT)


.PHONY: shell
shell:
$(EXEC_CMD) $(POETRY_CMD) python manage.py shell_plus

.PHONY: test
test:
$(EXEC_CMD) poetry run python manage.py test --buffer --parallel
$(EXEC_CMD) $(POETRY_CMD) python manage.py test --buffer --parallel

.PHONY: test-unit
test-unit:
$(EXEC_CMD) poetry run python manage.py test --settings config.settings_test
$(EXEC_CMD) $(POETRY_CMD) python manage.py test --settings config.settings_test
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ python -c "from django.core.management.utils import get_random_secret_key; print
### En local
#### Installer poetry s’il ne l’est pas

Cf. la [documentation de poetry](https://python-poetry.org/docs/#installation)
- Cf. la [documentation de poetry](https://python-poetry.org/docs/#installation)
- mettre la variable d’environnement `USE_POETRY` à `1` dans le fichier `.env`

#### Installer le projet

Expand Down
75 changes: 38 additions & 37 deletions blog/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-10 14:32+0100\n"
"POT-Creation-Date: 2025-01-17 18:35+0100\n"
"PO-Revision-Date: 2024-12-10 14:33+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -18,19 +18,19 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 3.4.2\n"

#: blog/blocks.py:9 blog/models.py:39 blog/models.py:67
#: blog/blocks.py:9 blog/models.py:41 blog/models.py:69
msgid "Name"
msgstr "Nom"

#: blog/blocks.py:10 blog/models.py:68
#: blog/blocks.py:10 blog/models.py:70
msgid "Role"
msgstr "Fonction"

#: blog/blocks.py:11 blog/models.py:56
#: blog/blocks.py:11 blog/models.py:58
msgid "Organization"
msgstr "Organisation"

#: blog/blocks.py:12 blog/models.py:70
#: blog/blocks.py:12 blog/models.py:72
msgid "Contact info"
msgstr "Informations de contact"

Expand All @@ -42,124 +42,125 @@ msgstr "Texte riche"
msgid "Contact card"
msgstr "Carte contact"

#: blog/models.py:95
#: blog/models.py:97
msgid "Person"
msgstr "Personne"

#: blog/models.py:107
#: blog/models.py:109
msgid "Category name"
msgstr "Nom de la catégorie"

#: blog/models.py:114
#: blog/models.py:116
msgid "Parent category"
msgstr "Catégorie parente"

#: blog/models.py:121
#: blog/models.py:123
msgid "Description"
msgstr "Description"

#: blog/models.py:122
#: blog/models.py:124
msgid "Displayed on the top of the category page"
msgstr "Affiché en haut de la page de la catégorie"

#: blog/models.py:128
#: blog/models.py:130
msgid "Text displayed at the end of every page in the category"
msgstr "Texte affiché à la fin de chaque page de la catégorie"

#: blog/models.py:155
#: blog/models.py:157
msgid "Parent category cannot be self."
msgstr "La catégorie ne peut être sa propre parente."

#: blog/models.py:157
#: blog/models.py:159
msgid "Cannot have circular Parents."
msgstr "Il est impossible d’avoir des parents circulaires."

#: blog/models.py:166 blog/models.py:185
#: blog/models.py:168 blog/models.py:187
msgid "Category"
msgstr "Catégorie"

#: blog/models.py:167 blog/models.py:279 blog/models.py:461 blog/models.py:468
#: blog/models.py:519
#: blog/models.py:169 blog/models.py:287 blog/models.py:469 blog/models.py:476
#: blog/models.py:527
msgid "Categories"
msgstr "Catégories"

#: blog/models.py:201
#: blog/models.py:203
msgid "Posts per page"
msgstr "Articles par page"

#: blog/models.py:207
#: blog/models.py:209
msgid "Post limit in the RSS/Atom feeds"
msgstr "Nombre d’articles dans les flux RSS/Atom"

#: blog/models.py:211 blog/templates/blog/blog_index_page.html:85
#: blog/models.py:213 blog/templates/blog/blog_index_page.html:85
msgid "Filter by category"
msgstr "Filtrer par catégorie"

#: blog/models.py:212 blog/templates/blog/blog_index_page.html:102
#: blog/models.py:214 blog/templates/blog/blog_index_page.html:102
msgid "Filter by tag"
msgstr "Filtrer par étiquette"

#: blog/models.py:213 blog/templates/blog/blog_index_page.html:119
#: blog/models.py:215 blog/templates/blog/blog_index_page.html:119
msgid "Filter by author"
msgstr "Filtrer par auteur"

#: blog/models.py:215 blog/templates/blog/blog_index_page.html:134
#: blog/models.py:217 blog/templates/blog/blog_index_page.html:134
msgid "Filter by source"
msgstr "Filtrer par source"

#: blog/models.py:215
#: blog/models.py:217
msgid "The source is the organization of the post author"
msgstr "La source est l’organisation à laquelle appartient l’auteur de l’article"
msgstr ""
"La source est l’organisation à laquelle appartient l’auteur de l’article"

#: blog/models.py:228
#: blog/models.py:230
msgid "Show filters"
msgstr "Afficher les filtres"

#: blog/models.py:235
#: blog/models.py:243
msgid "Blog index"
msgstr "Index de blog"

#: blog/models.py:262 blog/models.py:484 blog/models.py:498
#: blog/models.py:270 blog/models.py:492 blog/models.py:506
#: blog/templates/blog/tags_list_page.html:20
msgid "Tags"
msgstr "Étiquettes"

#: blog/models.py:267
#: blog/models.py:275
#, python-format
msgid "Posts tagged with %(tag)s"
msgstr "Articles avec l’étiquette %(tag)s"

#: blog/models.py:284
#: blog/models.py:292
#, python-format
msgid "Posts in category %(category)s"
msgstr "Articles dans la catégorie %(category)s"

#: blog/models.py:294 blog/models.py:296 blog/models.py:306 blog/models.py:309
#: blog/models.py:302 blog/models.py:304 blog/models.py:314 blog/models.py:317
msgid "Posts written by"
msgstr "Articles écrits par"

#: blog/models.py:314
#: blog/models.py:322
#, python-format
msgid "Posts published in %(year)s"
msgstr "Articles publiés en %(year)s"

#: blog/models.py:521
#: blog/models.py:529
msgid "Post date"
msgstr "Date de publication"

#: blog/models.py:523
#: blog/models.py:531
msgid "Author entries can be created in Snippets > Persons"
msgstr "Les auteurs peuvent être créés via Fragments > Personnes"

#: blog/models.py:542
#: blog/models.py:550
msgid "Scheduled publishing"
msgstr "Publication planifiée"

#: blog/models.py:550
#: blog/models.py:558
msgid "Tags and Categories"
msgstr "Étiquettes et Catégories"

#: blog/models.py:566
#: blog/models.py:585
msgid "Blog page"
msgstr "Page de blog"

Expand All @@ -183,7 +184,7 @@ msgstr "Flux RSS pour la catégorie"
msgid "RSS feed"
msgstr "Flux RSS"

#: blog/templates/blog/blog_entry_page.html:79
#: blog/templates/blog/blog_entry_page.html:80
msgid "Posted by:"
msgstr "Écrit par :"

Expand Down
13 changes: 13 additions & 0 deletions blog/migrations/0055_merge_20250117_1145.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by Django 5.0.9 on 2025-01-17 10:45

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("blog", "0041_alter_blogentrypage_body_alter_blogindexpage_body_and_more"),
("blog", "0054_alter_blogentrypage_body"),
]

operations = []
Loading

0 comments on commit 720d85c

Please sign in to comment.