From 3917b73d5bd4089f97805be73048742e3a6362da Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Thu, 19 Aug 2010 18:14:04 -0400 Subject: allow unicode user name, make date of birth optional and changed wording in faq --- askbot/forms.py | 50 +++++++++++++++++++++++++++------ askbot/skins/default/templates/faq.html | 2 +- askbot/utils/forms.py | 2 +- askbot/views/users.py | 6 +--- 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/askbot/forms.py b/askbot/forms.py index 2fd1afd5..76f85741 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -444,14 +444,49 @@ class EditAnswerForm(forms.Form): self.fields['text'].initial = revision.text class EditUserForm(forms.Form): - email = forms.EmailField(label=u'Email', help_text=_('this email does not have to be linked to gravatar'), required=True, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) + email = forms.EmailField( + label=u'Email', + help_text=_('this email does not have to be linked to gravatar'), + required=True, + max_length=255, + widget=forms.TextInput(attrs={'size' : 35}) + ) + if askbot_settings.EDITABLE_SCREEN_NAME: username = UserNameField(label=_('Screen name')) - realname = forms.CharField(label=_('Real name'), required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) - website = forms.URLField(label=_('Website'), required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) - city = forms.CharField(label=_('Location'), required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35})) - birthday = forms.DateField(label=_('Date of birth'), help_text=_('will not be shown, used to calculate age, format: YYYY-MM-DD'), required=False, widget=forms.TextInput(attrs={'size' : 35})) - about = forms.CharField(label=_('Profile'), required=False, widget=forms.Textarea(attrs={'cols' : 60})) + realname = forms.CharField( + label=_('Real name'), + required=False, + max_length=255, + widget=forms.TextInput(attrs={'size' : 35}) + ) + + website = forms.URLField( + label=_('Website'), + required=False, + max_length=255, + widget=forms.TextInput(attrs={'size' : 35}) + ) + + city = forms.CharField( + label=_('Location'), + required=False, + max_length=255, + widget=forms.TextInput(attrs={'size' : 35}) + ) + + birthday = forms.DateField( + label=_('Date of birth'), + help_text=_('will not be shown, used to calculate age, format: YYYY-MM-DD'), + required=False, + widget=forms.TextInput(attrs={'size' : 35}) + ) + + about = forms.CharField( + label=_('Profile'), + required=False, + widget=forms.Textarea(attrs={'cols' : 60}) + ) def __init__(self, user, *args, **kwargs): super(EditUserForm, self).__init__(*args, **kwargs) @@ -466,8 +501,7 @@ class EditUserForm(forms.Form): if user.date_of_birth is not None: self.fields['birthday'].initial = user.date_of_birth - else: - self.fields['birthday'].initial = '1990-01-01' + self.fields['about'].initial = user.about self.user = user diff --git a/askbot/skins/default/templates/faq.html b/askbot/skins/default/templates/faq.html index 83a24d68..f3a26d0f 100644 --- a/askbot/skins/default/templates/faq.html +++ b/askbot/skins/default/templates/faq.html @@ -71,7 +71,7 @@ {{settings.MIN_REP_TO_RETAG_OTHERS_QUESTIONS}} - {% trans "retag questions" %} + {% trans "retag other's questions" %} {% if settings.WIKI_ON %} diff --git a/askbot/utils/forms.py b/askbot/utils/forms.py index 62aa0170..575416bc 100644 --- a/askbot/utils/forms.py +++ b/askbot/utils/forms.py @@ -85,7 +85,7 @@ class UserNameField(StrippedNonEmptyCharField): except forms.ValidationError: raise forms.ValidationError(self.error_messages['required']) - username_regex = re.compile(const.USERNAME_REGEX_STRING) + username_regex = re.compile(const.USERNAME_REGEX_STRING, re.UNICODE) if self.required and not username_regex.search(username): raise forms.ValidationError(self.error_messages['invalid']) if username in self.RESERVED_NAMES: diff --git a/askbot/views/users.py b/askbot/views/users.py index ea1f03a5..9f74fbf4 100644 --- a/askbot/views/users.py +++ b/askbot/views/users.py @@ -253,11 +253,7 @@ def edit_user(request, id): user.real_name = sanitize_html(form.cleaned_data['realname']) user.website = sanitize_html(form.cleaned_data['website']) user.location = sanitize_html(form.cleaned_data['city']) - user.date_of_birth = sanitize_html(form.cleaned_data['birthday']) - - if len(user.date_of_birth) == 0: - user.date_of_birth = '1900-01-01' - + user.date_of_birth = form.cleaned_data.get('birthday', None) user.about = sanitize_html(form.cleaned_data['about']) user.save() -- cgit v1.2.3-1-g7c22