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
3de1405d
Commit
3de1405d
authored
Dec 10, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPDATE] clean version for mines.paristech
parent
8229e21b
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
182 additions
and
37 deletions
+182
-37
urls.py
gargantext_web/urls.py
+2
-1
views.py
gargantext_web/views.py
+18
-1
group.py
ngram/group.py
+5
-3
NgramsExtractor.py
parsing/NgramsExtractors/NgramsExtractor.py
+2
-2
TurboNgramsExtractor.py
parsing/NgramsExtractors/TurboNgramsExtractor.py
+2
-2
ngrams.py
rest_v1_0/ngrams.py
+20
-12
NGrams_dyna_chart_and_table.js
static/js/NGrams_dyna_chart_and_table.js
+12
-4
menu.html
templates/corpus/menu.html
+83
-2
terms.html
templates/corpus/terms.html
+3
-7
explorer.html
templates/explorer.html
+1
-1
views.py
tests/ngramstable/views.py
+34
-2
No files found.
gargantext_web/urls.py
View file @
3de1405d
...
@@ -103,7 +103,8 @@ urlpatterns = patterns('',
...
@@ -103,7 +103,8 @@ urlpatterns = patterns('',
url
(
r'^tests/'
,
include
(
'tests.urls'
)),
url
(
r'^tests/'
,
include
(
'tests.urls'
)),
url
(
r'^project/(\d+)/corpus/(\d+)/terms$'
,
samtest
.
get_ngrams
),
url
(
r'^project/(\d+)/corpus/(\d+)/terms$'
,
samtest
.
get_ngrams
),
url
(
r'^api/corpus/(\d+)$'
,
samtest
.
get_corpus_state
),
url
(
r'^api/corpus/(\d+)$'
,
samtest
.
get_corpus_state
),
url
(
r'^test_cores$'
,
samtest
.
get_cores
)
url
(
r'^test_cores$'
,
samtest
.
get_cores
),
url
(
r'^get_groups$'
,
samtest
.
get_groups
)
)
)
...
...
gargantext_web/views.py
View file @
3de1405d
...
@@ -345,7 +345,8 @@ def corpus(request, project_id, corpus_id):
...
@@ -345,7 +345,8 @@ def corpus(request, project_id, corpus_id):
type_doc_id
=
cache
.
NodeType
[
'Document'
]
.
id
type_doc_id
=
cache
.
NodeType
[
'Document'
]
.
id
number
=
session
.
query
(
func
.
count
(
Node
.
id
))
.
filter
(
Node
.
parent_id
==
corpus_id
,
Node
.
type_id
==
type_doc_id
)
.
all
()[
0
][
0
]
number
=
session
.
query
(
func
.
count
(
Node
.
id
))
.
filter
(
Node
.
parent_id
==
corpus_id
,
Node
.
type_id
==
type_doc_id
)
.
all
()[
0
][
0
]
# [ getting workflow status ] #
the_query
=
""" SELECT hyperdata FROM node_node WHERE id=
%
d """
%
(
int
(
corpus_id
)
)
the_query
=
""" SELECT hyperdata FROM node_node WHERE id=
%
d """
%
(
int
(
corpus_id
)
)
cursor
=
connection
.
cursor
()
cursor
=
connection
.
cursor
()
try
:
try
:
...
@@ -353,6 +354,21 @@ def corpus(request, project_id, corpus_id):
...
@@ -353,6 +354,21 @@ def corpus(request, project_id, corpus_id):
processing
=
cursor
.
fetchone
()[
0
][
"Processing"
]
processing
=
cursor
.
fetchone
()[
0
][
"Processing"
]
except
:
except
:
processing
=
"Error"
processing
=
"Error"
# [ / getting workflow status ] #
# [ how many groups ? ] #
nb_groups
=
0
the_query
=
""" SELECT group_id FROM auth_user_groups WHERE user_id=
%
d """
%
(
int
(
request
.
user
.
id
)
)
cursor
=
connection
.
cursor
()
try
:
cursor
.
execute
(
the_query
)
results
=
cursor
.
fetchall
()
nb_groups
=
len
(
results
)
except
:
pass
# [ / how many groups ? ] #
html
=
t
.
render
(
Context
({
html
=
t
.
render
(
Context
({
'debug'
:
settings
.
DEBUG
,
'debug'
:
settings
.
DEBUG
,
...
@@ -363,6 +379,7 @@ def corpus(request, project_id, corpus_id):
...
@@ -363,6 +379,7 @@ def corpus(request, project_id, corpus_id):
'processing'
:
processing
,
'processing'
:
processing
,
# 'documents': documents,\
# 'documents': documents,\
'number'
:
number
,
'number'
:
number
,
'nb_groups'
:
nb_groups
,
'view'
:
"documents"
'view'
:
"documents"
}))
}))
...
...
ngram/group.py
View file @
3de1405d
...
@@ -116,7 +116,10 @@ def compute_groups(corpus, limit_inf=None, limit_sup=None, how='Stem'):
...
@@ -116,7 +116,10 @@ def compute_groups(corpus, limit_inf=None, limit_sup=None, how='Stem'):
for
key
in
mainform_dict
.
keys
():
for
key
in
mainform_dict
.
keys
():
miam_to_insert
.
add
((
miam_node
.
id
,
mainform_dict
[
key
],
1
))
try
:
miam_to_insert
.
add
((
miam_node
.
id
,
mainform_dict
[
key
],
1
))
except
:
pass
try
:
try
:
ids
=
ids_dict
[
key
]
ids
=
ids_dict
[
key
]
...
@@ -125,9 +128,8 @@ def compute_groups(corpus, limit_inf=None, limit_sup=None, how='Stem'):
...
@@ -125,9 +128,8 @@ def compute_groups(corpus, limit_inf=None, limit_sup=None, how='Stem'):
for
ngram_id
in
ids
:
for
ngram_id
in
ids
:
if
ngram_id
!=
mainform_dict
[
key
]:
if
ngram_id
!=
mainform_dict
[
key
]:
group_to_insert
.
add
((
node_group
.
id
,
mainform_dict
[
key
],
ngram_id
,
1
))
group_to_insert
.
add
((
node_group
.
id
,
mainform_dict
[
key
],
ngram_id
,
1
))
except
e
xception
as
e
:
except
E
xception
as
e
:
print
(
e
)
print
(
e
)
print
(
group
[
stem
])
#print(ids_dict[stem])
#print(ids_dict[stem])
...
...
parsing/NgramsExtractors/NgramsExtractor.py
View file @
3de1405d
from
..Taggers
import
Turbo
Tagger
from
..Taggers
import
Nltk
Tagger
import
nltk
import
nltk
...
@@ -21,7 +21,7 @@ class NgramsExtractor:
...
@@ -21,7 +21,7 @@ class NgramsExtractor:
self
.
stop
()
self
.
stop
()
def
start
(
self
):
def
start
(
self
):
self
.
tagger
=
Turbo
Tagger
()
self
.
tagger
=
Nltk
Tagger
()
def
stop
(
self
):
def
stop
(
self
):
pass
pass
...
...
parsing/NgramsExtractors/TurboNgramsExtractor.py
View file @
3de1405d
from
.NgramsExtractor
import
NgramsExtractor
from
.NgramsExtractor
import
NgramsExtractor
from
..Taggers
import
Turbo
Tagger
from
..Taggers
import
Nltk
Tagger
class
TurboNgramsExtractor
(
NgramsExtractor
):
class
TurboNgramsExtractor
(
NgramsExtractor
):
def
start
(
self
):
def
start
(
self
):
self
.
tagger
=
Turbo
Tagger
()
self
.
tagger
=
Nltk
Tagger
()
rest_v1_0/ngrams.py
View file @
3de1405d
...
@@ -108,10 +108,12 @@ class List(APIView):
...
@@ -108,10 +108,12 @@ class List(APIView):
def
get
(
self
,
request
,
corpus_id
,
list_name
):
def
get
(
self
,
request
,
corpus_id
,
list_name
):
if
not
request
.
user
.
is_authenticated
():
return
JsonHttpResponse
(
{
"request"
:
"forbidden"
}
)
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
request
.
user
.
id
,
Node
.
id
==
corpus_id
)
.
first
()
if
corpus
==
None
:
return
JsonHttpResponse
(
{
"request"
:
"forbidden"
}
)
start_
=
time
.
time
()
start_
=
time
.
time
()
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
corpus_id
)
.
first
()
list_name
=
list_name
.
title
()
+
"List"
list_name
=
list_name
.
title
()
+
"List"
node_list
=
get_or_create_node
(
nodetype
=
list_name
,
corpus
=
corpus
)
node_list
=
get_or_create_node
(
nodetype
=
list_name
,
corpus
=
corpus
)
nodes_ngrams
=
session
.
query
(
NodeNgram
.
ngram_id
)
.
filter
(
NodeNgram
.
node_id
==
node_list
.
id
)
.
all
()
nodes_ngrams
=
session
.
query
(
NodeNgram
.
ngram_id
)
.
filter
(
NodeNgram
.
node_id
==
node_list
.
id
)
.
all
()
...
@@ -143,11 +145,13 @@ class Ngrams(APIView):
...
@@ -143,11 +145,13 @@ class Ngrams(APIView):
http://localhost:8000/api/node/1444485/ngrams?format=json&score=tfidf,occs
http://localhost:8000/api/node/1444485/ngrams?format=json&score=tfidf,occs
'''
'''
def
get
(
self
,
request
,
node_id
):
def
get
(
self
,
request
,
node_id
):
# query ngrams
if
not
request
.
user
.
is_authenticated
():
return
JsonHttpResponse
(
{
"request"
:
"forbidden"
}
)
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
request
.
user
.
id
,
Node
.
id
==
node_id
)
.
first
()
if
corpus
==
None
:
return
JsonHttpResponse
(
{
"request"
:
"forbidden"
}
)
start_
=
time
.
time
()
start_
=
time
.
time
()
ParentNode
=
aliased
(
Node
)
ParentNode
=
aliased
(
Node
)
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_id
)
.
first
()
group_by
=
[]
group_by
=
[]
results
=
[
'id'
,
'terms'
]
results
=
[
'id'
,
'terms'
]
...
@@ -319,15 +323,19 @@ class Group(APIView):
...
@@ -319,15 +323,19 @@ class Group(APIView):
REST API to manage groups of Ngrams
REST API to manage groups of Ngrams
Groups can be synonyms, a cathegory or ngrams groups with stems or lems.
Groups can be synonyms, a cathegory or ngrams groups with stems or lems.
'''
'''
def
get_group_id
(
self
,
node_id
):
def
get_group_id
(
self
,
node_id
,
user_id
):
node_id
=
int
(
node_id
)
node_id
=
int
(
node_id
)
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_id
)
.
first
()
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user_id
,
Node
.
id
==
node_id
)
.
first
()
if
corpus
==
None
:
return
None
group
=
get_or_create_node
(
corpus
=
corpus
,
nodetype
=
'Group'
)
group
=
get_or_create_node
(
corpus
=
corpus
,
nodetype
=
'Group'
)
return
(
group
.
id
)
return
(
group
.
id
)
def
get
(
self
,
request
,
corpus_id
):
def
get
(
self
,
request
,
corpus_id
):
# query ngrams
if
not
request
.
user
.
is_authenticated
():
group_id
=
self
.
get_group_id
(
corpus_id
)
return
JsonHttpResponse
(
{
"request"
:
"forbidden"
}
)
group_id
=
self
.
get_group_id
(
corpus_id
,
request
.
user
.
id
)
if
group_id
==
None
:
return
JsonHttpResponse
(
{
"request"
:
"forbidden"
}
)
#api/node/$corpus_id/ngrams?ngram_id=12
#api/node/$corpus_id/ngrams?ngram_id=12
# ngram_id = 1 #request.GET.get('ngram_id', False)
# ngram_id = 1 #request.GET.get('ngram_id', False)
# ngram_id = int(node_id)
# ngram_id = int(node_id)
...
@@ -395,7 +403,7 @@ class Group(APIView):
...
@@ -395,7 +403,7 @@ class Group(APIView):
# input validation
# input validation
input
=
validate
(
request
.
DATA
,
{
'data'
:
{
'source'
:
int
,
'target'
:
list
}})
input
=
validate
(
request
.
DATA
,
{
'data'
:
{
'source'
:
int
,
'target'
:
list
}})
group_id
=
get_group_id
(
corpus_id
)
group_id
=
get_group_id
(
corpus_id
,
request
.
user
.
id
)
for
data
in
input
[
'data'
]:
for
data
in
input
[
'data'
]:
...
@@ -424,7 +432,7 @@ class Group(APIView):
...
@@ -424,7 +432,7 @@ class Group(APIView):
for
subform
in
group_new
[
mainform
]:
for
subform
in
group_new
[
mainform
]:
gdict
.
append
(
subform
)
gdict
.
append
(
subform
)
GDict
.
append
(
gdict
)
GDict
.
append
(
gdict
)
existing_group_id
=
self
.
get_group_id
(
corpus_id
)
existing_group_id
=
self
.
get_group_id
(
corpus_id
,
request
.
user
.
id
)
grouped_ngrams
=
(
session
grouped_ngrams
=
(
session
.
query
(
NodeNgramNgram
)
.
query
(
NodeNgramNgram
)
.
filter
(
NodeNgramNgram
.
node_id
==
existing_group_id
)
.
filter
(
NodeNgramNgram
.
node_id
==
existing_group_id
)
...
...
static/js/NGrams_dyna_chart_and_table.js
View file @
3de1405d
...
@@ -538,13 +538,18 @@ function SelectAll( box ) {
...
@@ -538,13 +538,18 @@ function SelectAll( box ) {
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
}
}
function
SaveGlobalChanges
(
elem
)
{
function
SaveGlobalChanges
(
delete_
)
{
console
.
log
(
"iterating over global stop words:"
)
console
.
log
(
"iterating over global stop words:"
)
$
(
'.globalstopwords'
).
each
(
function
(
i
,
obj
)
{
$
(
'.globalstopwords'
).
each
(
function
()
{
console
.
log
(
obj
)
console
.
log
(
$
(
this
).
data
(
"id"
)
)
});
});
console
.
log
(
" - - - - -"
)
console
.
log
(
" - - - - -"
)
console
.
log
(
elem
)
console
.
log
(
"delete: "
+
delete_
)
if
(
!
delete_
)
{
// SaveLocalChanges()
}
else
{
}
}
}
function
SaveGlobalChanges_Form
(
nodes2del
)
{
function
SaveGlobalChanges_Form
(
nodes2del
)
{
...
@@ -1082,6 +1087,9 @@ var NGrams = {
...
@@ -1082,6 +1087,9 @@ var NGrams = {
}
}
$
(
"#corpusdisplayer"
).
hide
()
$
(
"#corpusdisplayer"
).
hide
()
if
(
$
(
"#share_button"
).
length
==
0
)
{
$
(
"#ImportList"
).
remove
()
}
var
url
=
[
var
url
=
[
...
...
templates/corpus/menu.html
View file @
3de1405d
...
@@ -48,6 +48,9 @@
...
@@ -48,6 +48,9 @@
{% if number == 0 %}
{% if number == 0 %}
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/admin/documents/corpus/{{ corpus.id }}/"
>
Add documents
</a></p>
<a
class=
"btn btn-primary btn-lg"
role=
"button"
href=
"/admin/documents/corpus/{{ corpus.id }}/"
>
Add documents
</a></p>
{% endif %}
{% endif %}
{% if nb_groups != None and nb_groups > 0 %}
<a
style=
"visibility: hidden;"
id=
"share_button"
class=
"btn btn-primary btn-lg"
role=
"button"
>
Share!!!
</a></p>
{% endif %}
</div>
</div>
</div>
</div>
...
@@ -117,6 +120,47 @@
...
@@ -117,6 +120,47 @@
</div>
</div>
</div>
</div>
<div
id=
"sharemodal"
class=
"modal fade"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h3
class=
"modal-title"
>
Share this Corpus with your Groups
</h3>
</div>
<div
class=
"modal-body form-horizontal"
>
<h4>
List of available groups:
</h4>
<div
id=
"groups_list"
>
here show the groups
</div>
<div
class=
"modal-footer"
>
<button
id=
"closesharemodal"
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
Close
</button>
<button
id=
"send_share"
type=
"button"
class=
"btn btn-primary"
>
Share
</button>
</div>
</div>
</div>
</div>
</div>
<style>
label
{
padding
:
10px
;
margin
:
0
0
10px
;
display
:
block
;
}
label
:hover
{
background
:
#eee
;
cursor
:
pointer
;
}
</style>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
function
gotoexplorer
(
elem
)
{
function
gotoexplorer
(
elem
)
{
...
@@ -139,7 +183,6 @@
...
@@ -139,7 +183,6 @@
// url_ += "&start=" + start__.getFullYear() + "&end="+end__.getFullYear();
// url_ += "&start=" + start__.getFullYear() + "&end="+end__.getFullYear();
}
}
return
window
.
open
(
url_
,
'_blank'
);
return
window
.
open
(
url_
,
'_blank'
);
}
}
var
refresh_time
=
10000
//ms
var
refresh_time
=
10000
//ms
...
@@ -162,7 +205,6 @@
...
@@ -162,7 +205,6 @@
});
});
}
}
if
(
$
(
"#process_state"
).
text
()
==
"0"
)
{
if
(
$
(
"#process_state"
).
text
()
==
"0"
)
{
// workflow : finished!
// workflow : finished!
}
else
{
}
else
{
...
@@ -170,6 +212,45 @@
...
@@ -170,6 +212,45 @@
}
}
function
get_groups
()
{
console
.
log
(
"IN get_groups()!"
)
var
url_
=
"/get_groups"
$
.
ajax
({
type
:
"GET"
,
url
:
url_
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
var
_content
=
""
for
(
var
i
in
data
)
{
var
g_id
=
data
[
i
][
0
]
,
g_name
=
data
[
i
][
1
]
_content
+=
'<label><input name="groups" data-id="'
+
g_id
+
'" type="checkbox" /> '
+
g_name
+
'</label>'
}
$
(
"#groups_list"
).
html
(
_content
)
},
error
:
function
(
exception
)
{
console
.
log
(
"exception!:"
+
exception
.
status
)
}
});
}
if
(
$
(
"#share_button"
).
length
>
0
)
{
$
(
"#share_button"
).
click
(
function
()
{
get_groups
()
$
(
"#sharemodal"
).
modal
(
"show"
);
});
$
(
"#send_share"
).
click
(
function
()
{
$
(
'input[name=groups]:checked'
).
each
(
function
()
{
console
.
log
(
$
(
this
).
data
(
"id"
)
);
});
});
}
</script>
</script>
...
...
templates/corpus/terms.html
View file @
3de1405d
...
@@ -113,7 +113,7 @@ input[type=radio] + label {
...
@@ -113,7 +113,7 @@ input[type=radio] + label {
}
}
input
[
type
=
radio
]
:checked
+
label
{
input
[
type
=
radio
]
:checked
+
label
{
background-image
:
none
;
background-image
:
none
;
outline
:
0
;
outline
:
0
;
-webkit-box-shadow
:
inset
0
2px
4px
rgba
(
0
,
0
,
0
,
0.15
),
0
1px
2px
rgba
(
0
,
0
,
0
,
0.05
);
-webkit-box-shadow
:
inset
0
2px
4px
rgba
(
0
,
0
,
0
,
0.15
),
0
1px
2px
rgba
(
0
,
0
,
0
,
0.05
);
-moz-box-shadow
:
inset
0
2px
4px
rgba
(
0
,
0
,
0
,
0.15
),
0
1px
2px
rgba
(
0
,
0
,
0
,
0.05
);
-moz-box-shadow
:
inset
0
2px
4px
rgba
(
0
,
0
,
0
,
0.15
),
0
1px
2px
rgba
(
0
,
0
,
0
,
0.05
);
...
@@ -291,8 +291,8 @@ input[type=radio]:checked + label {
...
@@ -291,8 +291,8 @@ input[type=radio]:checked + label {
-->
-->
<div
class=
"modal-footer"
>
<div
class=
"modal-footer"
>
<button
onclick=
"SaveGlobalChanges(
this.id
)"
id=
"nope"
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
No
</button>
<button
onclick=
"SaveGlobalChanges(
false
)"
id=
"nope"
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
No
</button>
<button
onclick=
"SaveGlobalChanges(t
his.id
)"
id=
"yep"
type=
"button"
class=
"btn btn-primary"
>
Yes
</button>
<button
onclick=
"SaveGlobalChanges(t
rue
)"
id=
"yep"
type=
"button"
class=
"btn btn-primary"
>
Yes
</button>
</div>
</div>
...
@@ -309,10 +309,6 @@ input[type=radio]:checked + label {
...
@@ -309,10 +309,6 @@ input[type=radio]:checked + label {
<div
id=
"filter_search"
style=
"visibility:hidden"
>
<div
id=
"filter_search"
style=
"visibility:hidden"
>
<span
style=
"font-size:70%;"
>
<input
title=
"Search in Titles"
type=
"checkbox"
checked
onclick=
"return false"
>
TI
</input>
<input
title=
"Search in Abstracts"
type=
"checkbox"
>
AB
</input>
</span>
<select
id=
"example-single-optgroups"
onchange=
"SearchFilters(this);"
>
<select
id=
"example-single-optgroups"
onchange=
"SearchFilters(this);"
>
<!-- <optgroup label=""> -->
<!-- <optgroup label=""> -->
<option
id=
"filter_all"
value=
"filter_all"
>
All
</option>
<option
id=
"filter_all"
value=
"filter_all"
>
All
</option>
...
...
templates/explorer.html
View file @
3de1405d
...
@@ -324,7 +324,7 @@
...
@@ -324,7 +324,7 @@
<div
id=
"tab-container-top"
class=
'tab-container'
style=
"display: none;"
>
<div
id=
"tab-container-top"
class=
'tab-container'
style=
"display: none;"
>
<ul
class=
'etabs'
>
<ul
class=
'etabs'
>
<li
id=
"tabmed"
class=
'tab active'
><a
href=
"#tabs3"
>
Medline
Pubs
</a></li>
<li
id=
"tabmed"
class=
'tab active'
><a
href=
"#tabs3"
>
Pubs
</a></li>
<li
id=
"tabgps"
class=
'tab'
><a
href=
"#tabs3"
></a></li>
<li
id=
"tabgps"
class=
'tab'
><a
href=
"#tabs3"
></a></li>
</ul>
</ul>
...
...
tests/ngramstable/views.py
View file @
3de1405d
...
@@ -77,7 +77,6 @@ def get_ngrams(request , project_id , corpus_id ):
...
@@ -77,7 +77,6 @@ def get_ngrams(request , project_id , corpus_id ):
myamlist_type_id
=
cache
.
NodeType
[
'MiamList'
]
.
id
myamlist_type_id
=
cache
.
NodeType
[
'MiamList'
]
.
id
miamlist
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
request
.
user
.
id
,
Node
.
parent_id
==
corpus_id
,
Node
.
type_id
==
myamlist_type_id
)
.
first
()
miamlist
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
request
.
user
.
id
,
Node
.
parent_id
==
corpus_id
,
Node
.
type_id
==
myamlist_type_id
)
.
first
()
t
the_query
=
""" SELECT hyperdata FROM node_node WHERE id=
%
d """
%
(
int
(
corpus_id
)
)
the_query
=
""" SELECT hyperdata FROM node_node WHERE id=
%
d """
%
(
int
(
corpus_id
)
)
cursor
=
connection
.
cursor
()
cursor
=
connection
.
cursor
()
try
:
try
:
...
@@ -86,6 +85,18 @@ def get_ngrams(request , project_id , corpus_id ):
...
@@ -86,6 +85,18 @@ def get_ngrams(request , project_id , corpus_id ):
except
:
except
:
processing
=
"Error"
processing
=
"Error"
# [ how many groups ? ] #
nb_groups
=
0
the_query
=
""" SELECT group_id FROM auth_user_groups WHERE user_id=
%
d """
%
(
int
(
request
.
user
.
id
)
)
cursor
=
connection
.
cursor
()
try
:
cursor
.
execute
(
the_query
)
results
=
cursor
.
fetchall
()
nb_groups
=
len
(
results
)
except
:
pass
# [ / how many groups ? ] #
html
=
t
.
render
(
Context
({
html
=
t
.
render
(
Context
({
'debug'
:
settings
.
DEBUG
,
'debug'
:
settings
.
DEBUG
,
'user'
:
request
.
user
,
'user'
:
request
.
user
,
...
@@ -94,6 +105,7 @@ def get_ngrams(request , project_id , corpus_id ):
...
@@ -94,6 +105,7 @@ def get_ngrams(request , project_id , corpus_id ):
'corpus'
:
corpus
,
'corpus'
:
corpus
,
'processing'
:
processing
,
'processing'
:
processing
,
'number'
:
number
,
'number'
:
number
,
'nb_groups'
:
nb_groups
,
'list_id'
:
miamlist
.
id
,
'list_id'
:
miamlist
.
id
,
}))
}))
...
@@ -186,4 +198,24 @@ def get_corpus_state( request , corpus_id ):
...
@@ -186,4 +198,24 @@ def get_corpus_state( request , corpus_id ):
finally
:
finally
:
connection
.
close
()
connection
.
close
()
# processing = corpus.hyperdata['Processing']
# processing = corpus.hyperdata['Processing']
return
JsonHttpResponse
(
processing
)
return
JsonHttpResponse
(
processing
)
\ No newline at end of file
def
get_groups
(
request
):
if
not
request
.
user
.
is_authenticated
():
return
JsonHttpResponse
(
{
"request"
:
"forbidden"
}
)
results
=
[]
the_query
=
""" SELECT auth_user_groups.group_id, auth_group.name
\
FROM auth_user_groups,auth_group
\
WHERE auth_user_groups.user_id=
%
d
\
AND auth_user_groups.group_id=auth_group.id """
%
(
int
(
request
.
user
.
id
)
)
cursor
=
connection
.
cursor
()
try
:
cursor
.
execute
(
the_query
)
results
=
cursor
.
fetchall
()
except
:
pass
return
JsonHttpResponse
(
results
)
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