diff options
author | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-11-29 08:55:52 -0600 |
---|---|---|
committer | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-11-29 08:55:52 -0600 |
commit | a185ef7a269eb670e09acb5efeda97fa15efd44a (patch) | |
tree | 79037103fad37949bc4bf1e30a17634b7d4d4746 | |
parent | dbb130e5b8f615f8dfd9e2aa22879924fff78d1a (diff) | |
parent | 84abf90354bda4ae1bbc7a57e3fdd0ee9c82055a (diff) | |
download | askbot-a185ef7a269eb670e09acb5efeda97fa15efd44a.tar.gz askbot-a185ef7a269eb670e09acb5efeda97fa15efd44a.tar.bz2 askbot-a185ef7a269eb670e09acb5efeda97fa15efd44a.zip |
Merge branch 'master' of github.com:ASKBOT/askbot-devel
-rw-r--r-- | askbot/deps/django_authopenid/forms.py | 15 | ||||
-rw-r--r-- | askbot/deps/django_authopenid/views.py | 8 | ||||
-rw-r--r-- | askbot/forms.py | 13 | ||||
-rw-r--r-- | askbot/mail/__init__.py | 2 | ||||
-rw-r--r-- | askbot/media/style/style.css | 2 | ||||
-rw-r--r-- | askbot/skins/utils.py | 14 | ||||
-rw-r--r-- | askbot/utils/forms.py | 11 | ||||
-rw-r--r-- | askbot/views/writers.py | 2 |
8 files changed, 45 insertions, 22 deletions
diff --git a/askbot/deps/django_authopenid/forms.py b/askbot/deps/django_authopenid/forms.py index fbc5c6ff..3c0e8e7f 100644 --- a/askbot/deps/django_authopenid/forms.py +++ b/askbot/deps/django_authopenid/forms.py @@ -33,12 +33,13 @@ import logging from django import forms from django.contrib.auth.models import User from django.utils.translation import ugettext as _ -from django.conf import settings +from django.conf import settings as django_settings from askbot.conf import settings as askbot_settings from askbot import const as askbot_const from django.utils.safestring import mark_safe from recaptcha_works.fields import RecaptchaField from askbot.utils.forms import NextUrlField, UserNameField, UserEmailField, SetPasswordForm +from askbot.utils.loading import load_module # needed for some linux distributions like debian try: @@ -105,7 +106,7 @@ class OpenidSigninForm(forms.Form): if 'openid_url' in self.cleaned_data: openid_url = self.cleaned_data['openid_url'] if xri.identifierScheme(openid_url) == 'XRI' and getattr( - settings, 'OPENID_DISALLOW_INAMES', False + django_settings, 'OPENID_DISALLOW_INAMES', False ): raise forms.ValidationError(_('i-names are not supported')) return self.cleaned_data['openid_url'] @@ -449,3 +450,13 @@ class EmailPasswordForm(forms.Form): except: raise forms.ValidationError(_("sorry, there is no such user name")) return self.cleaned_data['username'] + +def get_registration_form_class(): + """returns class for the user registration form + user has a chance to specify the form via setting `REGISTRATION_FORM` + """ + custom_class = getattr(django_settings, 'REGISTRATION_FORM', None) + if custom_class: + return load_module(custom_class) + else: + return OpenidRegisterForm diff --git a/askbot/deps/django_authopenid/views.py b/askbot/deps/django_authopenid/views.py index 8e206120..1d1a9a57 100644 --- a/askbot/deps/django_authopenid/views.py +++ b/askbot/deps/django_authopenid/views.py @@ -903,7 +903,8 @@ def register(request, login_provider_name=None, user_identifier=None): email = request.session.get('email', '') logging.debug('request method is %s' % request.method) - register_form = forms.OpenidRegisterForm( + form_class = forms.get_registration_form_class() + register_form = form_class( initial={ 'next': next_url, 'username': request.session.get('username', ''), @@ -931,9 +932,10 @@ def register(request, login_provider_name=None, user_identifier=None): login_provider_name = request.session['login_provider_name'] logging.debug('trying to create new account associated with openid') - register_form = forms.OpenidRegisterForm(request.POST) + form_class = forms.get_registration_form_class() + register_form = form_class(request.POST) if not register_form.is_valid(): - logging.debug('OpenidRegisterForm is INVALID') + logging.debug('registration form is INVALID') else: username = register_form.cleaned_data['username'] email = register_form.cleaned_data['email'] diff --git a/askbot/forms.py b/askbot/forms.py index ed47e20e..50f17580 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -629,12 +629,13 @@ class ChangeUserStatusForm(forms.Form): super(ChangeUserStatusForm, self).__init__(*arg, **kwarg) #select user_status_choices depending on status of the moderator - if moderator.is_administrator(): - user_status_choices = ADMINISTRATOR_STATUS_CHOICES - elif moderator.is_moderator(): - user_status_choices = MODERATOR_STATUS_CHOICES - if subject.is_moderator() and subject != moderator: - raise ValueError('moderator cannot moderate another moderator') + if moderator.is_authenticated(): + if moderator.is_administrator(): + user_status_choices = ADMINISTRATOR_STATUS_CHOICES + elif moderator.is_moderator(): + user_status_choices = MODERATOR_STATUS_CHOICES + if subject.is_moderator() and subject != moderator: + raise ValueError('moderator cannot moderate another moderator') else: raise ValueError('moderator or admin expected from "moderator"') diff --git a/askbot/mail/__init__.py b/askbot/mail/__init__.py index 6e181b33..9da53ac4 100644 --- a/askbot/mail/__init__.py +++ b/askbot/mail/__init__.py @@ -1,6 +1,7 @@ """functions that send email in askbot these automatically catch email-related exceptions """ +import logging import os import re import smtplib @@ -133,6 +134,7 @@ def send_mail( ) msg.attach_alternative(body_text, "text/html") msg.send() + logging.debug('sent update to %s' % ','.join(recipient_list)) if related_object is not None: assert(activity_type is not None) except Exception, error: diff --git a/askbot/media/style/style.css b/askbot/media/style/style.css index ea81746f..1f5aabc5 100644 --- a/askbot/media/style/style.css +++ b/askbot/media/style/style.css @@ -498,7 +498,7 @@ body.anon #searchBar { width: 500px; } body.anon #searchBar .searchInput { - width: 440px; + width: 435px; } body.anon #searchBar .searchInputCancelable { width: 405px; diff --git a/askbot/skins/utils.py b/askbot/skins/utils.py index f0e149d0..e2a815b7 100644 --- a/askbot/skins/utils.py +++ b/askbot/skins/utils.py @@ -175,14 +175,14 @@ def update_media_revision(skin = None): from askbot.conf import settings as askbot_settings resource_revision = askbot_settings.MEDIA_RESOURCE_REVISION - if skin: - if skin in get_skin_choices(): - skin_path = get_path_to_skin(skin) - else: - raise MediaNotFound('Skin %s not found' % skin) + skin = skin or askbot_settings.ASKBOT_DEFAULT_SKIN + + if skin in get_available_skins().keys(): + skin_path = get_path_to_skin(skin) else: - skin = 'default' - skin_path = get_path_to_skin(askbot_settings.ASKBOT_DEFAULT_SKIN) + assert(skin != 'default') + msg = 'Skin "%s" not found. Please check ASKBOT_EXTRA_SKINS_DIR setting' + raise MediaNotFound(msg % skin) media_dirs = [ os.path.join(skin_path, 'media'), diff --git a/askbot/utils/forms.py b/askbot/utils/forms.py index 6f57f71f..6ade6e82 100644 --- a/askbot/utils/forms.py +++ b/askbot/utils/forms.py @@ -206,10 +206,17 @@ def email_is_allowed( return False class UserEmailField(forms.EmailField): - def __init__(self,skip_clean=False,**kw): + def __init__(self, skip_clean=False, **kw): self.skip_clean = skip_clean + + hidden = kw.pop('hidden', False) + if hidden is True: + widget_class = forms.HiddenInput + else: + widget_class = forms.TextInput + super(UserEmailField,self).__init__( - widget=forms.TextInput( + widget=widget_class( attrs=dict(login_form_widget_attrs, maxlength=200) ), label=mark_safe(_('Your email <i>(never shared)</i>')), diff --git a/askbot/views/writers.py b/askbot/views/writers.py index fadacd1f..895e026d 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -716,7 +716,7 @@ def delete_comment(request): parent = comment.parent comment.delete() #attn: recalc denormalized field - parent.comment_count = parent.comment_count - 1 + parent.comment_count = parent.comments.count() parent.save() parent.thread.invalidate_cached_data() |