mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-26 18:10:36 +00:00
User page redesign
This commit is contained in:
parent
c41b53bdbe
commit
7e73bae07d
6 changed files with 136 additions and 64 deletions
26
fedireads/templates/followers.html
Normal file
26
fedireads/templates/followers.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% load fr_display %}
|
||||
{% block content %}
|
||||
{% include 'user_header.html' with user=user %}
|
||||
|
||||
<div class="content-container">
|
||||
<h2>Followers</h2>
|
||||
{% for followers in followers %}
|
||||
<div class="row shrink">
|
||||
<div>
|
||||
{% include 'snippets/avatar.html' with user=followers %}
|
||||
</div>
|
||||
<div>
|
||||
{% include 'snippets/username.html' with user=followers show_full=True %}
|
||||
</div>
|
||||
<div>
|
||||
{% include 'snippets/follow_button.html' with user=followers %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if not followers.count %}
|
||||
<div>{{ user|username }} has no followers</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
26
fedireads/templates/following.html
Normal file
26
fedireads/templates/following.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% load fr_display %}
|
||||
{% block content %}
|
||||
{% include 'user_header.html' %}
|
||||
|
||||
<div class="content-container">
|
||||
<h2>Following</h2>
|
||||
{% for follower in user.following.all %}
|
||||
<div class="row shrink">
|
||||
<div>
|
||||
{% include 'snippets/avatar.html' with user=follower %}
|
||||
</div>
|
||||
<div>
|
||||
{% include 'snippets/username.html' with user=follower show_full=True %}
|
||||
</div>
|
||||
<div>
|
||||
{% include 'snippets/follow_button.html' with user=follower %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if not following.count %}
|
||||
<div>No one is following {{ user|username }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -7,12 +7,12 @@ Follow request already sent.
|
|||
<form action="/follow/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ user.username }}"></input>
|
||||
<input type="submit" value="Follow"></input>
|
||||
<button type="submit">Follow</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<form action="/unfollow/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ user.username }}"></input>
|
||||
<input type="submit" value="Unfollow"></input>
|
||||
<button type="submit">Unfollow</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
|
|
@ -1,52 +1,7 @@
|
|||
{% extends 'layout.html' %}
|
||||
{% load humanize %}
|
||||
{% block content %}
|
||||
<div class="content-container user-profile">
|
||||
<h2>User Profile
|
||||
{% if is_self %}
|
||||
<a href="/user-edit/">edit
|
||||
<span class="icon icon-pencil">
|
||||
<span class="hidden-text">Edit profile</span>
|
||||
</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</h2>
|
||||
|
||||
<div class="row">
|
||||
<div class="pic-container">
|
||||
{% include 'snippets/avatar.html' with user=user large=True %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>{% if user.name %}{{ user.name }}{% else %}{{ user.localname }}{% endif %}</p>
|
||||
<p>{{ user.username }}</p>
|
||||
<p>Joined {{ user.created_date | naturaltime }}</p>
|
||||
</div>
|
||||
|
||||
{% if user.summary %}
|
||||
<blockquote><span class="icon icon-quote-open"></span>{{ user.summary | safe }}</blockquote>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if not is_self %}
|
||||
{% include 'snippets/follow_button.html' with user=user %}
|
||||
{% endif %}
|
||||
|
||||
{% if is_self and user.follower_requests.all %}
|
||||
<div class="follow-requests">
|
||||
<h2>Follow Requests</h2>
|
||||
{% for requester in user.follower_requests.all %}
|
||||
<div class="row shrink">
|
||||
<p>
|
||||
{% include 'snippets/username.html' with user=requester show_full=True %}
|
||||
</p>
|
||||
{% include 'snippets/follow_request_buttons.html' with user=requester %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
{% include 'user_header.html' with user=user %}
|
||||
<div class="all-shelves content-container">
|
||||
{% include 'snippets/covers_shelf.html' with shelves=shelves user=user %}
|
||||
</div>
|
||||
|
@ -58,6 +13,11 @@
|
|||
{% include 'snippets/status.html' with status=activity %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if not activities %}
|
||||
<div class="content-container">
|
||||
<p>No activities yet!</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
50
fedireads/templates/user_header.html
Normal file
50
fedireads/templates/user_header.html
Normal file
|
@ -0,0 +1,50 @@
|
|||
{% load humanize %}
|
||||
{% load fr_display %}
|
||||
<div class="content-container user-profile">
|
||||
<h2>User Profile
|
||||
{% if is_self %}
|
||||
<a href="/user-edit/">edit
|
||||
<span class="icon icon-pencil">
|
||||
<span class="hidden-text">Edit profile</span>
|
||||
</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</h2>
|
||||
|
||||
<div class="row">
|
||||
<div class="pic-container">
|
||||
{% include 'snippets/avatar.html' with user=user large=True %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>{% if user.name %}{{ user.name }}{% else %}{{ user.localname }}{% endif %}</p>
|
||||
<p>{{ user.username }}</p>
|
||||
<p>Joined {{ user.created_date | naturaltime }}</p>
|
||||
<p>
|
||||
<a href="/user/{{ user|username }}/followers">{{ user.followers.count }} follower{{ user.followers.count | pluralize }}</a>,
|
||||
<a href="/user/{{ user|username }}/following">{{ user.following.count }} following</a></p>
|
||||
</div>
|
||||
|
||||
{% if user.summary %}
|
||||
<blockquote><span class="icon icon-quote-open"></span>{{ user.summary | safe }}</blockquote>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if not is_self %}
|
||||
{% include 'snippets/follow_button.html' with user=user %}
|
||||
{% endif %}
|
||||
|
||||
{% if is_self and user.follower_requests.all %}
|
||||
<div class="follow-requests">
|
||||
<h2>Follow Requests</h2>
|
||||
{% for requester in user.follower_requests.all %}
|
||||
<div class="row shrink">
|
||||
<p>
|
||||
{% include 'snippets/username.html' with user=requester show_full=True %}
|
||||
</p>
|
||||
{% include 'snippets/follow_request_buttons.html' with user=requester %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
@ -3,7 +3,6 @@ from django.contrib.auth.decorators import login_required
|
|||
from django.db.models import Avg, Q
|
||||
from django.http import HttpResponseBadRequest, HttpResponseNotFound, \
|
||||
JsonResponse
|
||||
from django.shortcuts import redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
|
@ -120,7 +119,7 @@ def notifications_page(request):
|
|||
return TemplateResponse(request, 'notifications.html', data)
|
||||
|
||||
@csrf_exempt
|
||||
def user_page(request, username):
|
||||
def user_page(request, username, subpage=None):
|
||||
''' profile page for a user '''
|
||||
try:
|
||||
user = get_user_from_username(username)
|
||||
|
@ -135,19 +134,25 @@ def user_page(request, username):
|
|||
# TODO: change display with privacy and authentication considerations
|
||||
shelves = get_user_shelf_preview(user)
|
||||
|
||||
activities = models.Status.objects.filter(
|
||||
user=user,
|
||||
).order_by(
|
||||
'-created_date',
|
||||
).select_subclasses()[:10]
|
||||
|
||||
data = {
|
||||
'user': user,
|
||||
'shelves': shelves,
|
||||
'is_self': request.user.id == user.id,
|
||||
'activities': activities,
|
||||
}
|
||||
return TemplateResponse(request, 'user.html', data)
|
||||
if subpage == 'followers':
|
||||
data['followers'] = user.followers.all()
|
||||
return TemplateResponse(request, 'followers.html', data)
|
||||
elif subpage == 'following':
|
||||
data['following'] = user.following.all()
|
||||
return TemplateResponse(request, 'following.html', data)
|
||||
else:
|
||||
activities = models.Status.objects.filter(
|
||||
user=user,
|
||||
).order_by(
|
||||
'-created_date',
|
||||
).select_subclasses().all()[:10]
|
||||
data['activities'] = activities
|
||||
return TemplateResponse(request, 'user.html', data)
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
|
@ -167,7 +172,7 @@ def followers_page(request, username):
|
|||
page = request.GET.get('page')
|
||||
return JsonResponse(activitypub.get_followers(user, page, followers))
|
||||
|
||||
return redirect('/user/' + username)
|
||||
return user_page(request, username, subpage='followers')
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
|
@ -187,7 +192,7 @@ def following_page(request, username):
|
|||
page = request.GET.get('page')
|
||||
return JsonResponse(activitypub.get_following(user, page, following))
|
||||
|
||||
return redirect('/user/' + username)
|
||||
return user_page(request, username, subpage='following')
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
|
@ -386,10 +391,15 @@ def get_user_shelf_preview(user, shelf_proportions=None):
|
|||
break
|
||||
if count > shelf_max or count < 0:
|
||||
count = shelf_max
|
||||
shelf = models.Shelf.objects.get(
|
||||
user=user,
|
||||
identifier=identifier,
|
||||
)
|
||||
|
||||
try:
|
||||
shelf = models.Shelf.objects.get(
|
||||
user=user,
|
||||
identifier=identifier,
|
||||
)
|
||||
except models.Shelf.DoesNotExist:
|
||||
continue
|
||||
|
||||
if not shelf.books.count():
|
||||
continue
|
||||
books = models.ShelfBook.objects.filter(
|
||||
|
|
Loading…
Reference in a new issue