refuse to add/remove slivers for readonly user
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 @@
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 @@
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 @@
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);
+ }
});
});
@@ -121,17 +117,12 @@
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) {