Add new user tab listing only reviews and comments
This commit is contained in:
parent
0452731d02
commit
fbd8e22b97
6 changed files with 106 additions and 1 deletions
|
@ -137,7 +137,13 @@ from .setup import InstanceConfig, CreateAdmin
|
|||
from .status import CreateStatus, EditStatus, DeleteStatus, update_progress
|
||||
from .status import edit_readthrough
|
||||
from .updates import get_notification_count, get_unread_status_string
|
||||
from .user import User, hide_suggestions, user_redirect, toggle_guided_tour
|
||||
from .user import (
|
||||
User,
|
||||
UserReviewsComments,
|
||||
hide_suggestions,
|
||||
user_redirect,
|
||||
toggle_guided_tour,
|
||||
)
|
||||
from .relationships import Relationships
|
||||
from .wellknown import *
|
||||
from .annual_summary import (
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
""" The user profile """
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.paginator import Paginator
|
||||
from django.db.models import Q
|
||||
from django.http import Http404
|
||||
from django.shortcuts import redirect
|
||||
from django.template.response import TemplateResponse
|
||||
|
@ -100,6 +101,49 @@ class User(View):
|
|||
return TemplateResponse(request, "user/user.html", data)
|
||||
|
||||
|
||||
class UserReviewsComments(View):
|
||||
"""user's activity filtered by reviews and comments"""
|
||||
|
||||
def get(self, request, username):
|
||||
"""user's activity filtered by reviews and comments"""
|
||||
user = get_user_from_username(request.user, username)
|
||||
is_self = request.user.id == user.id
|
||||
|
||||
activities = (
|
||||
models.Status.privacy_filter(
|
||||
request.user,
|
||||
)
|
||||
.filter(
|
||||
Q(review__isnull=False) | Q(comment__isnull=False),
|
||||
user=user,
|
||||
)
|
||||
.exclude(
|
||||
privacy="direct",
|
||||
)
|
||||
.select_related(
|
||||
"user",
|
||||
"reply_parent",
|
||||
"review__book",
|
||||
"comment__book",
|
||||
"quotation__book",
|
||||
)
|
||||
.prefetch_related(
|
||||
"mention_books",
|
||||
"mention_users",
|
||||
"attachments",
|
||||
)
|
||||
)
|
||||
|
||||
paginated = Paginator(activities, PAGE_LENGTH)
|
||||
|
||||
data = {
|
||||
"user": user,
|
||||
"is_self": is_self,
|
||||
"activities": paginated.get_page(request.GET.get("page", 1)),
|
||||
}
|
||||
return TemplateResponse(request, "user/reviews_comments.html", data)
|
||||
|
||||
|
||||
@require_POST
|
||||
@login_required
|
||||
def hide_suggestions(request):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue