forked from expo/troggle
[svn] Use the django compatability thing - webserver might have old python on it....
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import hashlib
|
from django.utils.hashcompat import sha_constructor
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
@@ -152,8 +152,8 @@ class RegistrationManager(models.Manager):
|
|||||||
username and a random salt.
|
username and a random salt.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
salt = hashlib.sha1(str(random.random())).hexdigest()[:5]
|
salt = sha_constructor(str(random.random())).hexdigest()[:5]
|
||||||
activation_key = hashlib.sha1(salt+user.username).hexdigest()
|
activation_key = sha_constructor(salt+user.username).hexdigest()
|
||||||
return self.create(user=user,
|
return self.create(user=user,
|
||||||
activation_key=activation_key)
|
activation_key=activation_key)
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ getting django-registration running in the default setup, to wit:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import hashlib
|
from django.utils.hashcompat import sha_constructor
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
@@ -115,7 +115,7 @@ class RegistrationModelTests(RegistrationTestCase):
|
|||||||
self.failIf(RegistrationProfile.objects.activate_user('foo'))
|
self.failIf(RegistrationProfile.objects.activate_user('foo'))
|
||||||
|
|
||||||
# Activating from a key that doesn't exist returns False.
|
# Activating from a key that doesn't exist returns False.
|
||||||
self.failIf(RegistrationProfile.objects.activate_user(hashlib.sha1('foo').hexdigest()))
|
self.failIf(RegistrationProfile.objects.activate_user(sha_constructor('foo').hexdigest()))
|
||||||
|
|
||||||
def test_account_expiration_condition(self):
|
def test_account_expiration_condition(self):
|
||||||
"""
|
"""
|
||||||
@@ -351,5 +351,5 @@ class RegistrationViewTests(RegistrationTestCase):
|
|||||||
|
|
||||||
# Nonexistent key sets the account to False.
|
# Nonexistent key sets the account to False.
|
||||||
response = self.client.get(reverse('registration_activate',
|
response = self.client.get(reverse('registration_activate',
|
||||||
kwargs={ 'activation_key': hashlib.sha1('foo').hexdigest() }))
|
kwargs={ 'activation_key': sha_constructor('foo').hexdigest() }))
|
||||||
self.failIf(response.context['account'])
|
self.failIf(response.context['account'])
|
||||||
|
|||||||
Reference in New Issue
Block a user