Commit b20ee3b9 authored by Adrián Ribao's avatar Adrián Ribao
Browse files

varias mejoras

parent 668847bc
......@@ -3,10 +3,11 @@ from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from perfiles.urls import urlpatterns as baseurlpatterns
from perfiles.backends.confirmationemail.views import Activate, CreateUser
from common.forms import RegistrationForm
urlpatterns = patterns('',
url(r'^register/$',
CreateUser.as_view(),
CreateUser.as_view(form_class=RegistrationForm),
name='register'
),
url(r'^activation-sent/$',
......
......@@ -57,8 +57,8 @@ class CreateUser(CreateUserBase):
data = form.cleaned_data
user = User.objects.create_user(data['username'], data['email'], data['password'])
user.is_active = False
user.first_name = data['first_name']
user.last_name = data['last_name']
user.first_name = data.get('first_name', '')
user.last_name = data.get('last_name', '')
user.save()
# Send the activation email
self._send_activation_email(user)
......
......@@ -16,3 +16,14 @@ class CreateUserForm(forms.ModelForm):
raise forms.ValidationError(_(u"The passwords don't match"))
return self.cleaned_data
def clean_username(self):
username = self.cleaned_data.get('username')
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
user = None
if user:
raise forms.ValidationError(_(u"The username has already been taken"))
return self.cleaned_data
......@@ -16,7 +16,6 @@
{% endif %}
<input type="submit" name="login" value="{% trans "login" %}"/>
</form>
<p class="register"><a href="{% url register %}">{% trans "Regístrate en CossioEmplea" %}</a></p>
</div>
{% endblock %}
......@@ -2,11 +2,15 @@
from django.conf.urls.defaults import *
from django.contrib.auth.views import login, logout, password_change, password_change_done,\
password_reset, password_reset_done, password_reset_confirm, password_reset_complete
from longerusername.forms import AuthenticationForm
urlpatterns = patterns('',
url(r'^login/$',
login,
{'template_name': 'registration/login.html'},
{
'template_name': 'registration/login.html',
'authentication_form': AuthenticationForm,
},
name='auth_login'),
url(r'^logout/$',
logout,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment