fix signup

This commit is contained in:
j 2011-11-07 23:28:28 +01:00
parent 37e15bcb70
commit 1ded5a0cd4
2 changed files with 10 additions and 5 deletions

View file

@ -126,9 +126,15 @@ class UserProfile(models.Model):
def user_post_save(sender, instance, **kwargs):
profile, new = UserProfile.objects.get_or_create(user=instance)
SessionData.objects.filter(user=instance).update(level=profile.level,
username=instance.username)
models.signals.post_save.connect(user_post_save, sender=User)
def profile_post_save(sender, instance, **kwargs):
SessionData.objects.filter(user=instance.user).update(level=instance.level,
username=instance.user.username)
models.signals.post_save.connect(profile_post_save, sender=UserProfile)
def get_ui(user_ui, user=None):
ui = {}
config = copy.deepcopy(settings.CONFIG)
@ -201,7 +207,6 @@ def init_user(user, request=None):
result['volumes'] = [v.json() for v in user.volumes.all()]
return result
def user_json(user, keys=None):
p = user.get_profile()
j = {

View file

@ -161,7 +161,7 @@ def signup(request):
user.save()
#create default user lists:
for l in settings.CONFIG['personalLists']:
list = models.List(name=l['name'], user=user)
list = models.List(name=l['id'], user=user)
for key in ('query', 'public', 'featured'):
if key in l:
setattr(list, key, l[key])
@ -170,7 +170,7 @@ def signup(request):
user = authenticate(username=data['username'],
password=data['password'])
login(request, user)
user_json = models.init_user(user)
user_json = models.init_user(user, request)
response = json_response({
'user': user_json
}, text='account created')
@ -219,7 +219,7 @@ def resetPassword(request):
user = authenticate(username=user.username, password=data['password'])
login(request, user)
user_json = models.init_user(user)
user_json = models.init_user(user, request)
response = json_response({
'user': user_json
}, text='password reset')