From b855464396900f6110108c3665e1b7f0ec3f86e9 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 5 Jan 2022 21:42:41 -0800 Subject: [PATCH] Expands about pages --- bookwyrm/templates/about/about.html | 111 +++++++++++++++++++++++++ bookwyrm/templates/about/conduct.html | 15 ++++ bookwyrm/templates/about/layout.html | 37 +++++++++ bookwyrm/templates/about/privacy.html | 15 ++++ bookwyrm/templates/landing/about.html | 37 --------- bookwyrm/templates/landing/layout.html | 2 + bookwyrm/templates/snippets/about.html | 2 +- bookwyrm/urls.py | 4 +- bookwyrm/views/__init__.py | 2 +- bookwyrm/views/helpers.py | 2 +- bookwyrm/views/landing/landing.py | 45 ++++++++-- 11 files changed, 222 insertions(+), 50 deletions(-) create mode 100644 bookwyrm/templates/about/about.html create mode 100644 bookwyrm/templates/about/conduct.html create mode 100644 bookwyrm/templates/about/layout.html create mode 100644 bookwyrm/templates/about/privacy.html delete mode 100644 bookwyrm/templates/landing/about.html diff --git a/bookwyrm/templates/about/about.html b/bookwyrm/templates/about/about.html new file mode 100644 index 000000000..3481f7313 --- /dev/null +++ b/bookwyrm/templates/about/about.html @@ -0,0 +1,111 @@ +{% extends 'about/layout.html' %} +{% load i18n %} +{% load utilities %} + +{% block title %} +{% trans "About" %} +{% endblock %} + +{% block about_content %} +
+

+ {% blocktrans trimmed with site_name=site.name %} + {{ site_name }} is part of BookWyrm, a network of independent, self-directed communites for readers. + While you can interact seemlessly with users anywhere in the BookWyrm network, this community is unique. + {% endblocktrans %} +

+ +
+
+
+ +
+ {% blocktrans trimmed with title=top_rated|book_title site_name=site.name rating=top_rated.rating|floatformat:1 %} + {{ title }} is {{ site_name }}'s most beloved book, with a {{ rating }} rating out of 5 + {% endblocktrans %} +
+
+
+
+
+ +
+ {% blocktrans trimmed with title=wanted|book_title site_name=site.name %} + More {{ site_name }} users want to read {{ title }} + {% endblocktrans %} +
+
+
+
+
+ +
+ {% blocktrans trimmed with title=controversial|book_title site_name=site.name %} + {{ title }} has the most divisive ratings of any book on {{ site_name }} + {% endblocktrans %} +
+
+
+
+ +

+ Join/request an invite to track your reading, share your thoughts, and discover what to read next on {{ site.name }}. +

+ +
+ +
+
+

{% trans "Meet your admins" %}

+

+ these nice people run your instance, when you have a problem, talk to them. when you make a report, they are the ones that receive it +

+
+
+ {% for user in admins %} +
+
+ {% with role=user.groups.first.name %} +
+ + {% if role == "moderator" %} + {% trans "Moderator" %} + {% else %} + {% trans "Admin" %} + {% endif %} + +
+ {% endwith %} + +
+ {% include 'user/user_preview.html' with user=user %} +
+ + {% if request.user.is_authenticated and user.id != request.user.id %} + + {% endif %} +
+
+ {% endfor %} +
+
+{% endblock %} diff --git a/bookwyrm/templates/about/conduct.html b/bookwyrm/templates/about/conduct.html new file mode 100644 index 000000000..a38a01684 --- /dev/null +++ b/bookwyrm/templates/about/conduct.html @@ -0,0 +1,15 @@ +{% extends 'about/layout.html' %} +{% load i18n %} + +{% block title %}{% trans "Code of Conduct" %}{% endblock %} + + +{% block about_content %} +
+

{% trans "Code of Conduct" %}

+
+ {{ site.code_of_conduct | safe }} +
+
+ +{% endblock %} diff --git a/bookwyrm/templates/about/layout.html b/bookwyrm/templates/about/layout.html new file mode 100644 index 000000000..82d8aaaee --- /dev/null +++ b/bookwyrm/templates/about/layout.html @@ -0,0 +1,37 @@ +{% extends 'landing/layout.html' %} +{% load i18n %} + +{% block about_panel %} +{% endblock %} + +{% block panel %} +
+ + +
+ {% block about_content %}{% endblock %} +
+
+{% endblock %} diff --git a/bookwyrm/templates/about/privacy.html b/bookwyrm/templates/about/privacy.html new file mode 100644 index 000000000..c43b9da17 --- /dev/null +++ b/bookwyrm/templates/about/privacy.html @@ -0,0 +1,15 @@ +{% extends 'about/layout.html' %} +{% load i18n %} + +{% block title %}{% trans "Privacy Policy" %}{% endblock %} + +{% block about_content %} + +
+

