summaryrefslogtreecommitdiffstats
path: root/forum/views/commands.py
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-05-08 00:42:08 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-05-08 00:42:08 -0400
commit2c2308ad323362ed6f8765e79c781412f6827157 (patch)
treeecfb59dc0eb8592b0173859527a2c96611d8485b /forum/views/commands.py
parentdbc9e355d821c380d4492ec878646bd46b8f0dfc (diff)
downloadaskbot-2c2308ad323362ed6f8765e79c781412f6827157.tar.gz
askbot-2c2308ad323362ed6f8765e79c781412f6827157.tar.bz2
askbot-2c2308ad323362ed6f8765e79c781412f6827157.zip
added vote rule and minimum rep settings
Diffstat (limited to 'forum/views/commands.py')
-rw-r--r--forum/views/commands.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/forum/views/commands.py b/forum/views/commands.py
index b5dbec56..2905426c 100644
--- a/forum/views/commands.py
+++ b/forum/views/commands.py
@@ -1,5 +1,7 @@
import datetime
+#todo: maybe eliminate usage of django.settings
from django.conf import settings
+from forum.conf import settings as forum_settings
from django.utils import simplejson
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render_to_response
@@ -138,7 +140,8 @@ def vote(request, id):#todo: pretty incomprehensible view used by various ajax c
vote = post.votes.filter(user=request.user)[0]
# get latest vote by the current user
# unvote should be less than certain time
- if (datetime.datetime.now().day - vote.voted_at.day) >= auth.VOTE_RULES['scope_deny_unvote_days'].value:
+ if (datetime.datetime.now().day - vote.voted_at.day) \
+ >= forum_settings.MAX_DAYS_TO_CANCEL_VOTE:
response_data['status'] = 2
else:
voted = vote.vote
@@ -152,7 +155,8 @@ def vote(request, id):#todo: pretty incomprehensible view used by various ajax c
response_data['status'] = 1
response_data['count'] = post.score
- elif Vote.objects.get_votes_count_today_from_user(request.user) >= auth.VOTE_RULES['scope_votes_per_user_per_day'].value:
+ elif Vote.objects.get_votes_count_today_from_user(request.user)\
+ >= forum_settings.MAX_VOTES_PER_USER_PER_DAY:
response_data['allowed'] = -3
else:
vote = Vote(user=request.user, content_object=post, vote=vote_score, voted_at=datetime.datetime.now())
@@ -163,8 +167,10 @@ def vote(request, id):#todo: pretty incomprehensible view used by various ajax c
# downvote
auth.onDownVoted(vote, post, request.user)
- votes_left = auth.VOTE_RULES['scope_votes_per_user_per_day'].value - Vote.objects.get_votes_count_today_from_user(request.user)
- if votes_left <= auth.VOTE_RULES['scope_warn_votes_left'].value:
+ votes_left = forum_settings.MAX_VOTES_PER_USER_PER_DAY \
+ - Vote.objects.get_votes_count_today_from_user(request.user)
+ if votes_left <= \
+ forum_settings.VOTES_LEFT_WARNING_THRESHOLD:
response_data['message'] = u'%s votes left' % votes_left
response_data['count'] = post.score
elif vote_type in ['7', '8']:
@@ -174,7 +180,7 @@ def vote(request, id):#todo: pretty incomprehensible view used by various ajax c
post_id = request.POST.get('postId')
post = get_object_or_404(Answer, id=post_id)
- if FlaggedItem.objects.get_flagged_items_count_today(request.user) >= auth.VOTE_RULES['scope_flags_per_user_per_day'].value:
+ if FlaggedItem.objects.get_flagged_items_count_today(request.user) >= forum_settings.MAX_FLAGS_PER_USER_PER_DAY:
response_data['allowed'] = -3
elif not auth.can_flag_offensive(request.user):
response_data['allowed'] = -2