Skip to content

Commit

Permalink
Merge branch 'main' into access
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucien Mollard authored and Lucien Mollard committed Jan 24, 2025
2 parents 9c52078 + 4561909 commit 70f2ae7
Show file tree
Hide file tree
Showing 11 changed files with 460 additions and 348 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
2 changes: 0 additions & 2 deletions blog/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,4 @@ def test_deep_blog_works(self):
self.assertPageIsRenderable(new_blog_post)

response = self.client.get(deep_blog_index_page.url + "rss/")
print(deep_blog_index_page.url + "rss/")
print(response)
self.assertEqual(response.status_code, 200)
2 changes: 0 additions & 2 deletions content_manager/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,6 @@ def enlarge_link(self):
if len(call_to_action):
enlarge = False
elif len(tags):
print(tags)
print(tags.raw_data)
tags_list = tags.raw_data
for tag in tags_list:
if (
Expand Down
6 changes: 4 additions & 2 deletions content_manager/management/commands/import_dsfr_pictograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def handle(self, *args, **kwargs):
image_exists = Image.objects.filter(title=full_image_title).first()
if image_exists:
file_hash = image_exists.get_file_hash()
print(f"A file named {full_image_title} already exists, skipping (file_hash: {file_hash})")
self.stdout.write(
f"A file named {full_image_title} already exists, skipping (file_hash: {file_hash})"
)
else:
image = import_image(
full_path=os.path.join(folder_path, filename),
Expand All @@ -49,4 +51,4 @@ def handle(self, *args, **kwargs):
image.tags.add("DSFR")
image.tags.add("Pictogrammes")
image.tags.add(folder_title)
print(f"File {full_image_title} imported")
self.stdout.write(f"File {full_image_title} imported")
Loading

0 comments on commit 70f2ae7

Please sign in to comment.