From f6cebcaec9c439efb598519b95ab80c14b2f5c22 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 8 Mar 2016 20:10:00 +0530 Subject: [PATCH] fix user/group api --- pandora/user/views.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pandora/user/views.py b/pandora/user/views.py index c07a4a5f..2e89ced1 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -385,7 +385,7 @@ def editUser(request, data): user.save() profile.save() add_changelog(request, data, user.username) - response['data'] = user.data.get().json() + response['data'] = user.data.json() return render_to_json_response(response) actions.register(editUser, cache=False) @@ -548,7 +548,7 @@ def getUser(request, data): ''' response = json_response() u = get_user_or_404(data) - response['data'] = u.data.get().json(data.get('keys', []), request.user) + response['data'] = u.data.json(data.get('keys', []), request.user) return render_to_json_response(response) actions.register(getUser) @@ -931,7 +931,14 @@ def editGroup(request, data): ''' response = json_response(status=200, text='ok') g = Group.objects.get(id=ox.fromAZ(data['id'])) - g.name = data['name'] + name = data['name'] + n = 1 + name = data['name'] + _name = re.sub(' \[\d+\]$', '', name).strip() + while Group.objects.filter(name=name).count(): + n += 1 + name = u'%s [%d]' % (_name, n) + g.name = name g.save() add_changelog(request, data, g.name) response['data'] = group_json(g)