{% trans "Privacy Policy" %}

+
+ {{ site.privacy_policy | safe }} +
+
+ +{% endblock %} diff --git a/bookwyrm/templates/landing/about.html b/bookwyrm/templates/landing/about.html deleted file mode 100644 index c3b1e84ef..000000000 --- a/bookwyrm/templates/landing/about.html +++ /dev/null @@ -1,37 +0,0 @@ -{% extends 'landing/layout.html' %} -{% load i18n %} - -{% block panel %} -
- - -
-
-

{% trans "Code of Conduct" %}

-
- {{ site.code_of_conduct | safe }} -
-
- - - -
-

{% trans "Privacy Policy" %}

-
- {{ site.privacy_policy | safe }} -
-
-
-
- -{% endblock %} diff --git a/bookwyrm/templates/landing/layout.html b/bookwyrm/templates/landing/layout.html index 56985768f..afe8ceccf 100644 --- a/bookwyrm/templates/landing/layout.html +++ b/bookwyrm/templates/landing/layout.html @@ -31,6 +31,7 @@ +{% block about_panel %}
@@ -89,6 +90,7 @@ {% endif %}
+{% endblock %} {% block panel %}{% endblock %} diff --git a/bookwyrm/templates/snippets/about.html b/bookwyrm/templates/snippets/about.html index c9a9db80e..786c8f72d 100644 --- a/bookwyrm/templates/snippets/about.html +++ b/bookwyrm/templates/snippets/about.html @@ -2,7 +2,7 @@
-
+
BookWyrm logo
diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index bd36f3d85..331992257 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -197,7 +197,9 @@ urlpatterns = [ ), re_path(r"^report/?$", views.make_report, name="report"), # landing pages - re_path(r"^about/?$", views.About.as_view(), name="about"), + re_path(r"^about/?$", views.about, name="about"), + re_path(r"^privacy/?$", views.privacy, name="privacy"), + re_path(r"^conduct/?$", views.conduct, name="conduct"), path("", views.Home.as_view(), name="landing"), re_path(r"^discover/?$", views.Discover.as_view(), name="discover"), re_path(r"^notifications/?$", views.Notifications.as_view(), name="notifications"), diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index f77a3b502..12a86bf0d 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -34,7 +34,7 @@ from .books.edit_book import EditBook, ConfirmEditBook from .books.editions import Editions, switch_edition # landing -from .landing.landing import About, Home, Landing +from .landing.landing import Home, Landing, about, privacy, conduct from .landing.login import Login, Logout from .landing.register import Register, ConfirmEmail, ConfirmEmailCode, resend_link from .landing.password import PasswordResetRequest, PasswordReset diff --git a/bookwyrm/views/helpers.py b/bookwyrm/views/helpers.py index 93aac9c4f..33d709a61 100644 --- a/bookwyrm/views/helpers.py +++ b/bookwyrm/views/helpers.py @@ -160,7 +160,7 @@ def get_landing_books(): models.Edition.objects.filter( review__published_date__isnull=False, review__deleted=False, - review__user__local=True, + #review__user__local=True, review__privacy__in=["public", "unlisted"], ) .exclude(cover__exact="") diff --git a/bookwyrm/views/landing/landing.py b/bookwyrm/views/landing/landing.py index c8bba0664..d9955dd7a 100644 --- a/bookwyrm/views/landing/landing.py +++ b/bookwyrm/views/landing/landing.py @@ -1,21 +1,48 @@ """ non-interactive pages """ +from django.db.models import Avg, StdDev, Count, Q from django.template.response import TemplateResponse from django.views import View +from django.views.decorators.http import require_GET -from bookwyrm import forms +from bookwyrm import forms, models from bookwyrm.views import helpers from bookwyrm.views.feed import Feed +@require_GET +def about(request): + """more information about the instance""" + + books = models.Edition.objects.exclude( + cover__exact="" + ).annotate( + rating=Avg("review__rating"), + deviation=StdDev("review__rating"), + shelf_count=Count("shelves", filter=Q(shelves__identifier="to-read")), + ) + + data = { + "admins": models.User.objects.filter(groups__name__in=["admin", "moderator"]), + "top_rated": books.order_by("rating").first(), + "controversial": books.order_by("deviation").first(), + "wanted": books.order_by("shelf_count").first(), + } + return TemplateResponse(request, "about/about.html", data) + + +@require_GET +def conduct(request): + """more information about the instance""" + return TemplateResponse(request, "about/conduct.html") + + +@require_GET +def privacy(request): + """more information about the instance""" + return TemplateResponse(request, "about/privacy.html") + + # pylint: disable= no-self-use -class About(View): - """create invites""" - - def get(self, request): - """more information about the instance""" - return TemplateResponse(request, "landing/about.html") - - class Home(View): """landing page or home feed depending on auth"""