Skip to content

Commit 82c6fa8

Browse files
authored
Merge branch 'master' into fix/docs
2 parents a574a44 + 7d7acdd commit 82c6fa8

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

.github/workflows/frontend.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push]
44

55
jobs:
66
gulp:
7-
runs-on: ubuntu-20.04
7+
runs-on: ubuntu-latest
88
strategy:
99
matrix:
1010
node-version: [16.20.x]

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
# args: [--target-version, "2.2"]
2222

2323
- repo: https://github.com/PyCQA/flake8
24-
rev: 7.2.0
24+
rev: 7.3.0
2525
hooks:
2626
- id: flake8
2727

filer/templatetags/filer_admin_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def get_aspect_ratio_and_download_url(context, detail, file, height, width):
190190
# because they don't really have width or height
191191
if file.width:
192192
width, height = 210, ceil(210 / file.width * file.height)
193-
context['sidebar_image_ratio'] = file.width / 210
193+
context['sidebar_image_ratio'] = '%.6f' % (file.width / 210)
194194
return height, width, context
195195

196196

tests/test_admin.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,6 +1935,22 @@ def test_file_icon_with_size(self):
19351935
self.assertNotIn('sidebar_image_ratio', context.keys())
19361936
self.assertIn('download_url', context.keys())
19371937

1938+
def test_sidebar_image_ratio_format(self):
1939+
"""
1940+
Test that sidebar_image_ratio is formatted as a string with 6 decimal places
1941+
to ensure consistent formatting regardless of locale settings
1942+
"""
1943+
image = Image.objects.create(name='test.jpg')
1944+
image._width = 100
1945+
image._height = 200
1946+
image.save()
1947+
context = {}
1948+
height, width, context = get_aspect_ratio_and_download_url(context=context, detail=True, file=image, height=40, width=40)
1949+
self.assertIsInstance(context['sidebar_image_ratio'], str)
1950+
expected_ratio = '%.6f' % (image.width / 210)
1951+
self.assertEqual(context['sidebar_image_ratio'], expected_ratio)
1952+
self.assertEqual(context['sidebar_image_ratio'], '0.476190')
1953+
19381954

19391955
class AdditionalAdminFormsTests(TestCase):
19401956
def setUp(self):

0 commit comments

Comments
 (0)