From 716e64de68bc825aaf4330dfaa14dae05034f430 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 6 Nov 2023 08:27:30 -0800 Subject: [PATCH 1/4] Changes notification links for user import/export I found it unexpected that the export notification linked me directly to the file, and wanted the import link to lead me to the import page --- bookwyrm/templates/notifications/items/user_export.html | 6 +++++- bookwyrm/templates/notifications/items/user_import.html | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/notifications/items/user_export.html b/bookwyrm/templates/notifications/items/user_export.html index a7eec4632..d4ab04faa 100644 --- a/bookwyrm/templates/notifications/items/user_export.html +++ b/bookwyrm/templates/notifications/items/user_export.html @@ -1,11 +1,15 @@ {% extends 'notifications/items/layout.html' %} {% load i18n %} +{% block primary_link %}{% spaceless %} +{% url 'prefs-user-export' %} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} {% block description %} - {% url 'prefs-export-file' notification.related_user_export.task_id as url %} + {% url 'prefs-user-export' as url %} {% blocktrans %}Your user export is ready.{% endblocktrans %} {% endblock %} diff --git a/bookwyrm/templates/notifications/items/user_import.html b/bookwyrm/templates/notifications/items/user_import.html index e0b3ddaad..2e9838688 100644 --- a/bookwyrm/templates/notifications/items/user_import.html +++ b/bookwyrm/templates/notifications/items/user_import.html @@ -1,6 +1,10 @@ {% extends 'notifications/items/layout.html' %} {% load i18n %} +{% block primary_link %}{% spaceless %} +{% url 'user-import' %} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} From 85d1760b97a29feca6834fbfdd75467ab3be1399 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 6 Nov 2023 08:41:36 -0800 Subject: [PATCH 2/4] Changes recent exports table I thought both dates seemed less necessary (happy to be told otherwise) and the download link should be more explicit --- .../templates/preferences/export-user.html | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/bookwyrm/templates/preferences/export-user.html b/bookwyrm/templates/preferences/export-user.html index 437b6c7be..b1e36f9d2 100644 --- a/bookwyrm/templates/preferences/export-user.html +++ b/bookwyrm/templates/preferences/export-user.html @@ -38,12 +38,9 @@ - - @@ -56,13 +53,6 @@ {% endif %} {% for job in jobs %} - + {% endfor %} From 3f038b4d67c324a49c647e75d69f1f9ff5620c12 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 6 Nov 2023 09:42:58 -0800 Subject: [PATCH 3/4] Moves if to the right place --- bookwyrm/templates/preferences/export-user.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/preferences/export-user.html b/bookwyrm/templates/preferences/export-user.html index b1e36f9d2..0a45b8b0a 100644 --- a/bookwyrm/templates/preferences/export-user.html +++ b/bookwyrm/templates/preferences/export-user.html @@ -75,9 +75,9 @@ {% trans "Active" %} {% endif %} - {% if job.complete and not job.status == "stopped" and not job.status == "failed" %} - + {% if not jobs %} @@ -76,6 +80,9 @@ {% endif %} +
- {% trans "Date Created" %} + {% trans "Date" %} - {% trans "Last Updated" %} - + {% trans "Status" %}
- {% if job.complete and not job.status == "stopped" and not job.status == "failed" %} -

{{ job.created_date }}

- {% else %} -

{{ job.created_date }}

- {% endif %} -
{{ job.updated_date }} + {% if job.complete and not job.status == "stopped" and not job.status == "failed" %} + +

+ + + + {% trans "Download your export" %} + + +

+ {% endif %}
+ {% if job.complete and not job.status == "stopped" and not job.status == "failed" %}

From 282f7dd8d649dca3fbb7a5ac96e8850eada55e9f Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Tue, 7 Nov 2023 11:04:11 +1100 Subject: [PATCH 4/4] show filesize on user downloads page - add column to user download page to display filesize - adds a filter to display file sizes - don't download the user downloads page from notifications ;) --- .../notifications/items/user_export.html | 2 +- bookwyrm/templates/preferences/export-user.html | 9 ++++++++- bookwyrm/templatetags/utilities.py | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/notifications/items/user_export.html b/bookwyrm/templates/notifications/items/user_export.html index d4ab04faa..1df40dbac 100644 --- a/bookwyrm/templates/notifications/items/user_export.html +++ b/bookwyrm/templates/notifications/items/user_export.html @@ -11,5 +11,5 @@ {% block description %} {% url 'prefs-user-export' as url %} - {% blocktrans %}Your user export is ready.{% endblocktrans %} + {% blocktrans %}Your user export is ready.{% endblocktrans %} {% endblock %} diff --git a/bookwyrm/templates/preferences/export-user.html b/bookwyrm/templates/preferences/export-user.html index 0a45b8b0a..da8f537a6 100644 --- a/bookwyrm/templates/preferences/export-user.html +++ b/bookwyrm/templates/preferences/export-user.html @@ -1,5 +1,6 @@ {% extends 'preferences/layout.html' %} {% load i18n %} +{% load utilities %} {% block title %}{% trans "User Export" %}{% endblock %} @@ -40,9 +41,12 @@

{% trans "Date" %} + {% trans "Status" %} + {% trans "Size" %} +
+ {{ job.export_data|get_file_size }} + {% if job.complete and not job.status == "stopped" and not job.status == "failed" %}

diff --git a/bookwyrm/templatetags/utilities.py b/bookwyrm/templatetags/utilities.py index 42e67990f..3ae14c17c 100644 --- a/bookwyrm/templatetags/utilities.py +++ b/bookwyrm/templatetags/utilities.py @@ -125,3 +125,20 @@ def id_to_username(user_id): value = f"{name}@{domain}" return value + + +@register.filter(name="get_file_size") +def get_file_size(file): + """display the size of a file in human readable terms""" + + try: + raw_size = os.stat(file.path).st_size + if raw_size < 1024: + return f"{raw_size} bytes" + if raw_size < 1024**2: + return f"{raw_size/1024:.2f} KB" + if raw_size < 1024**3: + return f"{raw_size/1024**2:.2f} MB" + return f"{raw_size/1024**3:.2f} GB" + except Exception: # pylint: disable=broad-except + return ""