Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
69e5fb9d
Commit
69e5fb9d
authored
Jan 13, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPDATE] successfyllu deleting duplicated doc and reload page(for the moment)
parent
e9bceac5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
28 deletions
+57
-28
api.py
gargantext_web/api.py
+10
-19
corpus.html
templates/corpus.html
+3
-7
subcorpus.html
templates/subcorpus.html
+44
-2
No files found.
gargantext_web/api.py
View file @
69e5fb9d
...
...
@@ -622,29 +622,20 @@ class Nodes(APIView):
'metadata'
:
dict
(
node
.
metadata
),
})
# deleting node by id
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
node
=
models
.
Node
.
objects
.
filter
(
id
=
node_id
)
msgres
=
""
try
:
node
.
delete
()
msgres
=
node_id
+
" deleted!"
except
:
msgres
=
"error deleting: "
+
node_id
return
JsonHttpResponse
({
'deleted'
:
count
,
'deleted'
:
msgres
,
})
# return duplicates_query
class
CorpusController
:
...
...
templates/corpus.html
View file @
69e5fb9d
...
...
@@ -222,13 +222,9 @@ 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
...
...
templates/subcorpus.html
View file @
69e5fb9d
...
...
@@ -27,13 +27,55 @@
</ul>
<script>
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!=
''
)
{
var
cookies
=
document
.
cookie
.
split
(
';'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
var
cookie
=
jQuery
.
trim
(
cookies
[
i
]);
// Does this cookie string begin with the name we want?
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
==
(
name
+
'='
))
{
cookieValue
=
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
));
break
;
}
}
}
return
cookieValue
;
}
$
.
ajaxSetup
({
beforeSend
:
function
(
xhr
,
settings
)
{
if
(
!
(
/^http:.*/
.
test
(
settings
.
url
)
||
/^https:.*/
.
test
(
settings
.
url
)))
{
// Only send the token to relative URLs i.e. locally.
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
'csrftoken'
));
}
}
});
function
deleteNode
(
node_id
)
{
$
.
ajax
({
url
:
'/api/nodes/'
+
node_id
,
type
:
'DELETE'
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
result
)
{
console
.
log
(
result
)
location
.
reload
();
},
error
:
function
(
result
)
{
console
.
log
(
"Data not found"
);
console
.
log
(
result
)
}
});
}
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>'
var
delimg
=
'<a title="Delete this document!" style="cursor: pointer;" onclick="deleteNode('
+
"{{doc.id}}"
+
')"><img width="20px" src="/static/img/delete-big.png"></img></a>'
$
(
"#"
+
id
).
prepend
(
delimg
)
}
{
%
endfor
%
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment