From 688c0b20d06fe32e445ab5e585ac3b523b795edd Mon Sep 17 00:00:00 2001 From: Loic Baron Date: Sat, 1 Mar 2014 17:34:05 +0100 Subject: [PATCH] Institution: delete users and slices - this only works if the user has an authority credential ! --- portal/static/js/institution.js | 63 +++++++++++++++++++++++++++++++ portal/templates/institution.html | 39 ++++--------------- 2 files changed, 71 insertions(+), 31 deletions(-) create mode 100644 portal/static/js/institution.js diff --git a/portal/static/js/institution.js b/portal/static/js/institution.js new file mode 100644 index 00000000..91907811 --- /dev/null +++ b/portal/static/js/institution.js @@ -0,0 +1,63 @@ +$(document).ready(function() { + $('a.home-tab').click(function() { + $('ul.nav-tabs li').removeClass('active'); + $(this).parent().addClass('active'); + $('div.home-panel').hide(); + $('div#'+$(this).data('panel')).show(); + }); + var url = window.location; + if(url.hash) { + // Fragment exists + tab = url.href.split("#")[1]; + tab_exists = $('div#'+tab).length; + if (tab_exists) { + $('ul.nav-tabs li').removeClass('active'); + $('li#'+tab+'-tab').addClass('active'); + $('div.home-panel').hide(); + $('div#'+tab).show(); + } + } + + /* TODO: factorize into functions */ + $('button#deleteusers').click(function() { + $('input:checkbox.user').each(function (index) { + if(this.checked){ + var record_id = this.id; + $.post("/delete/user/",{'filters':{'user_hrn':this.id}}, function(data) { + if(data.success){ + $('tr[id="'+record_id+'"]').fadeOut("slow"); + $('tr[id="'+record_id+'"]').remove(); + }else{ + alert("Rest Error for "+record_id+": "+data.error); + } + }); + + } + }); + }); + $('button#deleteslices').click(function() { + $('input:checkbox.slice').each(function (index) { + if(this.checked){ + var record_id = this.id; + $.post("/delete/slice/",{'filters':{'user_hrn':this.id}}, function(data) { + if(data.success){ + $('tr[id="'+record_id+'"]').fadeOut("slow"); + $('tr[id="'+record_id+'"]').remove(); + }else{ + alert("Rest Error for "+record_id+": "+data.error); + } + }); + + } + }); + }); + + $('button#createslice').click(function() { + window.location="/portal/slice_request/"; + }); + $('button#slicerequestbtn').click(function() { + /* + window.location="/portal/slice_request/"; + */ + }); +}); diff --git a/portal/templates/institution.html b/portal/templates/institution.html index d8fb1d77..1cef3738 100644 --- a/portal/templates/institution.html +++ b/portal/templates/institution.html @@ -1,5 +1,7 @@ {% extends "layout.html" %} - +{% block head %} + +{% endblock head %} {% block content %}

Institution: {{user_details.parent_authority}}

@@ -60,32 +62,6 @@