From 43745b50d82ca8598791f05668d253aac0c8aa6c Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Thu, 23 Aug 2012 18:06:56 -0400 Subject: allowed user names > 30 chars --- askbot/__init__.py | 1 + askbot/doc/source/changelog.rst | 1 + askbot/setup_templates/settings.py | 1 + askbot/setup_templates/settings.py.mustache | 1 + .../default/templates/widgets/user_navigation.html | 2 +- askbot/startup_procedures.py | 19 +++++++++++++++++++ askbot/utils/forms.py | 5 ++++- askbot_requirements.txt | 1 + 8 files changed, 29 insertions(+), 2 deletions(-) diff --git a/askbot/__init__.py b/askbot/__init__.py index 8e4f20ab..59693a5a 100644 --- a/askbot/__init__.py +++ b/askbot/__init__.py @@ -32,6 +32,7 @@ REQUIREMENTS = { 'pystache': 'pystache==0.3.1', 'lamson': 'Lamson', 'pytz': 'pytz', + 'longerusername': 'longerusername', } #necessary for interoperability of django and coffin diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index d88cd734..9d28dd5f 100644 --- a/askbot/doc/source/changelog.rst +++ b/askbot/doc/source/changelog.rst @@ -3,6 +3,7 @@ Changes in Askbot Development version ------------------- +* Allow user names longer than 30 characters (Evgeny) * Option to disable feedback form for the anonymos users (Evgeny) * Optional restriction to have confirmed email address to join forum (Evgeny) * Optional list of allowed email addresses and email domain name for the new users (Evgeny) diff --git a/askbot/setup_templates/settings.py b/askbot/setup_templates/settings.py index 632c4e70..3b1f6bf5 100644 --- a/askbot/setup_templates/settings.py +++ b/askbot/setup_templates/settings.py @@ -150,6 +150,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( INSTALLED_APPS = ( + 'longerusername', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', diff --git a/askbot/setup_templates/settings.py.mustache b/askbot/setup_templates/settings.py.mustache index 18ac214d..69b030ed 100644 --- a/askbot/setup_templates/settings.py.mustache +++ b/askbot/setup_templates/settings.py.mustache @@ -149,6 +149,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( INSTALLED_APPS = ( + 'longerusername', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', diff --git a/askbot/skins/default/templates/widgets/user_navigation.html b/askbot/skins/default/templates/widgets/user_navigation.html index 717cd7ee..227053b0 100644 --- a/askbot/skins/default/templates/widgets/user_navigation.html +++ b/askbot/skins/default/templates/widgets/user_navigation.html @@ -17,7 +17,7 @@ {% trans %}sign out{% endtrans %} {% endif %} {% elif settings.USE_ASKBOT_LOGIN_SYSTEM %} - {% trans %}Hi, there! Please sign in{% endtrans %} + {% trans %}Hi there! Please sign in{% endtrans %} {% endif %} {% if request.user.is_authenticated() and request.user.is_administrator() %} {% trans %}settings{% endtrans %} diff --git a/askbot/startup_procedures.py b/askbot/startup_procedures.py index 0fec6d5f..4b4575cf 100644 --- a/askbot/startup_procedures.py +++ b/askbot/startup_procedures.py @@ -512,6 +512,24 @@ def test_custom_user_profile_tab(): footer = 'Please carefully read about adding a custom user profile tab.' print_errors(errors, header = header, footer = footer) +def test_longerusername(): + """tests proper installation of the "longerusername" app + """ + errors = list() + if 'longerusername' not in django_settings.INSTALLED_APPS: + errors.append( + "add 'longerusername', as the first item in the INSTALLED_APPS" + ) + else: + index = django_settings.INSTALLED_APPS.index('longerusername') + if index != 0: + message = "move 'longerusername', to the beginning of INSTALLED_APPS" + raise AskbotConfigError(message) + + if errors: + errors.append('run "python manage.py migrate longerusername"') + print_errors(errors) + def run_startup_tests(): """function that runs all startup tests, mainly checking settings config so far @@ -527,6 +545,7 @@ def run_startup_tests(): test_celery() #test_csrf_cookie_domain() test_staticfiles() + test_longerusername() test_avatar() settings_tester = SettingsTester({ 'CACHE_MIDDLEWARE_ANONYMOUS_ONLY': { diff --git a/askbot/utils/forms.py b/askbot/utils/forms.py index 319e9b9d..4375ca17 100644 --- a/askbot/utils/forms.py +++ b/askbot/utils/forms.py @@ -9,6 +9,7 @@ from askbot.conf import settings as askbot_settings from askbot.utils.slug import slugify from askbot.utils.functions import split_list from askbot import const +from longerusername import MAX_USERNAME_LENGTH import logging import urllib @@ -78,7 +79,9 @@ class UserNameField(StrippedNonEmptyCharField): if 'error_messages' in kw: error_messages.update(kw['error_messages']) del kw['error_messages'] - super(UserNameField,self).__init__(max_length=30, + + max_length = MAX_USERNAME_LENGTH + super(UserNameField,self).__init__(max_length=max_length, widget=forms.TextInput(attrs=login_form_widget_attrs), label=label, error_messages=error_messages, diff --git a/askbot_requirements.txt b/askbot_requirements.txt index 7b619c36..885a21e3 100644 --- a/askbot_requirements.txt +++ b/askbot_requirements.txt @@ -19,3 +19,4 @@ django-recaptcha-works python-openid pystache==0.3.1 pytz +longerusername -- cgit v1.2.3-1-g7c22