From 4a2e191d923751cb67186b019a8cf7ab7c046441 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 8 Jul 2022 11:29:15 -0700 Subject: [PATCH 1/4] Refactors dashboard warnings This cleans up the display so that they don't get all squished when a bunch are present, and creates a layout to make them more DRY --- .../settings/dashboard/dashboard.html | 65 ++++--------------- .../dashboard/warnings/domain_review.html | 17 +++++ .../dashboard/warnings/email_config.html | 15 +++++ .../settings/dashboard/warnings/invites.html | 17 +++++ .../settings/dashboard/warnings/layout.html | 6 ++ .../settings/dashboard/warnings/reports.html | 17 +++++ .../dashboard/warnings/update_version.html | 14 ++++ 7 files changed, 100 insertions(+), 51 deletions(-) create mode 100644 bookwyrm/templates/settings/dashboard/warnings/domain_review.html create mode 100644 bookwyrm/templates/settings/dashboard/warnings/email_config.html create mode 100644 bookwyrm/templates/settings/dashboard/warnings/invites.html create mode 100644 bookwyrm/templates/settings/dashboard/warnings/layout.html create mode 100644 bookwyrm/templates/settings/dashboard/warnings/reports.html create mode 100644 bookwyrm/templates/settings/dashboard/warnings/update_version.html diff --git a/bookwyrm/templates/settings/dashboard/dashboard.html b/bookwyrm/templates/settings/dashboard/dashboard.html index 10d7f4f22..46f36f286 100644 --- a/bookwyrm/templates/settings/dashboard/dashboard.html +++ b/bookwyrm/templates/settings/dashboard/dashboard.html @@ -38,60 +38,23 @@
{% if email_config_error %} -
- - {% blocktrans trimmed %} - Your outgoing email address, {{ email_sender }}, may be misconfigured. - {% endblocktrans %} - {% trans "Check the EMAIL_SENDER_NAME and EMAIL_SENDER_DOMAIN in your .env." %} - -
- {% endif %} - - {% if reports %} - - {% endif %} - - {% if pending_domains %} - - {% endif %} - - {% if not site.allow_registration and site.allow_invite_requests and invite_requests %} - + {% include 'settings/dashboard/warnings/email_config.html' with warning_level="danger" fullwidth=True %} {% endif %} {% if current_version %} - + {% include 'settings/dashboard/warnings/update_version.html' with warning_level="warning" fullwidth=True %} + {% endif %} + + {% if reports %} + {% include 'settings/dashboard/warnings/reports.html' with warning_level="warning" %} + {% endif %} + + {% if pending_domains %} + {% include 'settings/dashboard/warnings/domain_review.html' with warning_level="primary" %} + {% endif %} + + {% if not site.allow_registration and site.allow_invite_requests and invite_requests %} + {% include 'settings/dashboard/warnings/invites.html' with warning_level="success" %} {% endif %}
diff --git a/bookwyrm/templates/settings/dashboard/warnings/domain_review.html b/bookwyrm/templates/settings/dashboard/warnings/domain_review.html new file mode 100644 index 000000000..3ae11e2f8 --- /dev/null +++ b/bookwyrm/templates/settings/dashboard/warnings/domain_review.html @@ -0,0 +1,17 @@ +{% extends 'settings/dashboard/warnings/layout.html' %} +{% load i18n %} +{% load humanize %} + +{% block warning_link %} +{% url 'settings-link-domain' %} +{% endblock %} + +{% block warning_text %} + +{% blocktrans trimmed count counter=pending_domains with display_count=pending_domains|intcomma %} +{{ display_count }} domain needs review +{% plural %} +{{ display_count }} domains need review +{% endblocktrans %} + +{% endblock %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/email_config.html b/bookwyrm/templates/settings/dashboard/warnings/email_config.html new file mode 100644 index 000000000..7c597705d --- /dev/null +++ b/bookwyrm/templates/settings/dashboard/warnings/email_config.html @@ -0,0 +1,15 @@ +{% extends 'settings/dashboard/warnings/layout.html' %} +{% load i18n %} + +{% block warning_link %} +https://docs.joinbookwyrm.com/install-prod.html +{% endblock %} + +{% block warning_text %} + +{% blocktrans trimmed %} +Your outgoing email address, {{ email_sender }}, may be misconfigured. +{% endblocktrans %} +{% trans "Check the EMAIL_SENDER_NAME and EMAIL_SENDER_DOMAIN in your .env file." %} + +{% endblock %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/invites.html b/bookwyrm/templates/settings/dashboard/warnings/invites.html new file mode 100644 index 000000000..436596f91 --- /dev/null +++ b/bookwyrm/templates/settings/dashboard/warnings/invites.html @@ -0,0 +1,17 @@ +{% extends 'settings/dashboard/warnings/layout.html' %} +{% load i18n %} +{% load humanize %} + +{% block warning_link %} +{% url 'settings-invite-requests' %} +{% endblock %} + +{% block warning_text %} + +{% blocktrans trimmed count counter=invite_requests with display_count=invite_requests|intcomma %} +{{ display_count }} invite request +{% plural %} +{{ display_count }} invite requests +{% endblocktrans %} + +{% endblock %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/layout.html b/bookwyrm/templates/settings/dashboard/warnings/layout.html new file mode 100644 index 000000000..b1a6f06c2 --- /dev/null +++ b/bookwyrm/templates/settings/dashboard/warnings/layout.html @@ -0,0 +1,6 @@ +
+ + {% block warning_text %}{% endblock %} + +
+ diff --git a/bookwyrm/templates/settings/dashboard/warnings/reports.html b/bookwyrm/templates/settings/dashboard/warnings/reports.html new file mode 100644 index 000000000..b55695806 --- /dev/null +++ b/bookwyrm/templates/settings/dashboard/warnings/reports.html @@ -0,0 +1,17 @@ +{% extends 'settings/dashboard/warnings/layout.html' %} +{% load i18n %} +{% load humanize %} + +{% block warning_link %} +{% url 'settings-reports' %} +{% endblock %} + +{% block warning_text %} + +{% blocktrans trimmed count counter=reports with display_count=reports|intcomma %} +{{ display_count }} open report +{% plural %} +{{ display_count }} open reports +{% endblocktrans %} + +{% endblock %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/update_version.html b/bookwyrm/templates/settings/dashboard/warnings/update_version.html new file mode 100644 index 000000000..f12e20ffd --- /dev/null +++ b/bookwyrm/templates/settings/dashboard/warnings/update_version.html @@ -0,0 +1,14 @@ +{% extends 'settings/dashboard/warnings/layout.html' %} +{% load i18n %} + +{% block warning_link %} +https://docs.joinbookwyrm.com/updating.html +{% endblock %} + +{% block warning_text %} + +{% blocktrans trimmed with current=current_version available=available_version %} +An update is available! You're running v{{ current }} and the latest release is {{ available }}. +{% endblocktrans %} + +{% endblock %} From ba7ae46c758f89fb0d7b5607a60bf3a6176e1769 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 8 Jul 2022 11:58:55 -0700 Subject: [PATCH 2/4] Adds warnings for missing privacy policies and codes of conduct --- .../templates/settings/dashboard/dashboard.html | 16 ++++++++++++++++ .../dashboard/warnings/missing_conduct.html | 12 ++++++++++++ .../dashboard/warnings/missing_privacy.html | 12 ++++++++++++ bookwyrm/views/admin/dashboard.py | 13 +++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 bookwyrm/templates/settings/dashboard/warnings/missing_conduct.html create mode 100644 bookwyrm/templates/settings/dashboard/warnings/missing_privacy.html diff --git a/bookwyrm/templates/settings/dashboard/dashboard.html b/bookwyrm/templates/settings/dashboard/dashboard.html index 46f36f286..ea7a8a796 100644 --- a/bookwyrm/templates/settings/dashboard/dashboard.html +++ b/bookwyrm/templates/settings/dashboard/dashboard.html @@ -45,6 +45,22 @@ {% include 'settings/dashboard/warnings/update_version.html' with warning_level="warning" fullwidth=True %} {% endif %} + {% if missing_privacy or missing_conduct %} +
+ {% if missing_privacy %} + {% include 'settings/dashboard/warnings/missing_privacy.html' with warning_level="danger" %} + {% endif %} + + {% if missing_conduct %} + {% include 'settings/dashboard/warnings/missing_conduct.html' with warning_level="warning" %} + {% endif %} +
+ {% endif %} + + {% if current_version %} + {% include 'settings/dashboard/warnings/update_version.html' with warning_level="warning" fullwidth=True %} + {% endif %} + {% if reports %} {% include 'settings/dashboard/warnings/reports.html' with warning_level="warning" %} {% endif %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/missing_conduct.html b/bookwyrm/templates/settings/dashboard/warnings/missing_conduct.html new file mode 100644 index 000000000..30a3f7f33 --- /dev/null +++ b/bookwyrm/templates/settings/dashboard/warnings/missing_conduct.html @@ -0,0 +1,12 @@ +{% extends 'settings/dashboard/warnings/layout.html' %} +{% load i18n %} + +{% block warning_link %} +{% url 'settings-site' %}#instance-info +{% endblock %} + +{% block warning_text %} + +{% trans "Your instance is missing a code of conduct." %} + +{% endblock %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/missing_privacy.html b/bookwyrm/templates/settings/dashboard/warnings/missing_privacy.html new file mode 100644 index 000000000..dd0f3b1d1 --- /dev/null +++ b/bookwyrm/templates/settings/dashboard/warnings/missing_privacy.html @@ -0,0 +1,12 @@ +{% extends 'settings/dashboard/warnings/layout.html' %} +{% load i18n %} + +{% block warning_link %} +{% url 'settings-site' %}#instance-info +{% endblock %} + +{% block warning_text %} + +{% trans "Your instance is missing a privacy policy." %} + +{% endblock %} diff --git a/bookwyrm/views/admin/dashboard.py b/bookwyrm/views/admin/dashboard.py index df34fe5bf..d4abaebaf 100644 --- a/bookwyrm/views/admin/dashboard.py +++ b/bookwyrm/views/admin/dashboard.py @@ -42,6 +42,19 @@ class Dashboard(View): "email_sender" ] = f"{settings.EMAIL_SENDER_NAME}@{settings.EMAIL_SENDER_DOMAIN}" + site = models.SiteSettings.objects.get() + # other warnings + data["missing_conduct"] = ( + not site.code_of_conduct + or site.code_of_conduct + == site._meta.get_field("code_of_conduct").get_default() + ) + data["missing_privacy"] = ( + not site.privacy_policy + or site.privacy_policy + == site._meta.get_field("privacy_policy").get_default() + ) + # check version try: release = get_data(settings.RELEASE_API, timeout=3) From 36553ef2a99a1df1509cb392d4066acb99baf579 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 8 Jul 2022 12:22:23 -0700 Subject: [PATCH 3/4] Suppress protected-access warning on admin dashboard --- bookwyrm/views/admin/dashboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/views/admin/dashboard.py b/bookwyrm/views/admin/dashboard.py index d4abaebaf..19583bfa1 100644 --- a/bookwyrm/views/admin/dashboard.py +++ b/bookwyrm/views/admin/dashboard.py @@ -43,7 +43,7 @@ class Dashboard(View): ] = f"{settings.EMAIL_SENDER_NAME}@{settings.EMAIL_SENDER_DOMAIN}" site = models.SiteSettings.objects.get() - # other warnings + # pylint: disable=protected-access data["missing_conduct"] = ( not site.code_of_conduct or site.code_of_conduct From 147d092eac1a77bfd7bd8b3626f93f4ce231ae4e Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 8 Jul 2022 15:29:55 -0700 Subject: [PATCH 4/4] Removes line breaks from warning links --- .../templates/settings/dashboard/warnings/domain_review.html | 4 +--- .../templates/settings/dashboard/warnings/email_config.html | 4 +--- bookwyrm/templates/settings/dashboard/warnings/invites.html | 4 +--- bookwyrm/templates/settings/dashboard/warnings/layout.html | 1 - .../settings/dashboard/warnings/missing_conduct.html | 4 +--- .../settings/dashboard/warnings/missing_privacy.html | 4 +--- bookwyrm/templates/settings/dashboard/warnings/reports.html | 4 +--- .../templates/settings/dashboard/warnings/update_version.html | 4 +--- 8 files changed, 7 insertions(+), 22 deletions(-) diff --git a/bookwyrm/templates/settings/dashboard/warnings/domain_review.html b/bookwyrm/templates/settings/dashboard/warnings/domain_review.html index 3ae11e2f8..d03971f92 100644 --- a/bookwyrm/templates/settings/dashboard/warnings/domain_review.html +++ b/bookwyrm/templates/settings/dashboard/warnings/domain_review.html @@ -2,9 +2,7 @@ {% load i18n %} {% load humanize %} -{% block warning_link %} -{% url 'settings-link-domain' %} -{% endblock %} +{% block warning_link %}{% url 'settings-link-domain' %}{% endblock %} {% block warning_text %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/email_config.html b/bookwyrm/templates/settings/dashboard/warnings/email_config.html index 7c597705d..26ad5b1d7 100644 --- a/bookwyrm/templates/settings/dashboard/warnings/email_config.html +++ b/bookwyrm/templates/settings/dashboard/warnings/email_config.html @@ -1,9 +1,7 @@ {% extends 'settings/dashboard/warnings/layout.html' %} {% load i18n %} -{% block warning_link %} -https://docs.joinbookwyrm.com/install-prod.html -{% endblock %} +{% block warning_link %}https://docs.joinbookwyrm.com/install-prod.html{% endblock %} {% block warning_text %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/invites.html b/bookwyrm/templates/settings/dashboard/warnings/invites.html index 436596f91..34d278f40 100644 --- a/bookwyrm/templates/settings/dashboard/warnings/invites.html +++ b/bookwyrm/templates/settings/dashboard/warnings/invites.html @@ -2,9 +2,7 @@ {% load i18n %} {% load humanize %} -{% block warning_link %} -{% url 'settings-invite-requests' %} -{% endblock %} +{% block warning_link %}{% url 'settings-invite-requests' %}{% endblock %} {% block warning_text %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/layout.html b/bookwyrm/templates/settings/dashboard/warnings/layout.html index b1a6f06c2..7284530fe 100644 --- a/bookwyrm/templates/settings/dashboard/warnings/layout.html +++ b/bookwyrm/templates/settings/dashboard/warnings/layout.html @@ -3,4 +3,3 @@ {% block warning_text %}{% endblock %} - diff --git a/bookwyrm/templates/settings/dashboard/warnings/missing_conduct.html b/bookwyrm/templates/settings/dashboard/warnings/missing_conduct.html index 30a3f7f33..aa0b431f2 100644 --- a/bookwyrm/templates/settings/dashboard/warnings/missing_conduct.html +++ b/bookwyrm/templates/settings/dashboard/warnings/missing_conduct.html @@ -1,9 +1,7 @@ {% extends 'settings/dashboard/warnings/layout.html' %} {% load i18n %} -{% block warning_link %} -{% url 'settings-site' %}#instance-info -{% endblock %} +{% block warning_link %}{% url 'settings-site' %}#instance-info{% endblock %} {% block warning_text %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/missing_privacy.html b/bookwyrm/templates/settings/dashboard/warnings/missing_privacy.html index dd0f3b1d1..87407632a 100644 --- a/bookwyrm/templates/settings/dashboard/warnings/missing_privacy.html +++ b/bookwyrm/templates/settings/dashboard/warnings/missing_privacy.html @@ -1,9 +1,7 @@ {% extends 'settings/dashboard/warnings/layout.html' %} {% load i18n %} -{% block warning_link %} -{% url 'settings-site' %}#instance-info -{% endblock %} +{% block warning_link %}{% url 'settings-site' %}#instance-info{% endblock %} {% block warning_text %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/reports.html b/bookwyrm/templates/settings/dashboard/warnings/reports.html index b55695806..885f94789 100644 --- a/bookwyrm/templates/settings/dashboard/warnings/reports.html +++ b/bookwyrm/templates/settings/dashboard/warnings/reports.html @@ -2,9 +2,7 @@ {% load i18n %} {% load humanize %} -{% block warning_link %} -{% url 'settings-reports' %} -{% endblock %} +{% block warning_link %}{% url 'settings-reports' %}{% endblock %} {% block warning_text %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/update_version.html b/bookwyrm/templates/settings/dashboard/warnings/update_version.html index f12e20ffd..b04b0a624 100644 --- a/bookwyrm/templates/settings/dashboard/warnings/update_version.html +++ b/bookwyrm/templates/settings/dashboard/warnings/update_version.html @@ -1,9 +1,7 @@ {% extends 'settings/dashboard/warnings/layout.html' %} {% load i18n %} -{% block warning_link %} -https://docs.joinbookwyrm.com/updating.html -{% endblock %} +{% block warning_link %}https://docs.joinbookwyrm.com/updating.html{% endblock %} {% block warning_text %}