diff --git a/bookwyrm/templates/notifications/items/user_export.html b/bookwyrm/templates/notifications/items/user_export.html index a7eec4632..1df40dbac 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 %} - {% blocktrans %}Your user export is ready.{% endblocktrans %} + {% 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 %} diff --git a/bookwyrm/templates/preferences/export-user.html b/bookwyrm/templates/preferences/export-user.html index 437b6c7be..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 %} @@ -38,14 +39,14 @@ - + {% if not jobs %} @@ -56,13 +57,6 @@ {% endif %} {% for job in jobs %} - + + {% endfor %}
- {% trans "Date Created" %} - - {% trans "Last Updated" %} + {% trans "Date" %} {% trans "Status" %} + {% trans "Size" %} +
- {% if job.complete and not job.status == "stopped" and not job.status == "failed" %} -

{{ job.created_date }}

- {% else %} -

{{ job.created_date }}

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

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

+ {% endif %} +
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 ""