return 0
def _add_to_rep(self, value):
- if self.user.reputation + value < 1:
+ if (self.user.reputation + value < 1) and not settings.ALLOW_NEGATIVE_REPUTATION:
return 0
else:
return models.F('reputation') + value
is_approved = models.BooleanField(default=False)
email_isvalid = models.BooleanField(default=False)
- reputation = models.PositiveIntegerField(default=0)
+ reputation = models.IntegerField(default=0)
gold = models.PositiveIntegerField(default=0)
silver = models.PositiveIntegerField(default=0)
bronze = models.PositiveIntegerField(default=0)
return md5(self.email.lower()).hexdigest()
def save(self, *args, **kwargs):
- if self.reputation < 0:
+ # If the community doesn't allow negative reputation, set it to 0
+ if not settings.ALLOW_NEGATIVE_REPUTATION and self.reputation < 0:
self.reputation = 0
new = not bool(self.id)
USERS_SET = SettingSet('users', _('Users settings'), _("General settings for the OSQA users."), 20)
+ALLOW_NEGATIVE_REPUTATION = Setting('ALLOW_NEGATIVE_REPUTATION', True, USERS_SET, dict(
+label = _("Allow negative reputation"),
+help_text = _("Check if you want to allow negative user reputations in the community."),
+required=False))
+
STORE_GREETING_IN_COOKIE = Setting('STORE_GREETING_IN_COOKIE', True, USERS_SET, dict(
label = _("Store greeting in cookie"),
help_text = _("If you check this the greeting will be stored in a cookie and the users won't be notified on logout."),