Skip to content

download:download_release_detail view: Display file sizes with human-readable units #2354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2024

Conversation

noelleleigh
Copy link
Contributor

@noelleleigh noelleleigh commented Dec 31, 2023

When viewing the download files for a given release, their file sizes are displayed in bytes, which can be 8 digits long, making them difficult to read. To remedy this, the filesizeformat template filter can be used to reduce the number of digits to a more easily read amount.

Before

See how the numbers in the File Size column are very large and difficult to compare.

Table of releases where the File Size column is in units of bytes and contains large numbers

After

Now see how the values in the File Size column can be quickly parsed and compared visually.

Table of releases where the File Size column is in units of megabytes and contains 2- to 3-digit numbers

Unit test

A small subtest has been added to enforce this display change without affecting the rest of the testing method:

docker-compose run --rm web \
./manage.py test -k \
downloads.tests.test_views.DownloadViewsTests.test_download_release_detail

Make the release file sizes more readable by passing them through the
[filesizeformat filter][1].

[1]: https://docs.djangoproject.com/en/2.2/ref/templates/builtins/#filesizeformat
Adds a subTest to
downloads.tests.test_views.DownloadViewsTests.test_download_release_detail
to verify that the file size is displayed in MB.
@ambv ambv merged commit c1b800b into python:main Feb 21, 2024
@noelleleigh noelleleigh deleted the downloads/release_detail-filesizeformat branch February 21, 2024 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants