diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index d330211c1..4e92b32ed 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -3,7 +3,6 @@ import datetime from collections import defaultdict from django import forms -from django.core.exceptions import ValidationError from django.forms import ModelForm, PasswordInput, widgets from django.forms.widgets import Textarea from django.utils import timezone @@ -130,8 +129,9 @@ class EditUserForm(CustomForm): "name", "email", "summary", - "manually_approves_followers", "show_goal", + "manually_approves_followers", + "discoverable", ] help_texts = {f: None for f in fields} diff --git a/bookwyrm/templates/directory.html b/bookwyrm/templates/directory.html new file mode 100644 index 000000000..9323752fa --- /dev/null +++ b/bookwyrm/templates/directory.html @@ -0,0 +1,67 @@ +{% extends 'layout.html' %} +{% load i18n %} +{% load bookwyrm_tags %} +{% load humanize %} + +{% block title %}{% trans "Directory" %}{% endblock %} + +{% block content %} +
+

+ {% trans "Directory" %} +

+
+
+ {% for user in users %} +
+
+
+
+ + {% include 'snippets/avatar.html' with user=user large=True %} + +
+ + {{ user.display_name }} + @{{ user|username }} + + {% include 'snippets/follow_button.html' with user=user %} +
+
+ + {% if user.summary %} +
+ {{ user.summary | to_markdown | safe | truncatechars_html:40 }} +
+ {% endif %} +
+ +
+
+ {% endfor %} +
+ +
+ {% include 'snippets/pagination.html' with page=users path="/directory" %} +
+ +{% endblock %} diff --git a/bookwyrm/templates/edit_author.html b/bookwyrm/templates/edit_author.html index 0316a66fe..542b57f95 100644 --- a/bookwyrm/templates/edit_author.html +++ b/bookwyrm/templates/edit_author.html @@ -2,11 +2,11 @@ {% load i18n %} {% load humanize %} -{% block title %}{% trans "Edit Author" %}: {{ author.name }}{% endblock %} +{% block title %}{% trans "Edit Author:" %} {{ author.name }}{% endblock %} {% block content %}
-

+

Edit "{{ author.name }}"

diff --git a/bookwyrm/templates/preferences/edit_user.html b/bookwyrm/templates/preferences/edit_user.html index ca0f81c28..327d745b0 100644 --- a/bookwyrm/templates/preferences/edit_user.html +++ b/bookwyrm/templates/preferences/edit_user.html @@ -53,6 +53,14 @@ {{ form.manually_approves_followers }}
+
+ + {% url 'directory' as path %} +

{% blocktrans %}Your account will show up in the directory, and may be recommended to other BookWyrm users.{% endblocktrans %}

+
{% endblock %} diff --git a/bookwyrm/templates/snippets/avatar.html b/bookwyrm/templates/snippets/avatar.html index 6d27cd856..d53acf2b5 100644 --- a/bookwyrm/templates/snippets/avatar.html +++ b/bookwyrm/templates/snippets/avatar.html @@ -1,3 +1,3 @@ {% load bookwyrm_tags %} -{{ user.alt_text }} +{{ user.alt_text }} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 4aced6fe6..766227999 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -96,6 +96,7 @@ urlpatterns = [ path("", views.Home.as_view(), name="landing"), re_path(r"^discover/?$", views.Discover.as_view()), re_path(r"^notifications/?$", views.Notifications.as_view()), + re_path(r"^directory/?", views.Directory.as_view(), name="directory"), # feeds re_path(r"^(?Phome|local|federated)/?$", views.Feed.as_view()), re_path( diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 3402e65f7..f1ebfc4ca 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -4,6 +4,7 @@ from .author import Author, EditAuthor from .block import Block, unblock from .books import Book, EditBook, ConfirmEditBook, Editions from .books import upload_cover, add_description, switch_edition, resolve_book +from .directory import Directory from .error import not_found_page, server_error_page from .federation import Federation from .feed import DirectMessage, Feed, Replies, Status diff --git a/bookwyrm/views/directory.py b/bookwyrm/views/directory.py new file mode 100644 index 000000000..bbfbffe85 --- /dev/null +++ b/bookwyrm/views/directory.py @@ -0,0 +1,32 @@ +""" who all's here? """ +from django.contrib.auth.decorators import login_required +from django.core.paginator import Paginator +from django.template.response import TemplateResponse +from django.views import View +from django.utils.decorators import method_decorator + +from bookwyrm import models + +# pylint: disable=no-self-use +@method_decorator(login_required, name="dispatch") +class Directory(View): + """ display of known bookwyrm users """ + + def get(self, request): + """ lets see your cute faces """ + try: + page = int(request.GET.get("page", 1)) + except ValueError: + page = 1 + + users = models.User.objects.filter( + discoverable=True, + bookwyrm_user=True, + is_active=True, + ).order_by('-last_active_date') + paginated = Paginator(users, 12) + + data = { + "users": paginated.page(page), + } + return TemplateResponse(request, "directory.html", data) diff --git a/bookwyrm/views/landing.py b/bookwyrm/views/landing.py index 86f7d3e9f..407451fb8 100644 --- a/bookwyrm/views/landing.py +++ b/bookwyrm/views/landing.py @@ -2,7 +2,7 @@ from django.template.response import TemplateResponse from django.views import View -from bookwyrm import forms, models +from bookwyrm import forms from .feed import Feed from . import helpers