X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/4439fa35984bca40f3105a5382be30b305bd9ebf..f32668123bbf48a0b73e90024bc09aa60e903ea0:/forum/views/users.py?ds=sidebyside diff --git a/forum/views/users.py b/forum/views/users.py index 50c295f..0eeb122 100644 --- a/forum/views/users.py +++ b/forum/views/users.py @@ -11,6 +11,7 @@ from forum.http_responses import HttpResponseUnauthorized from django.utils.translation import ugettext as _ from django.utils.http import urlquote_plus from django.utils.html import strip_tags +from django.utils.encoding import smart_unicode from django.utils import simplejson from django.core.urlresolvers import reverse, NoReverseMatch from forum.forms import * @@ -34,13 +35,13 @@ class UserReputationSort(pagination.SimpleSort): 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): @@ -269,7 +270,7 @@ def user_view(template, tab_name, tab_title, tab_description, private=False, tab decorated = decorate.params.withfn(params)(fn) def result(context, request, user): - rev_page_title = user.username + " - " + tab_description + rev_page_title = smart_unicode(user.username) + " - " + tab_description context.update({ "tab": "users", @@ -285,7 +286,7 @@ def user_view(template, tab_name, tab_title, tab_description, private=False, tab if tabbed: def url_getter(vu): try: - return reverse(fn.__name__, kwargs={'id': vu.id, 'slug': slugify(vu.username)}) + return reverse(fn.__name__, kwargs={'id': vu.id, 'slug': slugify(smart_unicode(vu.username))}) except NoReverseMatch: return reverse(fn.__name__, kwargs={'id': vu.id}) @@ -305,7 +306,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 = int(settings.MAX_VOTES_PER_DAY) + 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') @@ -314,7 +315,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, @@ -368,7 +369,7 @@ def user_favorites(request, user): @user_view('users/subscriptions.html', 'subscriptions', _('subscription'), _('subscriptions'), True, tabbed=False) def user_subscriptions(request, user): - enabled = user.subscription_settings.enable_notifications + enabled = True tab = request.GET.get('tab', "settings") @@ -382,14 +383,6 @@ def user_subscriptions(request, user): form.save() message = _('New subscription settings are now saved') - if 'notswitch' in request.POST: - enabled = not enabled - - if enabled: - message = _('Notifications are now enabled') - else: - message = _('Notifications are now disabled') - user.subscription_settings.enable_notifications = enabled user.subscription_settings.save()