scidsg / frontpage

A self-hosted, privacy-focused publishing platform for autonomous and independent newsrooms.
https://ddosecrets.news
GNU Affero General Public License v3.0
14 stars 2 forks source link

Update routes.py #34

Closed glenn-sorrentino closed 8 months ago

glenn-sorrentino commented 8 months ago

Closes #33

Proposed Changes

This fix addresses the issue where articles with an empty string as their download_size cause a ValueError by trying to convert an empty string to an integer. The modification ensures the conversion and formatting only occur when article.download_size is neither None nor an empty string.

Files Affected

Modifications


# In frontpage/routes.py, within the article view function:

- format_size(int(article.download_size)) if article.download_size is not None else None
+ format_size(int(article.download_size)) if article.download_size not in [None, ''] else None