From d927d66e64f8910c4460a37e675d216e65da2c61 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Thu, 22 May 2014 09:29:06 -0700 Subject: [PATCH] refuse to add/remove slivers for readonly user --- planetstack/core/plus/views.py | 5 +++- .../admin/dashboard/cdnoperations.html | 23 ++++++------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/planetstack/core/plus/views.py b/planetstack/core/plus/views.py index 4dcca79..2b7bf38 100644 --- a/planetstack/core/plus/views.py +++ b/planetstack/core/plus/views.py @@ -699,6 +699,9 @@ class DashboardAddOrRemoveSliverView(View): siteList = [Site.objects.get(name=siteName)] slice = Slice.objects.get(name="HyperCache") + if request.user.isReadOnlyUser(): + return HttpResponseForbidden("User is in read-only mode") + if (actionToDo == "add"): user_ip = request.GET.get("ip", get_ip(request)) slice_increase_slivers(request.user, user_ip, siteList, slice, 1) @@ -707,7 +710,7 @@ class DashboardAddOrRemoveSliverView(View): print '*' * 50 print 'Ask for site: ' + siteName + ' to ' + actionToDo + ' another HPC Sliver' - return HttpResponse('This is POST request ') + return HttpResponse(json.dumps("Success"), mimetype='application/javascript') class DashboardAjaxView(View): def get(self, request, **kwargs): diff --git a/planetstack/templates/admin/dashboard/cdnoperations.html b/planetstack/templates/admin/dashboard/cdnoperations.html index 31ff746..167b558 100644 --- a/planetstack/templates/admin/dashboard/cdnoperations.html +++ b/planetstack/templates/admin/dashboard/cdnoperations.html @@ -96,16 +96,12 @@ $('#map-us').on('click', '#remHPCSliver', function() { csrfmiddlewaretoken: "{{ csrf_token }}", // < here state:"inactive" }, type : 'POST', - //success: function(response) - //{ - // alert("Successfully posted request to REMOVE sliver"); - //}, - complete:function(){ + success:function(){ confirmDialog("Info","Removed an HPC Sliver from Site "); }, - //error:function (xhr, textStatus, thrownError){ - // alert("Could not request to remove HPC Sliver"); - //} + error:function (xhr, textStatus, thrownError){ + errorDialog("Error", textStatus + " " + xhr.responseText); + } }); }); @@ -120,18 +116,13 @@ $('#map-us').on('click', '#addHPCSliver', function() { state:"inactive" }, type : 'POST', success: function(response) - { - //alert("Successfully posted request to add sliver"); - }, - complete:function() { confirmDialog("Info","Added an HPC Sliver to Site "); }, - //error:function (xhr, textStatus, thrownError){ - // alert("error doing something"); - //} + error:function (xhr, textStatus, thrownError){ + errorDialog("Error", textStatus + " " + xhr.responseText); + } }); - // confirmDialog("Add HPC Slivers","Add some HPC Slivers to site " + $(this).data('site')); }); function getIcon(numNodes, numHPCSlivers, currentBW, hot) { -- 2.43.0