diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-11-09 00:15:23 -0300 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-11-09 00:15:23 -0300 |
commit | fb8037803ec5fd8cba613c22310077324cbea49c (patch) | |
tree | f8f4e55668c560b84c68a465dace6243d0041e79 /askbot/forms.py | |
parent | 2373ab019c5515153fb085a5c2c80c1ac179f873 (diff) | |
download | askbot-fb8037803ec5fd8cba613c22310077324cbea49c.tar.gz askbot-fb8037803ec5fd8cba613c22310077324cbea49c.tar.bz2 askbot-fb8037803ec5fd8cba613c22310077324cbea49c.zip |
applied the karma limit to post links to questions posted before signing in
Diffstat (limited to 'askbot/forms.py')
-rw-r--r-- | askbot/forms.py | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/askbot/forms.py b/askbot/forms.py index a4365776..ed47e20e 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -4,6 +4,7 @@ import re from django import forms from askbot import const from askbot.const import message_keys +from django.core.exceptions import PermissionDenied from django.forms.util import ErrorList from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy, string_concat @@ -11,7 +12,6 @@ from django.utils.text import get_text_list from django.contrib.auth.models import User from django_countries import countries from askbot.utils.forms import NextUrlField, UserNameField -from askbot.utils.markup import URL_RE from askbot.mail import extract_first_email_address from recaptcha_works.fields import RecaptchaField from askbot.conf import settings as askbot_settings @@ -302,20 +302,16 @@ class EditorField(forms.CharField): ) % self.min_length raise forms.ValidationError(msg) - if re.search(URL_RE, value): - min_rep = askbot_settings.MIN_REP_TO_SUGGEST_LINK - if self.user.is_anonymous(): - raise forms.ValidationError( - _('Links or images cannot be posted anonymously') - ) - elif self.user.reputation < min_rep: - raise forms.ValidationError( - ungettext_lazy( - 'At at least %d karma point is required to post links', - 'At at least %d karma points are required to post links', - min_rep - ) % min_rep - ) + if self.user.is_anonymous(): + #we postpone this validation if user is posting + #before logging in, up until publishing the post + return value + + try: + self.user.assert_can_post_text(value) + except PermissionDenied, e: + raise forms.ValidationError(unicode(e)) + return value |