Commit e9bceac5 authored by PkSM3's avatar PkSM3

[UPDATE] delete view in the road

parent f35498c4
...@@ -214,6 +214,8 @@ class NodesChildrenDuplicates(APIView): ...@@ -214,6 +214,8 @@ class NodesChildrenDuplicates(APIView):
limit = int(request.GET.get('limit', 10)) limit = int(request.GET.get('limit', 10))
total = duplicates.count() total = duplicates.count()
# response building # response building
for duplicate in duplicates[offset : offset+limit]:
print(duplicate)
return JsonHttpResponse({ return JsonHttpResponse({
'pagination': { 'pagination': {
'offset': offset, 'offset': offset,
...@@ -621,6 +623,28 @@ class Nodes(APIView): ...@@ -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: class CorpusController:
......
...@@ -54,7 +54,7 @@ urlpatterns = patterns('', ...@@ -54,7 +54,7 @@ urlpatterns = patterns('',
url(r'^api/nodes/(\d+)/children/duplicates$', gargantext_web.api.NodesChildrenDuplicates.as_view()), url(r'^api/nodes/(\d+)/children/duplicates$', gargantext_web.api.NodesChildrenDuplicates.as_view()),
url(r'^api/nodes/(\d+)$', gargantext_web.api.Nodes.as_view()), url(r'^api/nodes/(\d+)$', gargantext_web.api.Nodes.as_view()),
url(r'^api/nodes$', gargantext_web.api.NodesList.as_view()), url(r'^api/nodes$', gargantext_web.api.NodesList.as_view()),
url(r'^api/project/(\d+)/corpus/(\d+)/timerange/(\d+)/(\d+)$', views.subcorpusJSON), url(r'^api/project/(\d+)/corpus/(\d+)/timerange/(\d+)/(\d+)$', views.subcorpusJSON),
url(r'^api/nodes/(\d+)/ngrams$', gargantext_web.api.CorpusController.ngrams), url(r'^api/nodes/(\d+)/ngrams$', gargantext_web.api.CorpusController.ngrams),
......
...@@ -222,7 +222,28 @@ function updateDocuments(pagenumber,pagenav) { ...@@ -222,7 +222,28 @@ function updateDocuments(pagenumber,pagenav) {
} }
//else: "Read Documents" collapsible is open!, so do nothing //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 gainOrLossChart = dc.pieChart("#gain-loss-chart");
// var fluctuationChart = dc.barChart("#fluctuation-chart"); // var fluctuationChart = dc.barChart("#fluctuation-chart");
......
...@@ -21,9 +21,22 @@ ...@@ -21,9 +21,22 @@
<ul> <ul>
{% for doc in documents %} {% for doc in documents %}
{% if doc.date %} {% 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 %} {% endif %}
{% endfor %} {% endfor %}
</ul> </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 %} {% 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