Skip to content

Commit

Permalink
Launch the import_dsfr_pictograms script during updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash-Crow committed Oct 30, 2024
1 parent 75d845c commit 8ab23ee
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ init-dev:
update:
$(EXEC_CMD) poetry install --without dev
$(EXEC_CMD) poetry run python manage.py migrate
$(EXEC_CMD) poetry run python manage.py import_page_templates
make collectstatic
$(EXEC_CMD) poetry run python manage.py import_dsfr_pictograms
$(EXEC_CMD) poetry run python manage.py import_page_templates
make index


Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
postdeploy: python manage.py migrate && python manage.py import_page_templates && python manage.py update_index
postdeploy: python manage.py migrate && python manage.py import_dsfr_pictograms && python manage.py import_page_templates && python manage.py update_index
web: gunicorn config.wsgi --log-file -
13 changes: 5 additions & 8 deletions content_manager/management/commands/import_dsfr_pictograms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os

from django.core.management import call_command
from django.core.management.base import BaseCommand
from wagtail.images.models import Image

Expand All @@ -9,15 +8,13 @@


class Command(BaseCommand):
help = """Import all the pictograms from the DSFR"""
help = """
Import all the pictograms from the DSFR.
def handle(self, *args, **kwargs):
call_command(
"collectstatic",
"--ignore=*.sass",
interactive=False,
)
Should only be launched if the statics have been collected at least once.
"""

def handle(self, *args, **kwargs):
picto_root = "staticfiles/dsfr/dist/artwork/pictograms/"
picto_folders = os.listdir(picto_root)
picto_folders.sort()
Expand Down
24 changes: 24 additions & 0 deletions content_manager/tests/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,30 @@ def test_tile_with_image_has_div(self):

self.assertContains(response, "fr-tile__header")

def test_tile_manages_svg_image(self):
image_file = "static/artwork/technical-error.svg"
image = import_image(image_file, "Sample image")

body = [
(
"tile",
{
"title": "Sample tile",
"description": RichText('<p data-block-key="test">This is a sample tile.</p>'),
"image": image,
},
)
]

self.content_page.body = body
self.content_page.save()

url = self.content_page.url

response = self.client.get(url)

self.assertContains(response, "fr-tile__pictogram")


class BlogRecentEntriesBlockTestCase(WagtailPageTestCase):
def setUp(self):
Expand Down

0 comments on commit 8ab23ee

Please sign in to comment.