From: lombardofr Date: Mon, 15 Oct 2018 12:35:59 +0000 (+0200) Subject: user edit - change password X-Git-Tag: v5.0.0~24 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F94%2F6694%2F1;p=osm%2FLW-UI.git user edit - change password Change-Id: Iab1efe49f69200dd262fff2b07468d2dcc0ebe66 Signed-off-by: lombardofr --- diff --git a/static/src/userhandler/user_list.js b/static/src/userhandler/user_list.js index afa1ae3..b485e5b 100644 --- a/static/src/userhandler/user_list.js +++ b/static/src/userhandler/user_list.js @@ -32,7 +32,7 @@ function openModalEditUser(args) { $("#projects_old").val(user_projects.toString()); $('#projects_edit').val(null).trigger('change'); $('#default_project_edit').val(null).trigger('change'); - + $('#edit_password').val(''); if (user_projects.length > 0) { // Create a DOM Option and pre-select by default var newOption = new Option(user_projects[0], user_projects[0], true, true); diff --git a/userhandler/templates/modal/user_edit.html b/userhandler/templates/modal/user_edit.html index caeeb3a..21dbe8a 100644 --- a/userhandler/templates/modal/user_edit.html +++ b/userhandler/templates/modal/user_edit.html @@ -19,6 +19,13 @@ placeholder="Username" required> {% endcomment %} +
+ +
+ +
+
diff --git a/userhandler/urls.py b/userhandler/urls.py index 2bd735b..6447d69 100644 --- a/userhandler/urls.py +++ b/userhandler/urls.py @@ -20,7 +20,7 @@ from userhandler import views urlpatterns = [ url(r'^list$', views.user_list, name='list'), url(r'^create$', views.create, name='create'), - url(r'^(?P[0-9a-zA-Z]+)', views.update, name='update'), - url(r'^(?P[0-9a-zA-Z]+)/delete$', views.delete, name='delete') + url(r'^(?P[0-9a-zA-Z]+)/delete$', views.delete, name='delete'), + url(r'^(?P[0-9a-zA-Z]+)', views.update, name='update') -] \ No newline at end of file +] diff --git a/userhandler/views.py b/userhandler/views.py index 3aa227a..a7c014d 100644 --- a/userhandler/views.py +++ b/userhandler/views.py @@ -58,20 +58,31 @@ def update(request, user_id=None): projects_to_add = list(set(projects_new) - set(projects_old)) projects_to_remove = list(set(projects_old) - set(projects_new)) - payload = {} + project_payload = {} for p in projects_to_remove: - payload["$"+str(p)] = None + project_payload["$"+str(p)] = None for p in projects_to_add: if p not in projects_old: - payload["$+"+str(p)] = str(p) - payload["$" + default_project] = None - payload["$+[0]"] = default_project + project_payload["$+"+str(p)] = str(p) + project_payload["$" + default_project] = None + project_payload["$+[0]"] = default_project + payload = {} + if project_payload: + payload["projects"] = project_payload + if request.POST.get('password') and request.POST.get('password') is not '': + payload["password"] = request.POST.get('password') - update_res = client.user_update(user.get_token(), user_id, {"projects": payload}) + update_res = client.user_update(user.get_token(), user_id, payload) except Exception as e: log.exception(e) - return __response_handler(request, {}, 'users:list', to_redirect=True, ) + update_res = {'error': True, 'data': str(e)} + if update_res['error']: + return __response_handler(request, update_res['data'], url=None, + status=update_res['data']['status'] if 'status' in update_res['data'] else 500) + else: + return __response_handler(request, {}, url=None, status=200) + #return __response_handler(request, {}, 'users:list', to_redirect=True, ) def __response_handler(request, data_res, url=None, to_redirect=None, *args, **kwargs):