X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FLW-UI.git;a=blobdiff_plain;f=vimhandler%2Fviews.py;h=d16fb7ed7cf2937e1e4f7bc5e44e9fa81710ef35;hp=c40e4e935dc86b23fd7e38698264a637eff04f95;hb=4908f382154fddb84d72ce8d516229649c01b606;hpb=c89a4a0390fd7250179e7a3730aa53a6ce2ede68 diff --git a/vimhandler/views.py b/vimhandler/views.py index c40e4e9..d16fb7e 100644 --- a/vimhandler/views.py +++ b/vimhandler/views.py @@ -15,7 +15,7 @@ # from django.shortcuts import render, redirect -from django.contrib.auth.decorators import login_required +from sf_t3d.decorators import login_required from django.http import HttpResponse import json from lib.osm.osmclient.clientv2 import Client @@ -31,13 +31,13 @@ log = logging.getLogger('vimhandler.py') def list(request): user = osmutils.get_user(request) project_id = user.project_id + result = {'type': 'ns', 'project_id': project_id} + raw_content_types = request.META.get('HTTP_ACCEPT', '*/*').split(',') + if 'application/json' not in raw_content_types: + return __response_handler(request, result, 'vim_list.html') client = Client() - result = client.vim_list(user.get_token()) - print result - result = { - "project_id": project_id, - "datacenters": result['data'] if result and result['error'] is False else [] - } + result_client = client.vim_list(user.get_token()) + result["datacenters"] = result_client['data'] if result_client and result_client['error'] is False else [] return __response_handler(request, result, 'vim_list.html')