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
52e1c24a
Commit
52e1c24a
authored
Jan 21, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'samuel' into unstable
parents
467bf2ff
aa7b57d4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
14 deletions
+51
-14
api.py
gargantext_web/api.py
+16
-12
urls.py
gargantext_web/urls.py
+1
-0
admin.py
node/admin.py
+2
-2
corpus.html
templates/corpus.html
+1
-0
subcorpus.html
templates/subcorpus.html
+31
-0
No files found.
gargantext_web/api.py
View file @
52e1c24a
...
...
@@ -234,20 +234,23 @@ class NodesChildrenDuplicates(APIView):
# get the minimum ID for each of the nodes sharing the same metadata
kept_node_ids_query
=
self
.
_fetch_duplicates
(
request
,
node_id
,
[
func
.
min
(
Node
.
id
)
.
label
(
'id'
)],
0
)
kept_node_ids
=
[
kept_node
.
id
for
kept_node
in
kept_node_ids_query
]
# delete the stuff
delete_query
=
(
session
.
query
(
Node
)
.
filter
(
Node
.
parent_id
==
node_id
)
.
filter
(
~
Node
.
id
.
in_
(
kept_node_ids
))
)
count
=
delete_query
.
count
()
delete_query
.
delete
(
synchronize_session
=
False
)
session
.
flush
()
# return the result
duplicate_nodes
=
models
.
Node
.
objects
.
filter
(
parent_id
=
node_id
)
.
exclude
(
id__in
=
kept_node_ids
)
# # delete the stuff
# delete_query = (session
# .query(Node)
# .filter(Node.parent_id == node_id)
# .filter(~Node.id.in_(kept_node_ids))
# )
count
=
len
(
duplicate_nodes
)
for
node
in
duplicate_nodes
:
print
(
"deleting node "
,
node
.
id
)
node
.
delete
()
# print(delete_query)
# # delete_query.delete(synchronize_session=True)
# session.flush()
return
JsonHttpResponse
({
'deleted'
:
count
,
'deleted'
:
count
})
# return duplicates_query
...
...
@@ -621,6 +624,7 @@ class Nodes(APIView):
})
# deleting node by id
# currently, very dangerous
def
delete
(
self
,
request
,
node_id
):
session
=
get_session
()
node
=
models
.
Node
.
objects
.
filter
(
id
=
node_id
)
...
...
gargantext_web/urls.py
View file @
52e1c24a
...
...
@@ -53,6 +53,7 @@ urlpatterns = patterns('',
url
(
r'^api/nodes/(\d+)/children/metadata$'
,
gargantext_web
.
api
.
NodesChildrenMetatadata
.
as_view
()),
url
(
r'^api/nodes/(\d+)/children/queries$'
,
gargantext_web
.
api
.
NodesChildrenQueries
.
as_view
()),
url
(
r'^api/nodes/(\d+)/children/duplicates$'
,
gargantext_web
.
api
.
NodesChildrenDuplicates
.
as_view
()),
# url(r'^api/nodes/(\d+)/children/duplicates/delete$', gargantext_web.api.NodesChildrenDuplicates.delete ),
url
(
r'^api/nodes/(\d+)$'
,
gargantext_web
.
api
.
Nodes
.
as_view
()),
url
(
r'^api/nodes$'
,
gargantext_web
.
api
.
NodesList
.
as_view
()),
...
...
node/admin.py
View file @
52e1c24a
...
...
@@ -124,10 +124,10 @@ class CustomForm(forms.Form):
if
len
(
file_
.
name
)
>
30
:
from
datetime
import
datetime
file_
.
name
=
str
(
datetime
.
now
()
.
microsecond
)
raise
forms
.
ValidationError
(
_
(
'Come on dude, name too long. Now is:'
+
file_
.
name
))
#
raise forms.ValidationError(_('Come on dude, name too long. Now is:'+file_.name))
#File size
if
len
(
file_
)
>
104857600
:
raise
forms
.
ValidationError
(
_
(
'File to heavy! (<100MB
svp mec
).'
))
raise
forms
.
ValidationError
(
_
(
'File to heavy! (<100MB).'
))
## File type:
# if file_.content_type == "application/zip":
# raise forms.ValidationError(_('We need a zip pls.'))
...
...
templates/corpus.html
View file @
52e1c24a
...
...
@@ -239,6 +239,7 @@ $.ajax({
BIS_dict
[
untitlebis
[
0
]]
=
[
bisarray
[
i
].
count
,
0
];
// [ total amount , removed ]
}
pr
(
BIS_dict
)
if
(
Object
.
keys
(
BIS_dict
).
length
>
0
)
$
(
"#delAll"
).
css
(
"visibility"
,
"visible"
);
$
(
"#delAll"
).
show
();
}
});
...
...
templates/subcorpus.html
View file @
52e1c24a
...
...
@@ -19,6 +19,12 @@
{% if documents %}
<div
id=
"delAll"
style=
"visibility: hidden;"
>
<button
onclick=
"deleteDuplicates(theurl);"
>
Delete Duplicates
</button>
</div>
<ul>
{% for doc in documents %}
{% if doc.date %}
...
...
@@ -45,6 +51,26 @@ function getCookie(name) {
return
cookieValue
;
}
function
deleteDuplicates
(
url
)
{
console
.
log
(
"hello world"
)
console
.
log
(
url
)
$
.
ajax
({
url
:
url
,
type
:
'DELETE'
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
data
)
{
console
.
log
(
"in DeleteDuplicates"
)
console
.
log
(
data
)
$
(
"#delAll"
).
remove
();
},
error
:
function
(
result
)
{
console
.
log
(
"Data not found"
);
console
.
log
(
result
)
}
});
}
function
deleteNode
(
node_id
)
{
$
.
ajax
({
...
...
@@ -111,6 +137,11 @@ function deleteNode(node_id) {
//'
+
"{{doc.id}}"
+
',
\
"'
+
title
+
'
\
"
current_docs = {}
if(Object.keys(BIS_dict).length>0) {
$("#delAll").css("visibility", "visible");
$("#delAll").show();
} else $("#delAll").remove()
{% for doc in documents %}
id = "doc_{{doc.id}}"
title = $("<div/>").html("{{doc.name}}").text()
...
...
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