From ff1099d23e34350e9884532ccd29b44c552c4708 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 16 Mar 2020 17:29:37 -0700 Subject: [PATCH] User shelves page --- fedireads/static/format.css | 2 +- fedireads/templates/layout.html | 2 +- fedireads/templates/snippets/shelf.html | 2 +- fedireads/templates/user_shelves.html | 14 ++++++++++++++ fedireads/urls.py | 1 + fedireads/views.py | 16 ++++++++++++++-- 6 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 fedireads/templates/user_shelves.html diff --git a/fedireads/static/format.css b/fedireads/static/format.css index 86c94b4d0..34a735a67 100644 --- a/fedireads/static/format.css +++ b/fedireads/static/format.css @@ -483,7 +483,7 @@ tr { } tr:nth-child(even) { - background-color: #DDD; + background-color: #EEE; } th { diff --git a/fedireads/templates/layout.html b/fedireads/templates/layout.html index 257ff4ca1..e76cc2d46 100644 --- a/fedireads/templates/layout.html +++ b/fedireads/templates/layout.html @@ -26,7 +26,7 @@
diff --git a/fedireads/templates/snippets/shelf.html b/fedireads/templates/snippets/shelf.html index 8f51342be..b18967e72 100644 --- a/fedireads/templates/snippets/shelf.html +++ b/fedireads/templates/snippets/shelf.html @@ -30,7 +30,7 @@ {% for book in shelf.books.all %} - {% include 'snippets/book_cover.html' with book=book %} + {% include 'snippets/book_cover.html' with book=book size="small" %} {{ book.title }} diff --git a/fedireads/templates/user_shelves.html b/fedireads/templates/user_shelves.html new file mode 100644 index 000000000..a2da8b223 --- /dev/null +++ b/fedireads/templates/user_shelves.html @@ -0,0 +1,14 @@ +{% extends 'layout.html' %} +{% load fr_display %} +{% block content %} +{% include 'user_header.html' with user=user %} + +{% for shelf in shelves %} +
+

{{ shelf.name }}

+ {% include 'snippets/shelf.html' with shelf=shelf ratings=ratings %} +
+{% endfor %} + +{% endblock %} + diff --git a/fedireads/urls.py b/fedireads/urls.py index 8220957d6..e26912c64 100644 --- a/fedireads/urls.py +++ b/fedireads/urls.py @@ -39,6 +39,7 @@ urlpatterns = [ re_path(r'%s/?$' % user_path, views.user_page), re_path(r'%s\.json$' % local_user_path, views.user_page), re_path(r'user-edit/?$', views.edit_profile_page), + re_path(r'%s/shelves/?$' % local_user_path, views.user_shelves_page), re_path(r'%s/followers/?$' % local_user_path, views.followers_page), re_path(r'%s/followers.json$' % local_user_path, views.followers_page), re_path(r'%s/following/?$' % local_user_path, views.following_page), diff --git a/fedireads/views.py b/fedireads/views.py index a57a6ba16..da5b8159a 100644 --- a/fedireads/views.py +++ b/fedireads/views.py @@ -132,11 +132,9 @@ def user_page(request, username, subpage=None): # otherwise we're at a UI view # TODO: change display with privacy and authentication considerations - shelves = get_user_shelf_preview(user) data = { 'user': user, - 'shelves': shelves, 'is_self': request.user.id == user.id, } if subpage == 'followers': @@ -145,7 +143,12 @@ def user_page(request, username, subpage=None): elif subpage == 'following': data['following'] = user.following.all() return TemplateResponse(request, 'following.html', data) + elif subpage == 'shelves': + data['shelves'] = user.shelf_set.all() + return TemplateResponse(request, 'user_shelves.html', data) else: + shelves = get_user_shelf_preview(user) + data['shelves'] = shelves activities = models.Status.objects.filter( user=user, ).order_by( @@ -195,6 +198,15 @@ def following_page(request, username): return user_page(request, username, subpage='following') +@csrf_exempt +def user_shelves_page(request, username): + ''' list of followers ''' + if request.method != 'GET': + return HttpResponseBadRequest() + + return user_page(request, username, subpage='shelves') + + @csrf_exempt def status_page(request, username, status_id): ''' display a particular status (and replies, etc) '''