diff --git a/colab/accounts/forms.py b/colab/accounts/forms.py index bc0f3699..58668d28 100644 --- a/colab/accounts/forms.py +++ b/colab/accounts/forms.py @@ -17,7 +17,7 @@ from django.utils.translation import ugettext_lazy as _ from django.utils.safestring import mark_safe -from .signals import user_created + from .utils.validators import validate_social_account from .utils import mailman @@ -242,14 +242,9 @@ def clean_password2(self): def save(self, commit=True): user = super(UserCreationForm, self).save(commit=False) - password = self.cleaned_data["password1"] - user.set_password(password) - + user.set_password(self.cleaned_data["password1"]) if commit: user.save() - - user_created.send(user.__class__, user=user, password=password) - return user diff --git a/colab/accounts/models.py b/colab/accounts/models.py index 1e5cb652..264adea8 100644 --- a/colab/accounts/models.py +++ b/colab/accounts/models.py @@ -9,20 +9,11 @@ from django.utils.crypto import get_random_string from django.utils.translation import ugettext_lazy as _ -from .signals import user_created, user_password_changed from .utils import mailman class ColabUserManager(UserManager): - def _create_user(self, username, email, password, - is_staff, is_superuser, **kwargs): - args = (username, email, password, is_staff, is_superuser) - user = super(ColabUserManager, self)._create_user(*args, **kwargs) - - user_created.send(user.__class__, user=user, password=password) - return user - def create_user(self, username, email=None, password=None, **extra_fields): # It creates a valid password for users @@ -77,11 +68,6 @@ def save(self, *args, **kwargs): self.username = self.username.lower() super(User, self).save(*args, **kwargs) - def set_password(self, raw_password): - super(User, self).set_password(raw_password) - if self.pk: - user_password_changed.send(User, user=self, password=raw_password) - # We need to have `email` field set as unique but Django does not # support field overriding (at least not until 1.6). diff --git a/colab/accounts/signals.py b/colab/accounts/signals.py deleted file mode 100644 index 58a6f083..00000000 --- a/colab/accounts/signals.py +++ /dev/null @@ -1,6 +0,0 @@ - -from django.dispatch import Signal - - -user_created = Signal(providing_args=['user', 'password']) -user_password_changed = Signal(providing_args=['user', 'password']) diff --git a/colab/accounts/tests/test_user.py b/colab/accounts/tests/test_user.py index ee263f9b..b55a686a 100644 --- a/colab/accounts/tests/test_user.py +++ b/colab/accounts/tests/test_user.py @@ -374,22 +374,3 @@ def test_update_user_bio_invalid_whitespace(self): self.authenticate_user() self.validate_non_mandatory_fields('bio', '', ' ') self.user.delete() - - @mock.patch('colab.accounts.signals.user_password_changed.send') - @mock.patch('colab.accounts.signals.user_created.send') - def test_user_created_signal(self, user_created_send, - user_password_changed_send): - user = User.objects.create_user( - username='test_user', - password='12345', - email='test@example.com', - ) - user_created_send.assert_called_with(User, user=user, password='12345') - user_password_changed_send.assert_not_called() - - @mock.patch('colab.accounts.signals.user_password_changed.send') - def test_user_password_changed_signal(self, user_password_changed_send): - user = User.objects.first() - user.set_password('54321') - user_password_changed_send.assert_called_with(User, user=user, - password='54321') diff --git a/colab/accounts/urls.py b/colab/accounts/urls.py index 3ffad036..335b0c26 100644 --- a/colab/accounts/urls.py +++ b/colab/accounts/urls.py @@ -29,7 +29,7 @@ {'template_name':'registration/password_reset_form_custom.html'}, name="password_reset"), - url(r'^change-password/?$', auth_views.password_change, + url(r'^change-password/?$',auth_views.password_change, {'template_name':'registration/password_change_form_custom.html'}, name='password_change'),