X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/eb1b2a97a14f9a4daa772709972e0d1650ac4fd3..f1defc59ca7a7b15e17e8a59c72a726ae937d8e5:/forum/views/users.py diff --git a/forum/views/users.py b/forum/views/users.py index 9dbde3e..6686a26 100644 --- a/forum/views/users.py +++ b/forum/views/users.py @@ -24,24 +24,22 @@ from forum.utils import pagination from forum.views.readers import QuestionListPaginatorContext, AnswerPaginatorContext from forum.settings import ONLINE_USERS -import bisect import time import datetime import decorators -import unicodedata class UserReputationSort(pagination.SimpleSort): def apply(self, objects): return objects.order_by('-is_active', self.order_by) class UserListPaginatorContext(pagination.PaginatorContext): - def __init__(self): + def __init__(self, pagesizes=(20, 35, 60)): super (UserListPaginatorContext, self).__init__('USERS_LIST', sort_methods=( (_('reputation'), UserReputationSort(_('reputation'), '-reputation', _("sorted by reputation"))), (_('newest'), pagination.SimpleSort(_('recent'), '-date_joined', _("newest members"))), (_('last'), pagination.SimpleSort(_('oldest'), 'date_joined', _("oldest members"))), (_('name'), pagination.SimpleSort(_('by username'), 'username', _("sorted by username"))), - ), pagesizes=(20, 35, 60)) + ), pagesizes=pagesizes) class SubscriptionListPaginatorContext(pagination.PaginatorContext): def __init__(self): @@ -306,7 +304,7 @@ def user_profile(request, user): up_votes = user.vote_up_count down_votes = user.vote_down_count votes_today = user.get_vote_count_today() - votes_total = users.can_vote_count_today() + votes_total = user.can_vote_count_today() user_tags = Tag.objects.filter(Q(nodes__author=user) | Q(nodes__children__author=user)) \ .annotate(user_tag_usage_count=Count('name')).order_by('-user_tag_usage_count') @@ -315,7 +313,7 @@ def user_profile(request, user): Badge.objects.filter(awards__user=user).values('id').annotate(count=Count('cls')).order_by('-count')] return pagination.paginated(request, ( - ('questions', QuestionListPaginatorContext('USER_QUESTION_LIST', _('questions'), 15)), + ('questions', QuestionListPaginatorContext('USER_QUESTION_LIST', _('questions'), default_pagesize=15)), ('answers', UserAnswersPaginatorContext())), { "view_user" : user, "questions" : questions,