diff --git a/bookwyrm/templates/feed/feed.html b/bookwyrm/templates/feed/feed.html index 3f9d36f7..e49b4c13 100644 --- a/bookwyrm/templates/feed/feed.html +++ b/bookwyrm/templates/feed/feed.html @@ -54,27 +54,7 @@ {# suggested users on the first page, two statuses down #}

{% trans "Who to follow" %}

-
- {% for user in suggested_users %} -
-
- - {% include 'snippets/avatar.html' with user=user large=True %} - {{ user.display_name|truncatechars:10 }} - @{{ user|username|truncatechars:8 }} - - {% include 'snippets/follow_button.html' with user=user minimal=True %} - {% if user.mutuals %} -

- {% blocktrans with mutuals=user.mutuals|intcomma count counter=user.mutuals %}{{ mutuals }} follower you follow{% plural %}{{ mutuals }} followers you follow{% endblocktrans %} -

- {% elif user.shared_books %} -

{% blocktrans with shared_books=user.shared_books|intcomma count counter=user.shared_books %}{{ shared_books }} book on your shelves{% plural %}{{ shared_books }} books on your shelves{% endblocktrans %}

- {% endif %} -
-
- {% endfor %} -
+ {% include 'feed/suggested_users.html' with suggested_users=suggested_users %} View directory
{% endif %} diff --git a/bookwyrm/templates/feed/suggested_users.html b/bookwyrm/templates/feed/suggested_users.html new file mode 100644 index 00000000..f66662e8 --- /dev/null +++ b/bookwyrm/templates/feed/suggested_users.html @@ -0,0 +1,25 @@ +{% load i18n %} +{% load bookwyrm_tags %} +{% load humanize %} +
+ {% for user in suggested_users %} +
+
+ + {% include 'snippets/avatar.html' with user=user large=True %} + {{ user.display_name|truncatechars:10 }} + @{{ user|username|truncatechars:8 }} + + {% include 'snippets/follow_button.html' with user=user minimal=True %} + {% if user.mutuals %} +

+ {% blocktrans with mutuals=user.mutuals|intcomma count counter=user.mutuals %}{{ mutuals }} follower you follow{% plural %}{{ mutuals }} followers you follow{% endblocktrans %} +

+ {% elif user.shared_books %} +

{% blocktrans with shared_books=user.shared_books|intcomma count counter=user.shared_books %}{{ shared_books }} book on your shelves{% plural %}{{ shared_books }} books on your shelves{% endblocktrans %}

+ {% endif %} +
+
+ {% endfor %} +
+ diff --git a/bookwyrm/templates/get_started/books.html b/bookwyrm/templates/get_started/books.html index cbb208f8..eb10f4ed 100644 --- a/bookwyrm/templates/get_started/books.html +++ b/bookwyrm/templates/get_started/books.html @@ -4,7 +4,7 @@ {% block panel %}

{% trans "What are you reading?" %}

-
+
{% if request.GET.query and not book_results %} diff --git a/bookwyrm/templates/get_started/layout.html b/bookwyrm/templates/get_started/layout.html index eeb01bbe..b6d373fd 100644 --- a/bookwyrm/templates/get_started/layout.html +++ b/bookwyrm/templates/get_started/layout.html @@ -19,10 +19,12 @@
diff --git a/bookwyrm/templates/get_started/profile.html b/bookwyrm/templates/get_started/profile.html new file mode 100644 index 00000000..7ee43c08 --- /dev/null +++ b/bookwyrm/templates/get_started/profile.html @@ -0,0 +1,58 @@ +{% extends 'get_started/layout.html' %} +{% load i18n %} + +{% block panel %} +
+

{% trans "A little bit about you" %}

+ {% if form.non_field_errors %} +

{{ form.non_field_errors }}

+ {% endif %} + + {% csrf_token %} +
+
+
+ + + {% for error in form.name.errors %} +

{{ error | escape }}

+ {% endfor %} +
+
+ + + {% for error in form.summary.errors %} +

{{ error | escape }}

+ {% endfor %} +
+
+ +
+
+ + {{ form.avatar }} + {% for error in form.avatar.errors %} +

{{ error | escape }}

+ {% endfor %} +
+
+
+
+ +
+
+ + {% url 'directory' as path %} +

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

+
+
+ +
+{% endblock %} + diff --git a/bookwyrm/templates/get_started/users.html b/bookwyrm/templates/get_started/users.html new file mode 100644 index 00000000..14c04e63 --- /dev/null +++ b/bookwyrm/templates/get_started/users.html @@ -0,0 +1,11 @@ +{% extends 'get_started/layout.html' %} +{% load i18n %} + +{% block panel %} +
+

{% trans "Who to follow" %}

+ + {% include 'feed/suggested_users.html' with suggested_users=suggested_users %} +
+{% endblock %} + diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 6d14beeb..ef8b3212 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -110,7 +110,21 @@ urlpatterns = [ re_path(r"^notifications/?$", views.Notifications.as_view()), re_path(r"^directory/?", views.Directory.as_view(), name="directory"), # Get started - re_path(r"^get-started/?$", views.GetStarted.as_view(), name="get-started"), + re_path( + r"^get-started/?$", + views.GetStartedProfile.as_view(), + name="get-started-profile", + ), + re_path( + r"^get-started/books/?$", + views.GetStartedBooks.as_view(), + name="get-started-books", + ), + re_path( + r"^get-started/users/?$", + views.GetStartedUsers.as_view(), + name="get-started-users", + ), # 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 9ea5ebeb..22e6071c 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -9,7 +9,7 @@ from .federation import Federation, FederatedServer from .feed import DirectMessage, Feed, Replies, Status from .follow import follow, unfollow from .follow import accept_follow_request, delete_follow_request -from .get_started import GetStarted +from .get_started import GetStartedBooks, GetStartedProfile, GetStartedUsers from .goal import Goal, hide_goal from .import_data import Import, ImportStatus from .inbox import Inbox diff --git a/bookwyrm/views/get_started.py b/bookwyrm/views/get_started.py index 7db45806..f133e335 100644 --- a/bookwyrm/views/get_started.py +++ b/bookwyrm/views/get_started.py @@ -1,35 +1,74 @@ """ Helping new users figure out the lay of the land """ from django.contrib.auth.decorators import login_required -from django.db.models import Count +from django.db.models import Count, Q from django.template.response import TemplateResponse from django.utils.decorators import method_decorator from django.views import View -from bookwyrm import models +from bookwyrm import forms, models from bookwyrm.connectors import connector_manager +from .helpers import get_suggested_users # pylint: disable= no-self-use @method_decorator(login_required, name="dispatch") -class GetStarted(View): - """ a book! this is the stuff """ +class GetStartedProfile(View): + """ tell us about yourself """ + + def get(self, request): + """ basic profile info """ + data = { + "form": forms.EditUserForm(instance=request.user), + "next": "get-started-books", + } + return TemplateResponse(request, "get_started/profile.html", data) + + +@method_decorator(login_required, name="dispatch") +class GetStartedBooks(View): + """ name a book, any book, we gotta start somewhere """ def get(self, request): """ info about a book """ - query = request.GET.get('query') + query = request.GET.get("query") book_results = [] if query: book_results = connector_manager.local_search(query, raw=True)[:5] if len(book_results) < 5: - popular_books = models.Edition.objects.exclude( - parent_work__in=[b.parent_work for b in book_results], - ).annotate( - Count("shelfbook") - ).order_by("-shelfbook__count")[: 5 - len(book_results)] - + popular_books = ( + models.Edition.objects.exclude( + parent_work__in=[b.parent_work for b in book_results], + ) + .annotate(Count("shelfbook")) + .order_by("-shelfbook__count")[: 5 - len(book_results)] + ) data = { "book_results": book_results, "popular_books": popular_books, + "next": "get-started-users", } return TemplateResponse(request, "get_started/books.html", data) + + +@method_decorator(login_required, name="dispatch") +class GetStartedUsers(View): + """ find friends """ + + def get(self, request): + """ basic profile info """ + suggested_users = ( + get_suggested_users( + request.user, + ~Q(id=request.user.id), + ~Q(followers=request.user), + bookwyrm_user=True, + ) + .order_by("shared_books", "-mutuals", "-last_active_date") + .all()[:5] + ) + data = { + "suggested_users": suggested_users, + "next": "get-started-profile", + } + return TemplateResponse(request, "get_started/users.html", data)