Skip to content

Commit

Permalink
Merge pull request #4021 from GeotrekCE/fix_svg_thumbnail
Browse files Browse the repository at this point in the history
Fix api crash when using an svg file for information desks (fixes #3860)
  • Loading branch information
submarcos committed Mar 29, 2024
2 parents e3c53c7 + ead95fd commit 8d884d0
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ override_dh_virtualenv:
--python /usr/bin/python3.8 \
--upgrade-pip \
--preinstall wheel \
--preinstall setuptools \
--preinstall setuptools==69.2.0 \
--builtin-venv \
--extra-pip-arg --no-cache-dir \
--extra-pip-arg --quiet
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ CHANGELOG
2.103.2+dev (XXXX-XX-XX)
------------------------

**Bug fixes**

- Fix api crash when using an svg file for information desks (fixes #3860)

**Breaking changes**

- Geotrek-rando v2 support is deprecated, `sync_rando` command and Sync rando menu view are removed.
Expand Down
20 changes: 20 additions & 0 deletions geotrek/api/tests/test_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2156,12 +2156,32 @@ def test_informationdesk_list(self):
tourism_models.InformationDesk
)

def test_informationdesk_list_with_svg(self):
info_desk = tourism_factory.InformationDeskFactory(
photo=get_dummy_uploaded_image_svg(), name='test!')
info_desk.save()
self.treks[0].information_desks.add(info_desk)
self.check_number_elems_response(
self.get_informationdesk_list(),
tourism_models.InformationDesk
)

def test_informationdesk_detail(self):
self.check_structure_response(
self.get_informationdesk_detail(self.info_desk.pk),
INFORMATION_DESK_PROPERTIES_JSON_STRUCTURE
)

def test_informationdesk_detail_with_svg(self):
info_desk = tourism_factory.InformationDeskFactory(
photo=get_dummy_uploaded_image_svg())
info_desk.save()
self.treks[0].information_desks.add(info_desk)
self.check_structure_response(
self.get_informationdesk_detail(info_desk.pk),
INFORMATION_DESK_PROPERTIES_JSON_STRUCTURE
)

def test_informationdesk_filter_trek(self):
response = self.get_informationdesk_list({'trek': self.treks[0].pk})
self.assertEqual(response.json()["count"], 1)
Expand Down
20 changes: 17 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ cffi==1.16.0
# pyvips
# weasyprint
chardet==5.2.0
# via geotrek (setup.py)
# via
# geotrek (setup.py)
# reportlab
charset-normalizer==3.2.0
# via requests
click==8.1.3
Expand Down Expand Up @@ -85,6 +87,7 @@ coreschema==0.0.4
cssselect2==0.7.0
# via
# cairosvg
# svglib
# weasyprint
datetime==5.2
# via appy
Expand Down Expand Up @@ -172,8 +175,9 @@ drf-yasg==1.21.5
# via
# django-large-image
# geotrek (setup.py)
easy-thumbnails==2.8.5
easy-thumbnails[svg]==2.8.5
# via
# geotrek (setup.py)
# mapentity
# paperclip
env-file==2020.12.3
Expand Down Expand Up @@ -217,7 +221,9 @@ large-image==1.20.3
large-image-source-vips==1.17.2
# via geotrek (setup.py)
lxml==4.9.3
# via mapentity
# via
# mapentity
# svglib
mapentity==8.7.2
# via geotrek (setup.py)
markdown==3.4.4
Expand Down Expand Up @@ -258,6 +264,7 @@ pillow==10.2.0
# geotrek (setup.py)
# large-image
# paperclip
# reportlab
# weasyprint
prompt-toolkit==3.0.39
# via click-repl
Expand Down Expand Up @@ -297,6 +304,10 @@ rcssmin==1.1.1
# via django-compressor
redis==4.5.4
# via geotrek (setup.py)
reportlab==4.1.0
# via
# easy-thumbnails
# svglib
requests==2.31.0
# via
# coreapi
Expand Down Expand Up @@ -326,12 +337,15 @@ soupsieve==2.5
# via beautifulsoup4
sqlparse==0.4.4
# via django
svglib==1.5.1
# via easy-thumbnails
tif2geojson==0.1.3
# via geotrek (setup.py)
tinycss2==1.2.1
# via
# cairosvg
# cssselect2
# svglib
# weasyprint
transaction==3.1.0
# via zodb
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def run(self):
# prod,
'gunicorn',
'sentry-sdk',
'easy-thumbnails[svg]',
],
cmdclass={"build": BuildCommand},
include_package_data=True,
Expand Down

0 comments on commit 8d884d0

Please sign in to comment.