+#
+# Copyright 2018 EveryUP Srl
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
from django.shortcuts import render, redirect
from sf_t3d.decorators import login_required
from django.http import HttpResponse
"password": request.POST['password'],
"projects": request.POST.getlist('projects')
}
-
result = client.user_create(user.get_token(), user_data)
-
- return __response_handler(request, result, 'users:list', to_redirect=True)
+ if result['error']:
+ return __response_handler(request, result['data'], url=None,
+ status=result['data']['status'] if 'status' in result['data'] else 500)
+ else:
+ return __response_handler(request, {}, url=None, status=200)
@login_required
user = osmutils.get_user(request)
try:
client = Client()
- del_res = client.user_delete(user.get_token(), user_id)
+ result = client.user_delete(user.get_token(), user_id)
except Exception as e:
log.exception(e)
- return __response_handler(request, {}, 'users:list', to_redirect=True, )
+ result = {'error': True, 'data': str(e)}
+ if result['error']:
+ return __response_handler(request, result['data'], url=None,
+ status=result['data']['status'] if 'status' in result['data'] else 500)
+ else:
+ return __response_handler(request, {}, url=None, status=200)
@login_required
def update(request, user_id=None):