fix signup
This commit is contained in:
parent
37e15bcb70
commit
1ded5a0cd4
2 changed files with 10 additions and 5 deletions
|
@ -126,9 +126,15 @@ class UserProfile(models.Model):
|
||||||
|
|
||||||
def user_post_save(sender, instance, **kwargs):
|
def user_post_save(sender, instance, **kwargs):
|
||||||
profile, new = UserProfile.objects.get_or_create(user=instance)
|
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)
|
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):
|
def get_ui(user_ui, user=None):
|
||||||
ui = {}
|
ui = {}
|
||||||
config = copy.deepcopy(settings.CONFIG)
|
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()]
|
result['volumes'] = [v.json() for v in user.volumes.all()]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def user_json(user, keys=None):
|
def user_json(user, keys=None):
|
||||||
p = user.get_profile()
|
p = user.get_profile()
|
||||||
j = {
|
j = {
|
||||||
|
|
|
@ -161,7 +161,7 @@ def signup(request):
|
||||||
user.save()
|
user.save()
|
||||||
#create default user lists:
|
#create default user lists:
|
||||||
for l in settings.CONFIG['personalLists']:
|
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'):
|
for key in ('query', 'public', 'featured'):
|
||||||
if key in l:
|
if key in l:
|
||||||
setattr(list, key, l[key])
|
setattr(list, key, l[key])
|
||||||
|
@ -170,7 +170,7 @@ def signup(request):
|
||||||
user = authenticate(username=data['username'],
|
user = authenticate(username=data['username'],
|
||||||
password=data['password'])
|
password=data['password'])
|
||||||
login(request, user)
|
login(request, user)
|
||||||
user_json = models.init_user(user)
|
user_json = models.init_user(user, request)
|
||||||
response = json_response({
|
response = json_response({
|
||||||
'user': user_json
|
'user': user_json
|
||||||
}, text='account created')
|
}, text='account created')
|
||||||
|
@ -219,7 +219,7 @@ def resetPassword(request):
|
||||||
user = authenticate(username=user.username, password=data['password'])
|
user = authenticate(username=user.username, password=data['password'])
|
||||||
login(request, user)
|
login(request, user)
|
||||||
|
|
||||||
user_json = models.init_user(user)
|
user_json = models.init_user(user, request)
|
||||||
response = json_response({
|
response = json_response({
|
||||||
'user': user_json
|
'user': user_json
|
||||||
}, text='password reset')
|
}, text='password reset')
|
||||||
|
|
Loading…
Reference in a new issue