diff --git a/pandora/user/models.py b/pandora/user/models.py index b5fcd88d..f89764b0 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -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 = { diff --git a/pandora/user/views.py b/pandora/user/views.py index a560c90a..57330918 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -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')