diff --git a/bookwyrm/templates/preferences/edit_user.html b/bookwyrm/templates/preferences/edit_user.html index c51ef363..f3cabbc7 100644 --- a/bookwyrm/templates/preferences/edit_user.html +++ b/bookwyrm/templates/preferences/edit_user.html @@ -62,7 +62,7 @@ -
+

{% trans "Display preferences" %}

@@ -94,7 +94,7 @@
-
+

{% trans "Privacy" %}

diff --git a/bookwyrm/templates/settings/announcement.html b/bookwyrm/templates/settings/announcements/announcement.html similarity index 96% rename from bookwyrm/templates/settings/announcement.html rename to bookwyrm/templates/settings/announcements/announcement.html index b3375bb5..37dba06f 100644 --- a/bookwyrm/templates/settings/announcement.html +++ b/bookwyrm/templates/settings/announcements/announcement.html @@ -26,7 +26,7 @@ {% block panel %}
- {% include 'settings/announcement_form.html' with controls_text="edit_announcement" %} + {% include 'settings/announcements/announcement_form.html' with controls_text="edit_announcement" %}
diff --git a/bookwyrm/templates/settings/announcement_form.html b/bookwyrm/templates/settings/announcements/announcement_form.html similarity index 100% rename from bookwyrm/templates/settings/announcement_form.html rename to bookwyrm/templates/settings/announcements/announcement_form.html diff --git a/bookwyrm/templates/settings/announcements.html b/bookwyrm/templates/settings/announcements/announcements.html similarity index 90% rename from bookwyrm/templates/settings/announcements.html rename to bookwyrm/templates/settings/announcements/announcements.html index 2c57ae78..c86ecf3e 100644 --- a/bookwyrm/templates/settings/announcements.html +++ b/bookwyrm/templates/settings/announcements/announcements.html @@ -11,7 +11,7 @@ {% block panel %}
- {% include 'settings/announcement_form.html' with controls_text="create_announcement" %} + {% include 'settings/announcements/announcement_form.html' with controls_text="create_announcement" %}
@@ -48,11 +48,10 @@ {% if announcement.active %}{% trans "active" %}{% else %}{% trans "inactive" %}{% endif %} {% endfor %} + {% if not announcements %} + {% trans "No announcements found" %} + {% endif %} - - {% if not announcements %} -

{% trans "No announcements found." %}

- {% endif %}
{% include 'snippets/pagination.html' with page=announcements path=request.path %} diff --git a/bookwyrm/templates/settings/dashboard.html b/bookwyrm/templates/settings/dashboard/dashboard.html similarity index 80% rename from bookwyrm/templates/settings/dashboard.html rename to bookwyrm/templates/settings/dashboard/dashboard.html index 608d32c9..fbf3ff72 100644 --- a/bookwyrm/templates/settings/dashboard.html +++ b/bookwyrm/templates/settings/dashboard/dashboard.html @@ -67,27 +67,27 @@
-
-
-
@@ -115,6 +115,6 @@ {% block scripts %} -{% include 'settings/dashboard_user_chart.html' %} -{% include 'settings/dashboard_status_chart.html' %} +{% include 'settings/dashboard/dashboard_user_chart.html' %} +{% include 'settings/dashboard/dashboard_status_chart.html' %} {% endblock %} diff --git a/bookwyrm/templates/settings/dashboard_status_chart.html b/bookwyrm/templates/settings/dashboard/dashboard_status_chart.html similarity index 100% rename from bookwyrm/templates/settings/dashboard_status_chart.html rename to bookwyrm/templates/settings/dashboard/dashboard_status_chart.html diff --git a/bookwyrm/templates/settings/dashboard_user_chart.html b/bookwyrm/templates/settings/dashboard/dashboard_user_chart.html similarity index 100% rename from bookwyrm/templates/settings/dashboard_user_chart.html rename to bookwyrm/templates/settings/dashboard/dashboard_user_chart.html diff --git a/bookwyrm/templates/settings/domain_form.html b/bookwyrm/templates/settings/email_blocklist/domain_form.html similarity index 100% rename from bookwyrm/templates/settings/domain_form.html rename to bookwyrm/templates/settings/email_blocklist/domain_form.html diff --git a/bookwyrm/templates/settings/email_blocklist.html b/bookwyrm/templates/settings/email_blocklist/email_blocklist.html similarity index 89% rename from bookwyrm/templates/settings/email_blocklist.html rename to bookwyrm/templates/settings/email_blocklist/email_blocklist.html index ea63b954..888f6a28 100644 --- a/bookwyrm/templates/settings/email_blocklist.html +++ b/bookwyrm/templates/settings/email_blocklist/email_blocklist.html @@ -12,7 +12,7 @@ {% endblock %} {% block panel %} -{% include 'settings/domain_form.html' with controls_text="add_domain" class="block" %} +{% include 'settings/email_blocklist/domain_form.html' with controls_text="add_domain" class="block" %}

{% trans "When someone tries to register with an email from this domain, no account will be created. The registration process will appear to have worked." %} @@ -55,7 +55,11 @@ {% endfor %} + {% if not domains.exists %} + {% trans "No email domains currently blocked" %} + {% endif %} + {% endblock %} diff --git a/bookwyrm/templates/settings/edit_server.html b/bookwyrm/templates/settings/federation/edit_instance.html similarity index 92% rename from bookwyrm/templates/settings/edit_server.html rename to bookwyrm/templates/settings/federation/edit_instance.html index 452316e4..7c2e6be6 100644 --- a/bookwyrm/templates/settings/edit_server.html +++ b/bookwyrm/templates/settings/federation/edit_instance.html @@ -33,6 +33,8 @@

{{ error | escape }}

{% endfor %}
+
+
@@ -43,6 +45,8 @@
+
+
@@ -51,6 +55,8 @@

{{ error | escape }}

