Commit e9bceac5 authored by PkSM3's avatar PkSM3

[UPDATE] delete view in the road

parent f35498c4
......@@ -214,6 +214,8 @@ class NodesChildrenDuplicates(APIView):
limit = int(request.GET.get('limit', 10))
total = duplicates.count()
# response building
for duplicate in duplicates[offset : offset+limit]:
print(duplicate)
return JsonHttpResponse({
'pagination': {
'offset': offset,
......@@ -621,6 +623,28 @@ class Nodes(APIView):
})
def delete(self, request, node_id):
session = get_session()
# get the minimum ID for each of the nodes sharing the same metadata
node = models.Node.objects.filter(id = node_id).first()
# delete the stuff
delete_query = (session
.query(Node)
.filter(Node.parent_id == node_id)
)
print("in Nodes.delete():")
print("node to delete: "+node_id)
print(delete_query)
print("--")
count = delete_query.count()
# delete_query.delete(synchronize_session=False)
# session.flush()
# # return the result
return JsonHttpResponse({
'deleted': count,
})
# return duplicates_query
class CorpusController:
......
......@@ -222,7 +222,28 @@ function updateDocuments(pagenumber,pagenav) {
}
//else: "Read Documents" collapsible is open!, so do nothing
}
$.ajax({
url: 'http://localhost:8000/api/nodes/44335',
type: 'DELETE',
success: function(result) {
console.log("Do something with the result");
}
});
var current_docs = {}
var BIS_dict = {}
var corpusid = window.location.href.split("corpus")[1].replace(/\//g, '')//replace all the slashes
var theurl = "http://localhost:8000/api/nodes/"+corpusid+"/children/duplicates?keys=title&limit=9999"
$.ajax({
url: theurl,
success: function(data) {
bisarray = data.data
for(var i in bisarray) {
onebis = bisarray[i].values
BIS_dict[onebis[0]] = [bisarray[i].count , 0];// [ total amount , removed ]
}
pr(BIS_dict)
}
});
// var gainOrLossChart = dc.pieChart("#gain-loss-chart");
// var fluctuationChart = dc.barChart("#fluctuation-chart");
......
......@@ -21,9 +21,22 @@
<ul>
{% for doc in documents %}
{% if doc.date %}
<li> <b>{{ doc.date }}</b>: <a target="_blank" href="/nodeinfo/{{doc.id}}">{{ doc.name}}</a> , @ {{ doc.metadata.source}}</li>
<li><div id="doc_{{doc.id}}"> <b>{{ doc.date }}</b>: <a target="_blank" href="/nodeinfo/{{doc.id}}">{{ doc.name}}</a> , @ {{ doc.metadata.source}}</div></li>
{% endif %}
{% endfor %}
</ul>
<script>
current_docs = []
{% for doc in documents %}
id = "doc_{{doc.id}}"
title = "{{doc.name}}"
if(BIS_dict[title]) {
var ahref = 'here goes the delete url'
var delimg = '<a><img width="20px" src="/static/img/delete-big.png"></img></a>'
$("#"+id).prepend( delimg )
}
{% endfor %}
</script>
{% endif %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment