From: jordan Date: Mon, 16 May 2011 18:18:57 +0000 (+0000) Subject: Resolves Jira OSQA-682, do not use the MAX_VOTES_PER_DAT setting, but the can_vote_co... X-Git-Tag: live~274 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/eb1b2a97a14f9a4daa772709972e0d1650ac4fd3 Resolves Jira OSQA-682, do not use the MAX_VOTES_PER_DAT setting, but the can_vote_count_today User object method to calculate how more times the user can vote for the certain day. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1039 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/views/commands.py b/forum/views/commands.py index 630e0ef..aeb01e5 100644 --- a/forum/views/commands.py +++ b/forum/views/commands.py @@ -73,6 +73,7 @@ def vote_post(request, id, vote_type): raise NotEnoughRepPointsException(vote_type == 'up' and _('upvote') or _('downvote')) user_vote_count_today = user.get_vote_count_today() + user_can_vote_count_today = user.can_vote_count_today() if user_vote_count_today >= user.can_vote_count_today(): raise NotEnoughLeftException(_('votes'), str(settings.MAX_VOTES_PER_DAY)) @@ -104,7 +105,7 @@ def vote_post(request, id, vote_type): } } - votes_left = (int(settings.MAX_VOTES_PER_DAY) - user_vote_count_today) + (vote_type == 'none' and -1 or 1) + votes_left = (user_can_vote_count_today - user_vote_count_today) + (vote_type == 'none' and -1 or 1) if int(settings.START_WARN_VOTES_LEFT) >= votes_left: response['message'] = _("You have %(nvotes)s %(tvotes)s left today.") % \ diff --git a/forum/views/users.py b/forum/views/users.py index d532baf..9dbde3e 100644 --- a/forum/views/users.py +++ b/forum/views/users.py @@ -306,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 = users.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')