def can_vote_down(self):
return False
+
+ def can_vote_count_today(self):
+ return 0
def can_flag_offensive(self, post=None):
return False
today = datetime.date.today()
return self.actions.filter(canceled=False, action_type="flag",
action_date__gte=(today - datetime.timedelta(days=1))).count()
-
+
+ def can_vote_count_today(self):
+ votes_today = settings.MAX_VOTES_PER_DAY
+
+ if settings.USER_REPUTATION_TO_MAX_VOTES:
+ votes_today = votes_today + int(self.reputation)
+
+ return votes_today
+
@true_if_is_super_or_staff
def can_view_deleted_post(self, post):
return post.author == self
)\r
\r
INITIAL_EMAIL_SUBSCRIBE_OPTION = Setting('INITIAL_EMAIL_SUBSCRIBE_OPTION', 'y', EMAIL_SET, dict(\r
-label = _("Default email subscription "),\r
+label = _("Default email subscription"),\r
widget=RadioSelect,\r
choices=EMAIL_SUBSCRIBE_CHOICES,\r
help_text = _("Choose what should be the default email subscription status while registering."),\r
\r
VOTE_RULES_SET = SettingSet('voting', _('Voting rules'), _("Configure the voting rules on your site."), 400)\r
\r
+USER_REPUTATION_TO_MAX_VOTES = Setting('USER_REPUTATION_TO_MAX_VOTES', True, VOTE_RULES_SET, dict(\r
+label = _("Add reputation to max votes per day"), required=False,\r
+help_text = _("The user reputation is added to the static MAX_VOTES_PER_DAY option. Users with higher reputation can vote more.")))\r
+\r
MAX_VOTES_PER_DAY = Setting('MAX_VOTES_PER_DAY', 30, VOTE_RULES_SET, dict(\r
label = _("Maximum votes per day"),\r
help_text = _("The maximum number of votes an user can cast per day.")))\r
user_vote_count_today = user.get_vote_count_today()
- if user_vote_count_today >= int(settings.MAX_VOTES_PER_DAY):
+ if user_vote_count_today >= user.can_vote_count_today():
raise NotEnoughLeftException(_('votes'), str(settings.MAX_VOTES_PER_DAY))
new_vote_cls = (vote_type == 'up') and VoteUpAction or VoteDownAction