Own registration page asking for full name as well

This commit is contained in:
Michal Čihař 2012-03-06 15:30:32 +01:00
parent 9eb9753bd5
commit 71be3bf3bf
4 changed files with 24 additions and 33 deletions

1
TODO
View File

@ -1,7 +1,6 @@
Things to implement before first public release
* Password change/reset pages
* Registration should ask for name
Possible features for future releases

View File

@ -33,4 +33,21 @@ class ContactForm(forms.Form):
)
class RegistrationForm(RegistrationFormUniqueEmail):
pass
first_name = forms.CharField(label = _('First name'))
last_name = forms.CharField(label = _('Last name'))
def __init__(self, *args, **kwargs):
super(RegistrationForm, self).__init__(*args, **kwargs)
self.fields['username'].label = _('Username')
self.fields['email'].label = _('Email address')
self.fields['password1'].label = _('Password')
self.fields['password2'].label = _('Password (again)')
def save(self, *args, **kwargs):
new_user = super(RegistrationForm, self).save(*args, **kwargs)
new_user.first_name = self.cleaned_data['first_name']
new_user.last_name = self.cleaned_data['last_name']
new_user.save()
return new_user

View File

@ -16,36 +16,10 @@
<form action="{% url 'registration.views.register' %}" method="post" accept-charset="utf-8">
{% csrf_token %}
<fieldset>
<legend>{% trans "User registration" %}</legend>
<label for="id_username">{% trans "Username" %}</label>
<p>{{ form.username }}
{% if form.username.errors %}
<br /><span class="ui-state-error">* {{ form.username.errors|join:"; " }}</span>
{% endif %}
</p>
<label for="id_email">{% trans "E-mail" %} {% trans "(will be used as Git author)" %}</label>
<p>{{ form.email }}
{% if form.email.errors %}
<br /><span class="ui-state-error">* {{ form.email.errors|join:"; " }}</span>
{% endif %}
</p>
<label for="id_password1">{% trans "Password" %}</label>
<p>{{ form.password1 }}
{% if form.password1.errors %}
<br /><span class="ui-state-error">* {{ form.password1.errors|join:"; " }}</span>
{% endif %}
</p>
<label for="id_password2">{% trans "Password (again)" %}</label>
<p>{{ form.password2 }}
{% if form.password2.errors %}
<br /><span class="ui-state-error">* {{ form.password2.errors|join:"; " }}</span>
{% endif %}
</p>
{% if form.non_field_errors %}
<ul class="ui-state-error">{{ form.non_field_errors.as_ul }}</ul>
{% endif %}
</fieldset>
<table>
{{ form.as_table }}
</table>
<p>{% trans "By registering you agree to use your name and email in Git commits." %}</p>
<p><input type="submit" value="{% trans 'Register' %}" /></p>
</form>

View File

@ -1,4 +1,5 @@
from django.conf.urls.defaults import patterns, include, url
from django.utils.translation import ugettext_lazy as _
from django.contrib import admin
from accounts.forms import RegistrationForm
@ -22,7 +23,7 @@ urlpatterns = patterns('',
# Auth
url(r'^accounts/', include('registration.urls')),
url(r'^accoints/register/$', 'registration.views.register', {'form_class': RegistrationForm}, name='registration_register'),
url(r'^accoints/register/$', 'registration.views.register', {'form_class': RegistrationForm, 'extra_context': {'title': _('User registration')}}, name='registration_register'),
url(r'^accounts/profile/', 'accounts.views.profile'),
url(r'^contact/', 'accounts.views.contact'),