{% endfor %}
+
+
@@ -62,7 +68,7 @@
- +
diff --git a/bookwyrm/templates/settings/federated_server.html b/bookwyrm/templates/settings/federation/instance.html similarity index 56% rename from bookwyrm/templates/settings/federated_server.html rename to bookwyrm/templates/settings/federation/instance.html index 6a1a5488..f0e48a97 100644 --- a/bookwyrm/templates/settings/federated_server.html +++ b/bookwyrm/templates/settings/federation/instance.html @@ -19,18 +19,14 @@

{% trans "Details" %}

-
-
{% trans "Software:" %}
-
{{ server.application_type }}
-
-
-
{% trans "Version:" %}
-
{{ server.application_version }}
-
-
-
{% trans "Status:" %}
-
{{ server.get_status_display }}
-
+
{% trans "Software:" %}
+
{{ server.application_type }}
+ +
{% trans "Version:" %}
+
{{ server.application_version }}
+ +
{% trans "Status:" %}
+
{{ server.get_status_display }}
@@ -39,38 +35,32 @@

{% trans "Activity" %}

-
-
{% trans "Users:" %}
-
- {{ users.count }} - {% if server.user_set.count %}({% trans "View all" %}){% endif %} -
-
-
-
{% trans "Reports:" %}
-
- {{ reports.count }} - {% if reports.count %}({% trans "View all" %}){% endif %} -
-
-
-
{% trans "Followed by us:" %}
-
- {{ followed_by_us.count }} -
-
-
-
{% trans "Followed by them:" %}
-
- {{ followed_by_them.count }} -
-
-
-
{% trans "Blocked by us:" %}
-
- {{ blocked_by_us.count }} -
-
+
{% trans "Users:" %}
+
+ {{ users.count }} + {% if server.user_set.count %}({% trans "View all" %}){% endif %} +
+ +
{% trans "Reports:" %}
+
+ {{ reports.count }} + {% if reports.count %}({% trans "View all" %}){% endif %} +
+ +
{% trans "Followed by us:" %}
+
+ {{ followed_by_us.count }} +
+ +
{% trans "Followed by them:" %}
+
+ {{ followed_by_them.count }} +
+ +
{% trans "Blocked by us:" %}
+
+ {{ blocked_by_us.count }} +
@@ -86,14 +76,13 @@ {% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_notes" %} - {% if server.notes %} -
{{ server.notes|to_markdown|safe }}
- {% endif %} + {% trans "No notes" as null_text %} +
{{ server.notes|to_markdown|default:null_text|safe }}
{% csrf_token %}

- +

{% trans "Cancel" as button_text %} diff --git a/bookwyrm/templates/settings/server_blocklist.html b/bookwyrm/templates/settings/federation/instance_blocklist.html similarity index 100% rename from bookwyrm/templates/settings/server_blocklist.html rename to bookwyrm/templates/settings/federation/instance_blocklist.html diff --git a/bookwyrm/templates/settings/federation.html b/bookwyrm/templates/settings/federation/instance_list.html similarity index 95% rename from bookwyrm/templates/settings/federation.html rename to bookwyrm/templates/settings/federation/instance_list.html index ffbabca3..61afb317 100644 --- a/bookwyrm/templates/settings/federation.html +++ b/bookwyrm/templates/settings/federation/instance_list.html @@ -59,7 +59,11 @@ {{ server.get_status_display }} {% endfor %} + {% if not servers %} + {% trans "No instances found" %} + {% endif %} + {% include 'snippets/pagination.html' with page=servers path=request.path %} {% endblock %} diff --git a/bookwyrm/templates/settings/invite_request_filters.html b/bookwyrm/templates/settings/invites/invite_request_filters.html similarity index 66% rename from bookwyrm/templates/settings/invite_request_filters.html rename to bookwyrm/templates/settings/invites/invite_request_filters.html index c55cc069..a29518d8 100644 --- a/bookwyrm/templates/settings/invite_request_filters.html +++ b/bookwyrm/templates/settings/invites/invite_request_filters.html @@ -1,6 +1,6 @@ {% extends 'snippets/filters_panel/filters_panel.html' %} {% block filter_fields %} -{% include 'settings/status_filter.html' %} +{% include 'settings/invites/status_filter.html' %} {% endblock %} diff --git a/bookwyrm/templates/settings/manage_invite_requests.html b/bookwyrm/templates/settings/invites/manage_invite_requests.html similarity index 97% rename from bookwyrm/templates/settings/manage_invite_requests.html rename to bookwyrm/templates/settings/invites/manage_invite_requests.html index e0cfd646..fb7c0b1f 100644 --- a/bookwyrm/templates/settings/manage_invite_requests.html +++ b/bookwyrm/templates/settings/invites/manage_invite_requests.html @@ -26,7 +26,7 @@ {% endif %} ({{ count }}) - {% include 'settings/invite_request_filters.html' %} + {% include 'settings/invites/invite_request_filters.html' %} {% url 'settings-invite-requests' as url %} @@ -47,7 +47,7 @@ {% if not requests %} - + {% endif %} {% for req in requests %} diff --git a/bookwyrm/templates/settings/manage_invites.html b/bookwyrm/templates/settings/invites/manage_invites.html similarity index 100% rename from bookwyrm/templates/settings/manage_invites.html rename to bookwyrm/templates/settings/invites/manage_invites.html diff --git a/bookwyrm/templates/settings/status_filter.html b/bookwyrm/templates/settings/invites/status_filter.html similarity index 100% rename from bookwyrm/templates/settings/status_filter.html rename to bookwyrm/templates/settings/invites/status_filter.html diff --git a/bookwyrm/templates/settings/ip_address_form.html b/bookwyrm/templates/settings/ip_blocklist/ip_address_form.html similarity index 100% rename from bookwyrm/templates/settings/ip_address_form.html rename to bookwyrm/templates/settings/ip_blocklist/ip_address_form.html diff --git a/bookwyrm/templates/settings/ip_blocklist.html b/bookwyrm/templates/settings/ip_blocklist/ip_blocklist.html similarity index 85% rename from bookwyrm/templates/settings/ip_blocklist.html rename to bookwyrm/templates/settings/ip_blocklist/ip_blocklist.html index c978c126..239baa84 100644 --- a/bookwyrm/templates/settings/ip_blocklist.html +++ b/bookwyrm/templates/settings/ip_blocklist/ip_blocklist.html @@ -12,7 +12,7 @@ {% endblock %} {% block panel %} -{% include 'settings/ip_address_form.html' with controls_text="add_address" class="block" %} +{% include 'settings/ip_blocklist/ip_address_form.html' with controls_text="add_address" class="block" %}

{% trans "Any traffic from this IP address will get a 404 response when trying to access any part of the application." %} @@ -42,6 +42,9 @@

{% endfor %} + {% if not addresses.exists %} + + {% endif %}
{% trans "Action" %}
{% trans "No requests" %}
{% trans "No requests" %}
{% trans "No IP addresses currently blocked" %}
{% endblock %} diff --git a/bookwyrm/templates/settings/ip_tooltip.html b/bookwyrm/templates/settings/ip_blocklist/ip_tooltip.html similarity index 100% rename from bookwyrm/templates/settings/ip_tooltip.html rename to bookwyrm/templates/settings/ip_blocklist/ip_tooltip.html diff --git a/bookwyrm/templates/settings/layout.html b/bookwyrm/templates/settings/layout.html index dd315347..d7a840af 100644 --- a/bookwyrm/templates/settings/layout.html +++ b/bookwyrm/templates/settings/layout.html @@ -74,14 +74,7 @@
  • {% url 'settings-site' as url %} {% trans "Site Settings" %} - {% if url in request.path %} - - {% endif %} + {% block site-subtabs %}{% endblock %}
  • {% endif %} diff --git a/bookwyrm/templates/moderation/report.html b/bookwyrm/templates/settings/reports/report.html similarity index 78% rename from bookwyrm/templates/moderation/report.html rename to bookwyrm/templates/settings/reports/report.html index d0e4026a..37593f3c 100644 --- a/bookwyrm/templates/moderation/report.html +++ b/bookwyrm/templates/settings/reports/report.html @@ -3,20 +3,21 @@ {% load humanize %} {% block title %}{% blocktrans with report_id=report.id username=report.user.username %}Report #{{ report_id }}: {{ username }}{% endblocktrans %}{% endblock %} -{% block header %}{% blocktrans with report_id=report.id username=report.user.username %}Report #{{ report_id }}: {{ username }}{% endblocktrans %}{% endblock %} + +{% block header %} +{% blocktrans with report_id=report.id username=report.user.username %}Report #{{ report_id }}: {{ username }}{% endblocktrans %} +{% trans "Back to reports" %} +{% endblock %} {% block panel %} -
    - {% trans "Back to reports" %} -
    - {% include 'moderation/report_preview.html' with report=report %} + {% include 'settings/reports/report_preview.html' with report=report %}
    -{% include 'user_admin/user_info.html' with user=report.user %} +{% include 'settings/users/user_info.html' with user=report.user %} -{% include 'user_admin/user_moderation_actions.html' with user=report.user %} +{% include 'settings/users/user_moderation_actions.html' with user=report.user %}

    {% trans "Moderator Comments" %}

    diff --git a/bookwyrm/templates/moderation/report_preview.html b/bookwyrm/templates/settings/reports/report_preview.html similarity index 100% rename from bookwyrm/templates/moderation/report_preview.html rename to bookwyrm/templates/settings/reports/report_preview.html diff --git a/bookwyrm/templates/moderation/reports.html b/bookwyrm/templates/settings/reports/reports.html similarity index 90% rename from bookwyrm/templates/moderation/reports.html rename to bookwyrm/templates/settings/reports/reports.html index c83f626f..c72fd03d 100644 --- a/bookwyrm/templates/moderation/reports.html +++ b/bookwyrm/templates/settings/reports/reports.html @@ -30,7 +30,7 @@
    -{% include 'user_admin/user_admin_filters.html' %} +{% include 'settings/users/user_admin_filters.html' %}
    {% if not reports %} @@ -39,7 +39,7 @@ {% for report in reports %}
    - {% include 'moderation/report_preview.html' with report=report %} + {% include 'settings/reports/report_preview.html' with report=report %}
    {% endfor %}
    diff --git a/bookwyrm/templates/settings/site.html b/bookwyrm/templates/settings/site.html index 50895485..da5b7705 100644 --- a/bookwyrm/templates/settings/site.html +++ b/bookwyrm/templates/settings/site.html @@ -5,36 +5,46 @@ {% block header %}{% trans "Site Settings" %}{% endblock %} -{% block panel %} +{% block site-subtabs %} + +{% endblock %} +{% block panel %} {% csrf_token %}

    {% trans "Instance Info" %}

    -
    - - {{ site_form.name }} -
    -
    - - {{ site_form.instance_tagline }} -
    -
    - - {{ site_form.instance_description }} -
    -
    - -

    {% trans "Used when the instance is previewed on joinbookwyrm.com. Does not support html or markdown." %}

    - {{ site_form.instance_short_description }} -
    -
    - - {{ site_form.code_of_conduct }} -
    -
    - - {{ site_form.privacy_policy }} +
    +
    + + {{ site_form.name }} +
    +
    + + {{ site_form.instance_tagline }} +
    +
    + + {{ site_form.instance_description }} +
    +
    + +

    {% trans "Used when the instance is previewed on joinbookwyrm.com. Does not support html or markdown." %}

    + {{ site_form.instance_short_description }} +
    +
    + + {{ site_form.code_of_conduct }} +
    +
    + + {{ site_form.privacy_policy }} +
    @@ -42,16 +52,16 @@

    {% trans "Images" %}

    -
    -
    +
    +
    {{ site_form.logo }}
    -
    +
    {{ site_form.logo_small }}
    -
    +
    {{ site_form.favicon }}
    @@ -62,21 +72,23 @@ @@ -84,35 +96,37 @@

    {% trans "Registration" %}

    -
    - -
    -
    - -
    -
    - -

    {% trans "(Recommended if registration is open)" %}

    -
    -
    - - {{ site_form.registration_closed_text }} -
    -
    - - {{ site_form.invite_request_text }} - {% for error in site_form.invite_request_text.errors %} -

    {{ error|escape }}

    - {% endfor %} +
    +
    + +
    +
    + +
    +
    + +

    {% trans "(Recommended if registration is open)" %}

    +
    +
    + + {{ site_form.registration_closed_text }} +
    +
    + + {{ site_form.invite_request_text }} + {% for error in site_form.invite_request_text.errors %} +

    {{ error|escape }}

    + {% endfor %} +
    diff --git a/bookwyrm/templates/user_admin/delete_user_form.html b/bookwyrm/templates/settings/users/delete_user_form.html similarity index 100% rename from bookwyrm/templates/user_admin/delete_user_form.html rename to bookwyrm/templates/settings/users/delete_user_form.html diff --git a/bookwyrm/templates/user_admin/server_filter.html b/bookwyrm/templates/settings/users/server_filter.html similarity index 100% rename from bookwyrm/templates/user_admin/server_filter.html rename to bookwyrm/templates/settings/users/server_filter.html diff --git a/bookwyrm/templates/settings/users/user.html b/bookwyrm/templates/settings/users/user.html new file mode 100644 index 00000000..676502e6 --- /dev/null +++ b/bookwyrm/templates/settings/users/user.html @@ -0,0 +1,16 @@ +{% extends 'settings/layout.html' %} +{% load i18n %} + +{% block title %}{{ user.username }}{% endblock %} +{% block header %} +{{ user.username }} +{% trans "Back to users" %} +{% endblock %} + +{% block panel %} +{% include 'settings/users/user_info.html' with user=user %} + +{% include 'settings/users/user_moderation_actions.html' with user=user %} + +{% endblock %} + diff --git a/bookwyrm/templates/user_admin/user_admin.html b/bookwyrm/templates/settings/users/user_admin.html similarity index 97% rename from bookwyrm/templates/user_admin/user_admin.html rename to bookwyrm/templates/settings/users/user_admin.html index 024ebfec..874ce818 100644 --- a/bookwyrm/templates/user_admin/user_admin.html +++ b/bookwyrm/templates/settings/users/user_admin.html @@ -13,7 +13,7 @@ {% block panel %} -{% include 'user_admin/user_admin_filters.html' %} +{% include 'settings/users/user_admin_filters.html' %} diff --git a/bookwyrm/templates/user_admin/user_admin_filters.html b/bookwyrm/templates/settings/users/user_admin_filters.html similarity index 59% rename from bookwyrm/templates/user_admin/user_admin_filters.html rename to bookwyrm/templates/settings/users/user_admin_filters.html index c9c7a93f..48a3b7c8 100644 --- a/bookwyrm/templates/user_admin/user_admin_filters.html +++ b/bookwyrm/templates/settings/users/user_admin_filters.html @@ -1,7 +1,7 @@ {% extends 'snippets/filters_panel/filters_panel.html' %} {% block filter_fields %} -{% include 'user_admin/username_filter.html' %} +{% include 'settings/users/username_filter.html' %} {% include 'directory/community_filter.html' %} -{% include 'user_admin/server_filter.html' %} +{% include 'settings/users/server_filter.html' %} {% endblock %} diff --git a/bookwyrm/templates/user_admin/user_info.html b/bookwyrm/templates/settings/users/user_info.html similarity index 57% rename from bookwyrm/templates/user_admin/user_info.html rename to bookwyrm/templates/settings/users/user_info.html index 7ad57e0e..8d332b1a 100644 --- a/bookwyrm/templates/user_admin/user_info.html +++ b/bookwyrm/templates/settings/users/user_info.html @@ -48,58 +48,42 @@
    {% if user.local %} -
    -
    {% trans "Email:" %}
    -
    {{ user.email }}
    -
    +
    {% trans "Email:" %}
    +
    {{ user.email }}
    {% endif %} {% with report_count=user.report_set.count %} -
    -
    {% trans "Reports:" %}
    -
    - {{ report_count|intcomma }} - {% if report_count > 0 %} - - {% trans "(View reports)" %} - - {% endif %} -
    -
    +
    {% trans "Reports:" %}
    +
    + {{ report_count|intcomma }} + {% if report_count > 0 %} + + {% trans "(View reports)" %} + + {% endif %} +
    {% endwith %} -
    -
    {% trans "Blocked by count:" %}
    -
    {{ user.blocked_by.count }}
    -
    +
    {% trans "Blocked by count:" %}
    +
    {{ user.blocked_by.count }}
    -
    -
    {% trans "Last active date:" %}
    -
    {{ user.last_active_date }}
    -
    +
    {% trans "Last active date:" %}
    +
    {{ user.last_active_date }}
    -
    -
    {% trans "Manually approved followers:" %}
    -
    {{ user.manually_approves_followers }}
    -
    +
    {% trans "Manually approved followers:" %}
    +
    {{ user.manually_approves_followers }}
    -
    -
    {% trans "Discoverable:" %}
    -
    {{ user.discoverable }}
    -
    +
    {% trans "Discoverable:" %}
    +
    {{ user.discoverable }}
    {% if not user.is_active %} -
    -
    {% trans "Deactivation reason:" %}
    -
    {{ user.deactivation_reason }}
    -
    +
    {% trans "Deactivation reason:" %}
    +
    {{ user.deactivation_reason }}
    {% endif %} {% if not user.is_active and user.deactivation_reason == "pending" %} -
    -
    {% trans "Confirmation code:" %}
    -
    {{ user.confirmation_code }}
    -
    +
    {% trans "Confirmation code:" %}
    +
    {{ user.confirmation_code }}
    {% endif %}
    @@ -113,18 +97,14 @@ {% if server %}
    {{ server.server_name }}
    -
    -
    {% trans "Software:" %}
    -
    {{ server.application_type }}
    -
    -
    -
    {% trans "Version:" %}
    -
    {{ server.application_version }}
    -
    -
    -
    {% trans "Status:" %}
    -
    {{ server.status }}
    -
    +
    {% trans "Software:" %}
    +
    {{ server.application_type }}
    + +
    {% trans "Version:" %}
    +
    {{ server.application_version }}
    + +
    {% trans "Status:" %}
    +
    {{ server.status }}
    {% if server.notes %}
    {% trans "Notes" %}
    diff --git a/bookwyrm/templates/user_admin/user_moderation_actions.html b/bookwyrm/templates/settings/users/user_moderation_actions.html similarity index 95% rename from bookwyrm/templates/user_admin/user_moderation_actions.html rename to bookwyrm/templates/settings/users/user_moderation_actions.html index 12b70d3c..a976359f 100644 --- a/bookwyrm/templates/user_admin/user_moderation_actions.html +++ b/bookwyrm/templates/settings/users/user_moderation_actions.html @@ -36,7 +36,7 @@ {% if user.local %}
    - {% include "user_admin/delete_user_form.html" with controls_text="delete_user" class="mt-2 mb-2" %} + {% include "settings/users/delete_user_form.html" with controls_text="delete_user" class="mt-2 mb-2" %}
    {% endif %} diff --git a/bookwyrm/templates/user_admin/username_filter.html b/bookwyrm/templates/settings/users/username_filter.html similarity index 100% rename from bookwyrm/templates/user_admin/username_filter.html rename to bookwyrm/templates/settings/users/username_filter.html diff --git a/bookwyrm/templates/snippets/report_button.html b/bookwyrm/templates/snippets/report_button.html index 55001aca..2638a9ff 100644 --- a/bookwyrm/templates/snippets/report_button.html +++ b/bookwyrm/templates/snippets/report_button.html @@ -6,6 +6,6 @@ {% trans "Report" as button_text %} {% include 'snippets/toggle/toggle_button.html' with class="is-danger is-light is-small is-fullwidth" text=button_text controls_text="report" controls_uid=report_uuid focus="modal_title_report" disabled=is_current %} -{% include 'moderation/report_modal.html' with user=user reporter=request.user controls_text="report" controls_uid=report_uuid %} +{% include 'snippets/report_modal.html' with user=user reporter=request.user controls_text="report" controls_uid=report_uuid %} {% endwith %} diff --git a/bookwyrm/templates/moderation/report_modal.html b/bookwyrm/templates/snippets/report_modal.html similarity index 100% rename from bookwyrm/templates/moderation/report_modal.html rename to bookwyrm/templates/snippets/report_modal.html diff --git a/bookwyrm/templates/user_admin/user.html b/bookwyrm/templates/user_admin/user.html deleted file mode 100644 index e3a2413a..00000000 --- a/bookwyrm/templates/user_admin/user.html +++ /dev/null @@ -1,19 +0,0 @@ -{% extends 'settings/layout.html' %} -{% load i18n %} - -{% block title %}{{ user.username }}{% endblock %} -{% block header %} -{{ user.username }} -

    - {% trans "Back to users" %} -

    - -{% endblock %} - -{% block panel %} -{% include 'user_admin/user_info.html' with user=user %} - -{% include 'user_admin/user_moderation_actions.html' with user=user %} - -{% endblock %} - diff --git a/bookwyrm/tests/views/admin/__init__.py b/bookwyrm/tests/views/admin/__init__.py new file mode 100644 index 00000000..b6e690fd --- /dev/null +++ b/bookwyrm/tests/views/admin/__init__.py @@ -0,0 +1 @@ +from . import * diff --git a/bookwyrm/tests/views/test_announcements.py b/bookwyrm/tests/views/admin/test_announcements.py similarity index 100% rename from bookwyrm/tests/views/test_announcements.py rename to bookwyrm/tests/views/admin/test_announcements.py diff --git a/bookwyrm/tests/views/test_dashboard.py b/bookwyrm/tests/views/admin/test_dashboard.py similarity index 88% rename from bookwyrm/tests/views/test_dashboard.py rename to bookwyrm/tests/views/admin/test_dashboard.py index 6ce30c18..70cc40fe 100644 --- a/bookwyrm/tests/views/test_dashboard.py +++ b/bookwyrm/tests/views/admin/test_dashboard.py @@ -1,5 +1,6 @@ """ test for app action functionality """ from unittest.mock import patch +from tidylib import tidy_document from django.template.response import TemplateResponse from django.test import TestCase from django.test.client import RequestFactory @@ -34,5 +35,8 @@ class DashboardViews(TestCase): request.user.is_superuser = True result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + html = result.render() + _, errors = tidy_document(html.content) + if errors: + raise Exception(errors) self.assertEqual(result.status_code, 200) diff --git a/bookwyrm/tests/views/test_email_blocks.py b/bookwyrm/tests/views/admin/test_email_blocks.py similarity index 100% rename from bookwyrm/tests/views/test_email_blocks.py rename to bookwyrm/tests/views/admin/test_email_blocks.py diff --git a/bookwyrm/tests/views/test_federation.py b/bookwyrm/tests/views/admin/test_federation.py similarity index 90% rename from bookwyrm/tests/views/test_federation.py rename to bookwyrm/tests/views/admin/test_federation.py index ebd311d3..2501a81a 100644 --- a/bookwyrm/tests/views/test_federation.py +++ b/bookwyrm/tests/views/admin/test_federation.py @@ -1,6 +1,8 @@ """ test for app action functionality """ import json from unittest.mock import patch +from tidylib import tidy_document + from django.core.files.uploadedfile import SimpleUploadedFile from django.template.response import TemplateResponse from django.test import TestCase @@ -46,10 +48,19 @@ class FederationViews(TestCase): request.user.is_superuser = True result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + html = result.render() + _, errors = tidy_document( + html.content, + options={ + "drop-empty-elements": False, + "warn-proprietary-attributes": False, + }, + ) + if errors: + raise Exception(errors) self.assertEqual(result.status_code, 200) - def test_server_page(self): + def test_instance_page(self): """there are so many views, this just makes sure it LOADS""" server = models.FederatedServer.objects.create(server_name="hi.there.com") view = views.FederatedServer.as_view() @@ -59,7 +70,10 @@ class FederationViews(TestCase): result = view(request, server.id) self.assertIsInstance(result, TemplateResponse) - result.render() + html = result.render() + _, errors = tidy_document(html.content, options={"drop-empty-elements": False}) + if errors: + raise Exception(errors) self.assertEqual(result.status_code, 200) def test_server_page_block(self): @@ -148,7 +162,10 @@ class FederationViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + html = result.render() + _, errors = tidy_document(html.content) + if errors: + raise Exception(errors) self.assertEqual(result.status_code, 200) def test_add_view_post_create(self): @@ -169,6 +186,7 @@ class FederationViews(TestCase): self.assertEqual(server.application_type, "coolsoft") self.assertEqual(server.status, "blocked") + # pylint: disable=consider-using-with def test_import_blocklist(self): """load a json file with a list of servers to block""" server = models.FederatedServer.objects.create(server_name="hi.there.com") @@ -180,7 +198,7 @@ class FederationViews(TestCase): {"instance": "hi.there.com", "url": "https://explanation.url"}, # existing {"a": "b"}, # invalid ] - json.dump(data, open("file.json", "w")) + json.dump(data, open("file.json", "w")) # pylint: disable=unspecified-encoding view = views.ImportServerBlocklist.as_view() request = self.factory.post( diff --git a/bookwyrm/tests/views/admin/test_ip_blocklist.py b/bookwyrm/tests/views/admin/test_ip_blocklist.py new file mode 100644 index 00000000..fb249b76 --- /dev/null +++ b/bookwyrm/tests/views/admin/test_ip_blocklist.py @@ -0,0 +1,44 @@ +""" test for app action functionality """ +from unittest.mock import patch +from tidylib import tidy_document +from django.template.response import TemplateResponse +from django.test import TestCase +from django.test.client import RequestFactory + +from bookwyrm import models, views + + +class IPBlocklistViews(TestCase): + """every response to a get request, html or json""" + + def setUp(self): + """we need basic test data and mocks""" + self.factory = RequestFactory() + with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( + "bookwyrm.activitystreams.populate_stream_task.delay" + ): + self.local_user = models.User.objects.create_user( + "mouse@local.com", + "mouse@mouse.mouse", + "password", + local=True, + localname="mouse", + ) + + models.SiteSettings.objects.create() + + def test_blocklist_page_get(self): + """there are so many views, this just makes sure it LOADS""" + view = views.IPBlocklist.as_view() + request = self.factory.get("") + request.user = self.local_user + request.user.is_superuser = True + + result = view(request) + + self.assertIsInstance(result, TemplateResponse) + html = result.render() + _, errors = tidy_document(html.content, options={"drop-empty-elements": False}) + if errors: + raise Exception(errors) + self.assertEqual(result.status_code, 200) diff --git a/bookwyrm/tests/views/test_reports.py b/bookwyrm/tests/views/admin/test_reports.py similarity index 87% rename from bookwyrm/tests/views/test_reports.py rename to bookwyrm/tests/views/admin/test_reports.py index 9fbeae04..456dff55 100644 --- a/bookwyrm/tests/views/test_reports.py +++ b/bookwyrm/tests/views/admin/test_reports.py @@ -1,6 +1,8 @@ """ test for app action functionality """ import json from unittest.mock import patch +from tidylib import tidy_document + from django.template.response import TemplateResponse from django.test import TestCase from django.test.client import RequestFactory @@ -42,7 +44,16 @@ class ReportViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + html = result.render() + _, errors = tidy_document( + html.content, + options={ + "drop-empty-elements": False, + "warn-proprietary-attributes": False, + }, + ) + if errors: + raise Exception(errors) self.assertEqual(result.status_code, 200) def test_reports_page_with_data(self): @@ -55,7 +66,16 @@ class ReportViews(TestCase): result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + html = result.render() + _, errors = tidy_document( + html.content, + options={ + "drop-empty-elements": False, + "warn-proprietary-attributes": False, + }, + ) + if errors: + raise Exception(errors) self.assertEqual(result.status_code, 200) def test_report_page(self): @@ -69,7 +89,10 @@ class ReportViews(TestCase): result = view(request, report.id) self.assertIsInstance(result, TemplateResponse) - result.render() + html = result.render() + _, errors = tidy_document(html.content, options={"drop-empty-elements": False}) + if errors: + raise Exception(errors) self.assertEqual(result.status_code, 200) def test_report_comment(self): diff --git a/bookwyrm/tests/views/test_user_admin.py b/bookwyrm/tests/views/admin/test_user_admin.py similarity index 82% rename from bookwyrm/tests/views/test_user_admin.py rename to bookwyrm/tests/views/admin/test_user_admin.py index 3917a6fd..3336cf24 100644 --- a/bookwyrm/tests/views/test_user_admin.py +++ b/bookwyrm/tests/views/admin/test_user_admin.py @@ -1,5 +1,7 @@ """ test for app action functionality """ from unittest.mock import patch +from tidylib import tidy_document + from django.contrib.auth.models import Group from django.template.response import TemplateResponse from django.test import TestCase @@ -34,7 +36,10 @@ class UserAdminViews(TestCase): request.user.is_superuser = True result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + html = result.render() + _, errors = tidy_document(html.content, options={"drop-empty-elements": False}) + if errors: + raise Exception(errors) self.assertEqual(result.status_code, 200) def test_user_admin_page(self): @@ -47,7 +52,10 @@ class UserAdminViews(TestCase): result = view(request, self.local_user.id) self.assertIsInstance(result, TemplateResponse) - result.render() + html = result.render() + _, errors = tidy_document(html.content, options={"drop-empty-elements": False}) + if errors: + raise Exception(errors) self.assertEqual(result.status_code, 200) @patch("bookwyrm.suggested_users.rerank_suggestions_task.delay") @@ -69,7 +77,10 @@ class UserAdminViews(TestCase): result = view(request, self.local_user.id) self.assertIsInstance(result, TemplateResponse) - result.render() + html = result.render() + _, errors = tidy_document(html.content, options={"drop-empty-elements": False}) + if errors: + raise Exception(errors) self.assertEqual( list(self.local_user.groups.values_list("name", flat=True)), ["editor"] diff --git a/bookwyrm/tests/views/preferences/test_block.py b/bookwyrm/tests/views/preferences/test_block.py index 1954d889..6663aa63 100644 --- a/bookwyrm/tests/views/preferences/test_block.py +++ b/bookwyrm/tests/views/preferences/test_block.py @@ -1,5 +1,7 @@ """ test for app action functionality """ from unittest.mock import patch +from tidylib import tidy_document + from django.template.response import TemplateResponse from django.test import TestCase from django.test.client import RequestFactory @@ -44,7 +46,10 @@ class BlockViews(TestCase): request.user = self.local_user result = view(request) self.assertIsInstance(result, TemplateResponse) - result.render() + html = result.render() + _, errors = tidy_document(html.content) + if errors: + raise Exception(errors) self.assertEqual(result.status_code, 200) def test_block_post(self, _): diff --git a/bookwyrm/views/admin/announcements.py b/bookwyrm/views/admin/announcements.py index e778b709..92ec1766 100644 --- a/bookwyrm/views/admin/announcements.py +++ b/bookwyrm/views/admin/announcements.py @@ -41,7 +41,9 @@ class Announcements(View): "form": forms.AnnouncementForm(), "sort": sort, } - return TemplateResponse(request, "settings/announcements.html", data) + return TemplateResponse( + request, "settings/announcements/announcements.html", data + ) def post(self, request): """edit the site settings""" @@ -56,7 +58,9 @@ class Announcements(View): ).get_page(request.GET.get("page")), "form": form, } - return TemplateResponse(request, "settings/announcements.html", data) + return TemplateResponse( + request, "settings/announcements/announcements.html", data + ) @method_decorator(login_required, name="dispatch") @@ -74,7 +78,9 @@ class Announcement(View): "announcement": announcement, "form": forms.AnnouncementForm(instance=announcement), } - return TemplateResponse(request, "settings/announcement.html", data) + return TemplateResponse( + request, "settings/announcements/announcement.html", data + ) def post(self, request, announcement_id): """edit announcement""" @@ -87,7 +93,9 @@ class Announcement(View): "announcement": announcement, "form": form, } - return TemplateResponse(request, "settings/announcement.html", data) + return TemplateResponse( + request, "settings/announcements/announcement.html", data + ) @login_required diff --git a/bookwyrm/views/admin/dashboard.py b/bookwyrm/views/admin/dashboard.py index 161dc6da..e02b9143 100644 --- a/bookwyrm/views/admin/dashboard.py +++ b/bookwyrm/views/admin/dashboard.py @@ -85,4 +85,4 @@ class Dashboard(View): "user_stats": user_stats, "status_stats": status_stats, } - return TemplateResponse(request, "settings/dashboard.html", data) + return TemplateResponse(request, "settings/dashboard/dashboard.html", data) diff --git a/bookwyrm/views/admin/email_blocklist.py b/bookwyrm/views/admin/email_blocklist.py index cd3d83fd..eecad4ff 100644 --- a/bookwyrm/views/admin/email_blocklist.py +++ b/bookwyrm/views/admin/email_blocklist.py @@ -22,7 +22,9 @@ class EmailBlocklist(View): "domains": models.EmailBlocklist.objects.order_by("-created_date").all(), "form": forms.EmailBlocklistForm(), } - return TemplateResponse(request, "settings/email_blocklist.html", data) + return TemplateResponse( + request, "settings/email_blocklist/email_blocklist.html", data + ) def post(self, request, domain_id=None): """create a new domain block""" @@ -35,11 +37,15 @@ class EmailBlocklist(View): "form": form, } if not form.is_valid(): - return TemplateResponse(request, "settings/email_blocklist.html", data) + return TemplateResponse( + request, "settings/email_blocklist/email_blocklist.html", data + ) form.save() data["form"] = forms.EmailBlocklistForm() - return TemplateResponse(request, "settings/email_blocklist.html", data) + return TemplateResponse( + request, "settings/email_blocklist/email_blocklist.html", data + ) # pylint: disable=unused-argument def delete(self, request, domain_id): diff --git a/bookwyrm/views/admin/federation.py b/bookwyrm/views/admin/federation.py index 97dfd6ff..19bba30d 100644 --- a/bookwyrm/views/admin/federation.py +++ b/bookwyrm/views/admin/federation.py @@ -44,7 +44,7 @@ class Federation(View): "sort": sort, "form": forms.ServerForm(), } - return TemplateResponse(request, "settings/federation.html", data) + return TemplateResponse(request, "settings/federation/instance_list.html", data) class AddFederatedServer(View): @@ -53,14 +53,16 @@ class AddFederatedServer(View): def get(self, request): """add server form""" data = {"form": forms.ServerForm()} - return TemplateResponse(request, "settings/edit_server.html", data) + return TemplateResponse(request, "settings/federation/edit_instance.html", data) def post(self, request): """add a server from the admin panel""" form = forms.ServerForm(request.POST) if not form.is_valid(): data = {"form": form} - return TemplateResponse(request, "settings/edit_server.html", data) + return TemplateResponse( + request, "settings/federation/edit_instance.html", data + ) server = form.save() return redirect("settings-federated-server", server.id) @@ -75,7 +77,7 @@ class ImportServerBlocklist(View): def get(self, request): """add server form""" - return TemplateResponse(request, "settings/server_blocklist.html") + return TemplateResponse(request, "settings/federation/instance_blocklist.html") def post(self, request): """add a server from the admin panel""" @@ -98,7 +100,9 @@ class ImportServerBlocklist(View): server.block() success_count += 1 data = {"failed": failed, "succeeded": success_count} - return TemplateResponse(request, "settings/server_blocklist.html", data) + return TemplateResponse( + request, "settings/federation/instance_blocklist.html", data + ) @method_decorator(login_required, name="dispatch") @@ -123,7 +127,7 @@ class FederatedServer(View): user_subject__in=users.all() ), } - return TemplateResponse(request, "settings/federated_server.html", data) + return TemplateResponse(request, "settings/federation/instance.html", data) def post(self, request, server): # pylint: disable=unused-argument """update note""" diff --git a/bookwyrm/views/admin/invite.py b/bookwyrm/views/admin/invite.py index f4c82e48..8a3db61a 100644 --- a/bookwyrm/views/admin/invite.py +++ b/bookwyrm/views/admin/invite.py @@ -45,7 +45,7 @@ class ManageInvites(View): ), "form": forms.CreateInviteForm(), } - return TemplateResponse(request, "settings/manage_invites.html", data) + return TemplateResponse(request, "settings/invites/manage_invites.html", data) def post(self, request): """creates an invite database entry""" @@ -64,7 +64,7 @@ class ManageInvites(View): PAGE_LENGTH, ) data = {"invites": paginated.page(1), "form": form} - return TemplateResponse(request, "settings/manage_invites.html", data) + return TemplateResponse(request, "settings/invites/manage_invites.html", data) class Invite(View): @@ -135,7 +135,9 @@ class ManageInviteRequests(View): ), "sort": sort, } - return TemplateResponse(request, "settings/manage_invite_requests.html", data) + return TemplateResponse( + request, "settings/invites/manage_invite_requests.html", data + ) def post(self, request): """send out an invite""" diff --git a/bookwyrm/views/admin/ip_blocklist.py b/bookwyrm/views/admin/ip_blocklist.py index 643dae22..d57a2422 100644 --- a/bookwyrm/views/admin/ip_blocklist.py +++ b/bookwyrm/views/admin/ip_blocklist.py @@ -22,7 +22,9 @@ class IPBlocklist(View): "addresses": models.IPBlocklist.objects.all(), "form": forms.IPBlocklistForm(), } - return TemplateResponse(request, "settings/ip_blocklist.html", data) + return TemplateResponse( + request, "settings/ip_blocklist/ip_blocklist.html", data + ) def post(self, request, block_id=None): """create a new ip address block""" @@ -35,11 +37,15 @@ class IPBlocklist(View): "form": form, } if not form.is_valid(): - return TemplateResponse(request, "settings/ip_blocklist.html", data) + return TemplateResponse( + request, "settings/ip_blocklist/ip_blocklist.html", data + ) form.save() data["form"] = forms.IPBlocklistForm() - return TemplateResponse(request, "settings/ip_blocklist.html", data) + return TemplateResponse( + request, "settings/ip_blocklist/ip_blocklist.html", data + ) # pylint: disable=unused-argument def delete(self, request, domain_id): diff --git a/bookwyrm/views/admin/reports.py b/bookwyrm/views/admin/reports.py index 23bb6fa3..f72d7970 100644 --- a/bookwyrm/views/admin/reports.py +++ b/bookwyrm/views/admin/reports.py @@ -40,7 +40,7 @@ class Reports(View): "server": server, "reports": models.Report.objects.filter(**filters), } - return TemplateResponse(request, "moderation/reports.html", data) + return TemplateResponse(request, "settings/reports/reports.html", data) @method_decorator(login_required, name="dispatch") @@ -60,7 +60,7 @@ class Report(View): data = { "report": get_object_or_404(models.Report, id=report_id), } - return TemplateResponse(request, "moderation/report.html", data) + return TemplateResponse(request, "settings/reports/report.html", data) def post(self, request, report_id): """comment on a report""" diff --git a/bookwyrm/views/admin/user_admin.py b/bookwyrm/views/admin/user_admin.py index b29214e7..aa847959 100644 --- a/bookwyrm/views/admin/user_admin.py +++ b/bookwyrm/views/admin/user_admin.py @@ -57,7 +57,7 @@ class UserAdminList(View): "sort": sort, "server": server, } - return TemplateResponse(request, "user_admin/user_admin.html", data) + return TemplateResponse(request, "settings/users/user_admin.html", data) @method_decorator(login_required, name="dispatch") @@ -72,7 +72,7 @@ class UserAdmin(View): """user view""" user = get_object_or_404(models.User, id=user) data = {"user": user, "group_form": forms.UserGroupForm()} - return TemplateResponse(request, "user_admin/user.html", data) + return TemplateResponse(request, "settings/users/user.html", data) def post(self, request, user): """update user group""" @@ -81,4 +81,4 @@ class UserAdmin(View): if form.is_valid(): form.save() data = {"user": user, "group_form": form} - return TemplateResponse(request, "user_admin/user.html", data) + return TemplateResponse(request, "settings/users/user.html", data)