-from general import NextUrlField, UserNameField, UserEmailField, SetPasswordForm
+from general import NextUrlField, UserNameField, UserEmailField, UserRealNameField, SetPasswordForm
from forum.models import Question, User
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext as _
next = NextUrlField()
username = UserNameField()
email = UserEmailField()
+ real_name = UserRealNameField()
class TemporaryLoginRequestForm(forms.Form):
def __init__(self, data=None):
else:
return email
+class UserRealNameField(StrippedNonEmptyCharField):
+ def __init__(self, db_model=User, db_field='real_name', must_exist=True, skip_clean=False, label=_('Your real name'),**kw):
+ self.must_exist = must_exist
+ self.skip_clean = skip_clean
+ self.db_model = db_model
+ self.db_field = db_field
+ error_messages={'required':_('Real name is required')
+ }
+ if 'error_messages' in kw:
+ error_messages.update(kw['error_messages'])
+ del kw['error_messages']
+ super(UserRealNameField,self).__init__(max_length=100,
+ widget=forms.TextInput(attrs=login_form_widget_attrs),
+ label=label,
+ error_messages=error_messages,
+ **kw
+ )
+
+ def clean(self, real_name):
+ if self.skip_clean == True:
+ return real_name
+ try:
+ return super(UserRealNameField, self).clean(real_name)
+ except forms.ValidationError:
+ raise forms.ValidationError(self.error_messages['required'])
+
class SetPasswordForm(forms.Form):
password1 = forms.CharField(widget=forms.PasswordInput(attrs=login_form_widget_attrs),
label=_('choose password'),
{% endif %}
{{ form1.email }}
</div>
+ <div class="form-row-vertical margin-bottom">
+ <label for="id_real_name">{{ form1.real_name.label }}</label>
+ {% if form1.real_name.errors %}
+ <p class="error">{{ form1.real_name.errors|join:", " }}</p>
+ {% endif %}
+ {{ form1.real_name }}
+ </div>
{% if form1.password1 %}
<div class="form-row-vertical margin-bottom">
<label for="password1_id">{{ form1.password1.label }}</label>
form1 = SimpleRegistrationForm(request.POST)
if form1.is_valid():
- user_ = User(username=form1.cleaned_data['username'], email=form1.cleaned_data['email'])
+ user_ = User(username=form1.cleaned_data['username'], email=form1.cleaned_data['email'], real_name=form1.cleaned_data['real_name'])
user_.email_isvalid = request.session.get('auth_validated_email', '') == form1.cleaned_data['email']
user_.set_unusable_password()
username = user_data.get('username', '')
email = user_data.get('email', '')
+ real_name = user_data.get('real_name', '')
if email:
request.session['auth_validated_email'] = email
'next': '/',
'username': username,
'email': email,
+ 'real_name': real_name,
})
provider_context = AUTH_PROVIDERS[request.session['auth_provider']].context
sreg_attributes = {
"required": {
"email": "email",
- "nickname": "username"
+ "nickname": "username",
+ "fullname": "real_name"
}
}
<facet type="django" name="Django">\r
<configuration>\r
<option name="rootFolder" value="$MODULE_DIR$" />\r
- <option name="templatesFolder" value="$MODULE_DIR$/forum/skins/default/templates" />\r
<option name="settingsModule" value="settings.py" />\r
+ <option name="manageScript" value="manage.py" />\r
</configuration>\r
</facet>\r
</component>\r