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
329a9f82
Commit
329a9f82
authored
Jan 28, 2016
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BUGFIX] explorer sharing
parent
47f6061a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
262 additions
and
98 deletions
+262
-98
corpus_views.py
gargantext_web/corpus_views.py
+3
-3
views.py
gargantext_web/views.py
+30
-9
views_optimized.py
gargantext_web/views_optimized.py
+1
-1
ngrams.py
rest_v1_0/ngrams.py
+14
-6
views.py
scrappers/scrap_pubmed/views.py
+2
-2
NGrams_dyna_chart_and_table.js
static/js/NGrams_dyna_chart_and_table.js
+207
-72
authentication.html
templates/authentication.html
+3
-3
views.py
tests/ngramstable/views.py
+2
-2
No files found.
gargantext_web/corpus_views.py
View file @
329a9f82
...
@@ -58,7 +58,7 @@ from ngram.lists import listIds, listNgramIds, ngramList , doList
...
@@ -58,7 +58,7 @@ from ngram.lists import listIds, listNgramIds, ngramList , doList
def
test_page
(
request
,
project_id
,
corpus_id
):
def
test_page
(
request
,
project_id
,
corpus_id
):
if
not
request
.
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/
login
/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/
auth
/?next=
%
s'
%
request
.
path
)
try
:
try
:
offset
=
int
(
project_id
)
offset
=
int
(
project_id
)
...
@@ -96,7 +96,7 @@ def test_page(request , project_id , corpus_id):
...
@@ -96,7 +96,7 @@ def test_page(request , project_id , corpus_id):
def
get_ngrams
(
request
,
project_id
,
corpus_id
):
def
get_ngrams
(
request
,
project_id
,
corpus_id
):
if
not
request
.
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/
login
/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/
auth
/?next=
%
s'
%
request
.
path
)
try
:
try
:
offset
=
int
(
project_id
)
offset
=
int
(
project_id
)
...
@@ -170,7 +170,7 @@ def test_test(request , corpus_id , doc_id):
...
@@ -170,7 +170,7 @@ def test_test(request , corpus_id , doc_id):
def
get_journals
(
request
,
project_id
,
corpus_id
):
def
get_journals
(
request
,
project_id
,
corpus_id
):
if
not
request
.
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/
login
/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/
auth
/?next=
%
s'
%
request
.
path
)
try
:
try
:
offset
=
int
(
project_id
)
offset
=
int
(
project_id
)
...
...
gargantext_web/views.py
View file @
329a9f82
...
@@ -51,9 +51,25 @@ from gargantext_web.db import session, cache, NodeNgram, NodeNgramNgram
...
@@ -51,9 +51,25 @@ from gargantext_web.db import session, cache, NodeNgram, NodeNgramNgram
def
login_user
(
request
):
def
login_user
(
request
):
logout
(
request
)
logout
(
request
)
username
=
password
=
''
username
=
password
=
''
print
(
request
)
if
request
.
POST
:
next_page
=
""
if
request
.
method
==
"GET"
:
additional_context
=
{}
# if for exemple: auth/?next=/project/5/corpus/554/document/556/
# => we'll forward ?next="..." into template with form
if
(
'next'
in
request
.
GET
):
additional_context
=
{
'next_page'
:
request
.
GET
[
'next'
]}
return
render_to_response
(
'authentication.html'
,
additional_context
,
context_instance
=
RequestContext
(
request
)
)
elif
request
.
method
==
"POST"
:
username
=
request
.
POST
[
'username'
]
username
=
request
.
POST
[
'username'
]
# /!\ pass is sent clear in POST data
password
=
request
.
POST
[
'password'
]
password
=
request
.
POST
[
'password'
]
user
=
authenticate
(
username
=
username
,
password
=
password
)
user
=
authenticate
(
username
=
username
,
password
=
password
)
...
@@ -61,8 +77,13 @@ def login_user(request):
...
@@ -61,8 +77,13 @@ def login_user(request):
if
user
.
is_active
:
if
user
.
is_active
:
login
(
request
,
user
)
login
(
request
,
user
)
return
HttpResponseRedirect
(
'/projects/'
)
return
render_to_response
(
'authentication.html'
,
context_instance
=
RequestContext
(
request
))
# if "next" forwarded from the GET via the template form
if
(
'the_next_page'
in
request
.
POST
):
return
HttpResponseRedirect
(
request
.
POST
[
'the_next_page'
])
else
:
return
HttpResponseRedirect
(
'/projects/'
)
def
logout_user
(
request
):
def
logout_user
(
request
):
logout
(
request
)
logout
(
request
)
...
@@ -297,7 +318,7 @@ def update_nodes(request, project_id, corpus_id, view=None):
...
@@ -297,7 +318,7 @@ def update_nodes(request, project_id, corpus_id, view=None):
'''
'''
if
not
request
.
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/
login
/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/
auth
/?next=
%
s'
%
request
.
path
)
try
:
try
:
offset
=
int
(
project_id
)
offset
=
int
(
project_id
)
...
@@ -360,7 +381,7 @@ def update_nodes(request, project_id, corpus_id, view=None):
...
@@ -360,7 +381,7 @@ def update_nodes(request, project_id, corpus_id, view=None):
def
corpus
(
request
,
project_id
,
corpus_id
):
def
corpus
(
request
,
project_id
,
corpus_id
):
if
not
request
.
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/
login
/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/
auth
/?next=
%
s'
%
request
.
path
)
try
:
try
:
offset
=
int
(
project_id
)
offset
=
int
(
project_id
)
...
@@ -488,7 +509,7 @@ def move_to_trash_multiple(request):
...
@@ -488,7 +509,7 @@ def move_to_trash_multiple(request):
user
=
request
.
user
user
=
request
.
user
if
not
user
.
is_authenticated
():
if
not
user
.
is_authenticated
():
return
redirect
(
'/
login
/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/
auth
/?next=
%
s'
%
request
.
path
)
results
=
[
"operation"
,
"failed"
]
results
=
[
"operation"
,
"failed"
]
...
@@ -516,7 +537,7 @@ def delete_node(request, node_id):
...
@@ -516,7 +537,7 @@ def delete_node(request, node_id):
node
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_id
)
.
first
()
node
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_id
)
.
first
()
if
not
user
.
is_authenticated
():
if
not
user
.
is_authenticated
():
return
redirect
(
'/
login
/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/
auth
/?next=
%
s'
%
request
.
path
)
if
node
.
user_id
!=
user
.
id
:
if
node
.
user_id
!=
user
.
id
:
return
HttpResponseForbidden
()
return
HttpResponseForbidden
()
...
@@ -618,7 +639,7 @@ def graph(request, project_id, corpus_id, generic=100, specific=100):
...
@@ -618,7 +639,7 @@ def graph(request, project_id, corpus_id, generic=100, specific=100):
corpus_type_id
=
cache
.
NodeType
[
'Corpus'
]
.
id
corpus_type_id
=
cache
.
NodeType
[
'Corpus'
]
.
id
miamlist_type_id
=
cache
.
NodeType
[
'MiamList'
]
.
id
miamlist_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
==
cache
.
NodeType
[
'MiamList'
]
.
id
)
.
first
()
miamlist
=
session
.
query
(
Node
)
.
filter
(
Node
.
parent_id
==
corpus_id
,
Node
.
type_id
==
cache
.
NodeType
[
'MiamList'
]
.
id
)
.
first
()
graphurl
=
"corpus/"
+
str
(
corpus_id
)
+
"/node_link.json"
graphurl
=
"corpus/"
+
str
(
corpus_id
)
+
"/node_link.json"
...
...
gargantext_web/views_optimized.py
View file @
329a9f82
...
@@ -52,7 +52,7 @@ def project(request, project_id):
...
@@ -52,7 +52,7 @@ def project(request, project_id):
# do we have a valid user?
# do we have a valid user?
user
=
request
.
user
user
=
request
.
user
if
not
user
.
is_authenticated
():
if
not
user
.
is_authenticated
():
return
redirect
(
'/
login
/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/
auth
/?next=
%
s'
%
request
.
path
)
if
project
.
user_id
!=
user
.
id
:
if
project
.
user_id
!=
user
.
id
:
in_group
=
""" SELECT user_parent FROM node_user_user WHERE user_id=
%
d"""
%
(
int
(
user
.
id
)
)
in_group
=
""" SELECT user_parent FROM node_user_user WHERE user_id=
%
d"""
%
(
int
(
user
.
id
)
)
cursor
=
connection
.
cursor
()
cursor
=
connection
.
cursor
()
...
...
rest_v1_0/ngrams.py
View file @
329a9f82
...
@@ -399,12 +399,20 @@ class Group(APIView):
...
@@ -399,12 +399,20 @@ class Group(APIView):
max_deg
=
-
1
max_deg
=
-
1
mainNode
=
-
1
mainNode
=
-
1
mainNode_sinonims
=
[]
mainNode_sinonims
=
[]
for
node
in
clique
:
groups
[
"nodes"
][
node
]
=
False
if
len
(
clique
)
>
1
:
node_outdeg
=
DG
.
out_degree
(
node
)
for
node
in
clique
:
if
node_outdeg
>
max_deg
:
# just a lookup hash with *both*
max_deg
=
node_outdeg
# the mainNode and the subnodes
mainNode
=
node
groups
[
"nodes"
][
node
]
=
False
# choosing mainNode
node_outdeg
=
DG
.
out_degree
(
node
)
if
node_outdeg
>
max_deg
:
max_deg
=
node_outdeg
mainNode
=
node
# the links themselves main => [subs]
for
node
in
clique
:
for
node
in
clique
:
if
mainNode
!=
node
:
if
mainNode
!=
node
:
mainNode_sinonims
.
append
(
node
)
mainNode_sinonims
.
append
(
node
)
...
...
scrappers/scrap_pubmed/views.py
View file @
329a9f82
...
@@ -104,7 +104,7 @@ def doTheQuery(request , project_id):
...
@@ -104,7 +104,7 @@ def doTheQuery(request , project_id):
# do we have a valid user?
# do we have a valid user?
user
=
request
.
user
user
=
request
.
user
if
not
user
.
is_authenticated
():
if
not
user
.
is_authenticated
():
return
redirect
(
'/
login
/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/
auth
/?next=
%
s'
%
request
.
path
)
if
project
.
user_id
!=
user
.
id
:
if
project
.
user_id
!=
user
.
id
:
return
HttpResponseForbidden
()
return
HttpResponseForbidden
()
...
@@ -208,7 +208,7 @@ def testISTEX(request , project_id):
...
@@ -208,7 +208,7 @@ def testISTEX(request , project_id):
# do we have a valid user?
# do we have a valid user?
user
=
request
.
user
user
=
request
.
user
if
not
user
.
is_authenticated
():
if
not
user
.
is_authenticated
():
return
redirect
(
'/
login
/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/
auth
/?next=
%
s'
%
request
.
path
)
if
project
.
user_id
!=
user
.
id
:
if
project
.
user_id
!=
user
.
id
:
return
HttpResponseForbidden
()
return
HttpResponseForbidden
()
...
...
static/js/NGrams_dyna_chart_and_table.js
View file @
329a9f82
...
@@ -494,18 +494,18 @@ function add2group ( elem ) {
...
@@ -494,18 +494,18 @@ function add2group ( elem ) {
function
clickngram_action
(
elem
)
{
function
clickngram_action
(
elem
)
{
// local id
// local id
var
elem_id
=
$
(
elem
).
data
(
"stuff"
)
;
var
elem_id
=
$
(
elem
).
data
(
"stuff"
)
;
console
.
log
(
"click: state before: "
+
AjaxRecords
[
elem_id
].
state
)
;
//
console.log("click: state before: "+ AjaxRecords[elem_id].state) ;
// cycle the statuses (omitting status 3 = group)
// cycle the statuses (omitting status 3 = group)
AjaxRecords
[
elem_id
].
state
=
(
AjaxRecords
[
elem_id
].
state
==
(
System
[
0
][
"states"
].
length
-
2
))?
0
:(
AjaxRecords
[
elem_id
].
state
+
1
);
AjaxRecords
[
elem_id
].
state
=
(
AjaxRecords
[
elem_id
].
state
==
(
System
[
0
][
"states"
].
length
-
2
))?
0
:(
AjaxRecords
[
elem_id
].
state
+
1
);
// State <=> term color <=> checked colums
// State <=> term color <=> checked colums
console
.
log
(
"
\n\n
RECORD visible on click --- "
+
JSON
.
stringify
(
AjaxRecords
[
elem_id
]))
;
//
console.log("\n\nRECORD visible on click --- " + JSON.stringify(AjaxRecords[elem_id])) ;
var
ngramId
=
AjaxRecords
[
elem_id
].
id
;
var
ngramId
=
AjaxRecords
[
elem_id
].
id
;
console
.
log
(
"click: state after: "
+
AjaxRecords
[
elem_id
].
state
)
;
//
console.log("click: state after: "+ AjaxRecords[elem_id].state) ;
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
}
}
...
@@ -546,13 +546,13 @@ function transformContent(rec_id) {
...
@@ -546,13 +546,13 @@ function transformContent(rec_id) {
}
}
}
}
// uncomment if column tableId
// uncomment if column tableId
(here and in Main_test)
// result['rec_id'] = rec_id ;
// result['rec_id'] = rec_id ;
// uncomment if column ngramId
// uncomment if column ngramId
(here and in Main_test)
// result["ngramId"] = ngram_info["id"] ;
// result["ngramId"] = ngram_info["id"] ;
// uncomment if column state
// uncomment if column state
(here and in Main_test)
// result["state"] = AjaxRecords[rec_id].state
// result["state"] = AjaxRecords[rec_id].state
// -------------------------------------------
// -------------------------------------------
...
@@ -666,54 +666,146 @@ function ulWriter(rowIndex, record, columns, cellWriter) {
...
@@ -666,54 +666,146 @@ function ulWriter(rowIndex, record, columns, cellWriter) {
}
}
/**
/**
* SelectAll: toggle all checkboxes in a
row by changing state
in System
* SelectAll: toggle all checkboxes in a
column by changing their list
in System
*
*
* (new version without the old Delete|Keep radio choice)
* @boxType : 'keep' or 'delete' (resp. maplist and stoplist)
* @boxType : 'keep' or 'delete' (resp. maplist and stoplist)
* @elem : entire element row with attribute 'data-stuff' (= rec_id)
* @elem : entire element row with attribute 'data-stuff' (= rec_id)
*
* 2016-01-12: new version without the old Delete|Keep radio choice
* 2016-01-26: new version with 3-state boxes:
* - indeterminate (SOME del SOME map SOME normal) = original state
* - check (ALL del or map)
* - uncheck (NONE --- " ---)
* => we get 3 visual expected result
* + 3 "vertical" possibilities for each checkall
* that combine with the "horizontal" states
* of each commanded ngrams (map, stop, miam)
*/
*/
function
SelectAll
(
boxType
,
boxElem
)
{
function
SelectAll
(
boxType
,
boxElem
)
{
// debug
// debug
// console.log("\nFUN SelectAll()")
// console.log("\nFUN SelectAll()")
// we will need status of the other "check all box"
// real checkAll flags : SOME|ALL|NONE
var
previousColumnSelection
=
$
(
boxElem
).
data
(
"columnSelection"
)
;
var
newColumnSelection
=
""
;
// we will also need the other "checkall box"
// - to uncheck "delete" when we check "map" & vice-versa
// - to make them both "indeterminate" when we restore buffered original state
// - to prevent buffering if the second column is already buffered
if
(
boxType
==
'keep'
)
{
otherBoxId
=
"delAll"
;
}
if
(
boxType
==
'keep'
)
{
otherBoxId
=
"delAll"
;
}
else
{
otherBoxId
=
"mapAll"
;
}
else
{
otherBoxId
=
"mapAll"
;
}
// did we already buffer original states ?
var
columnBufferExists
=
null
;
// console.log("-------------INCOMING----------------")
// console.log(boxElem.id)
// console.log("check:" + $(boxElem).prop("checked"))
// console.log("indet:" + $(boxElem).prop('indeterminate'))
// console.log("data:" + previousColumnSelection)
otherWasChecked
=
$
(
"input#"
+
otherBoxId
).
prop
(
'checked'
)
;
if
(
otherWasChecked
)
{
// toggle column ALL => NONE => SOME => again
// we visually uncheck the other box if necessary
switch
(
previousColumnSelection
)
{
$
(
'#'
+
otherBoxId
).
attr
(
'checked'
,
false
);
case
'ALL'
:
newColumnSelection
=
"NONE"
;
columnBufferExists
=
true
;
break
;
case
'NONE'
:
newColumnSelection
=
"SOME"
;
columnBufferExists
=
true
;
break
;
case
'SOME'
:
newColumnSelection
=
"ALL"
;
// probably no buffer, except if other column was set
columnBufferExists
=
(
$
(
"input#"
+
otherBoxId
).
data
(
'columnSelection'
)
!=
'SOME'
)
;
break
;
default
:
alert
(
'invalid flag for columnSelection'
);
}
}
// we'll find the target state for each row in this column
// 0 = normal = miam
// 1 = keep = map
// 2 = delete = stop
var
stateId
=
null
;
switch
(
newColumnSelection
)
{
// nothing in the column
case
'NONE'
:
// visual consequences
$
(
boxElem
).
prop
(
'checked'
,
false
);
$
(
boxElem
).
prop
(
'indeterminate'
,
false
);
$
(
'#'
+
otherBoxId
).
prop
(
'indeterminate'
,
false
);
$
(
'#'
+
otherBoxId
).
data
(
'columnSelection'
,
'NONE'
);
// target stateId: 0 for 'normal'
stateId
=
0
;
break
;
// the 'indeterminate' case
case
'SOME'
:
// visual consequences
$
(
boxElem
).
prop
(
'checked'
,
false
);
$
(
boxElem
).
prop
(
'indeterminate'
,
true
);
$
(
'#'
+
otherBoxId
).
prop
(
'indeterminate'
,
true
);
$
(
'#'
+
otherBoxId
).
data
(
'columnSelection'
,
'SOME'
);
// target stateId: undef <=> restore original ngram states
stateId
=
null
;
break
;
// all in the column
case
'ALL'
:
// visual consequences
$
(
boxElem
).
prop
(
'checked'
,
true
);
$
(
boxElem
).
prop
(
'indeterminate'
,
false
);
$
(
'#'
+
otherBoxId
).
prop
(
'indeterminate'
,
false
);
$
(
'#'
+
otherBoxId
).
data
(
'columnSelection'
,
'NONE'
);
// target stateId: 1 if boxType == 'keep'
// 2 if boxType == 'delete'
stateId
=
System
[
0
][
"statesD"
][
boxType
]
;
break
;
default
:
alert
(
'invalid result for columnSelection'
);
}
// and anyway the other box can't stay checked
$
(
'#'
+
otherBoxId
).
prop
(
'checked'
,
false
);
// console.log("data became:" + newColumnSelection)
$
(
"tbody tr"
).
each
(
function
(
i
,
row
)
{
$
(
"tbody tr"
).
each
(
function
(
i
,
row
)
{
var
rec_id
=
$
(
row
).
data
(
'stuff'
)
;
//
for old state system
var
rec_id
=
$
(
row
).
data
(
'stuff'
)
;
// ids
for old state system
var
ngramId
=
AjaxRecords
[
rec_id
].
id
;
// for future state system (cols)
//var ngramId = AjaxRecords[rec_id].id; // for future by ngramId
if
(
boxElem
.
checked
)
{
// a buffer to restore previous states if unchecked
// stateId: 1 if boxType == 'keep'
if
(
!
columnBufferExists
)
{
// 2 if boxType == 'delete'
AjaxRecords
[
rec_id
][
"state_buff"
]
=
AjaxRecords
[
rec_id
][
"state"
]
;
var
stateId
=
System
[
0
][
"statesD"
][
boxType
]
;
// a buffer to restore previous states if unchecked
// (except if there was a click on the other 'all' box
// b/c then buffer is already filled and we shouldn't redo it)
if
(
!
otherWasChecked
)
{
AjaxRecords
[
rec_id
][
"state_buff"
]
=
AjaxRecords
[
rec_id
][
"state"
]
;
}
// do the requested change
AjaxRecords
[
rec_id
][
"state"
]
=
stateId
;
}
// restore previous states
else
{
AjaxRecords
[
rec_id
][
"state"
]
=
AjaxRecords
[
rec_id
][
"state_buff"
]
;
AjaxRecords
[
rec_id
][
"state_buff"
]
=
null
;
}
}
if
(
stateId
!=
null
)
{
// check all with the requested change
AjaxRecords
[
rec_id
][
"state"
]
=
stateId
;
}
else
{
// restore previous states, remove buffer
AjaxRecords
[
rec_id
][
"state"
]
=
AjaxRecords
[
rec_id
][
"state_buff"
]
;
AjaxRecords
[
rec_id
][
"state_buff"
]
=
null
;
}
});
});
// OK update this table page
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
// and update our own "column situation" storage
$
(
boxElem
).
data
(
'columnSelection'
,
newColumnSelection
);
}
}
...
@@ -750,7 +842,9 @@ function SaveLocalChanges() {
...
@@ -750,7 +842,9 @@ function SaveLocalChanges() {
}
}
}
}
// [ = = = = For deleting subforms = = = = ]
// [ = = = = For deleting subforms = = = = ]
for
(
var
i
in
NGrams
[
"group"
].
links
)
{
for
(
var
i
in
NGrams
[
"group"
].
links
)
{
// i is ngram_id of a group mainNode
if
(
FlagsBuffer
[
"delete"
][
i
])
{
if
(
FlagsBuffer
[
"delete"
][
i
])
{
for
(
var
j
in
NGrams
[
"group"
].
links
[
i
]
)
{
for
(
var
j
in
NGrams
[
"group"
].
links
[
i
]
)
{
FlagsBuffer
[
"delete"
][
NGrams
[
"group"
].
links
[
i
][
j
]]
=
true
FlagsBuffer
[
"delete"
][
NGrams
[
"group"
].
links
[
i
][
j
]]
=
true
...
@@ -778,20 +872,20 @@ function SaveLocalChanges() {
...
@@ -778,20 +872,20 @@ function SaveLocalChanges() {
var
nodes_2inmap
=
$
.
extend
({},
FlagsBuffer
[
"inmap"
])
var
nodes_2inmap
=
$
.
extend
({},
FlagsBuffer
[
"inmap"
])
var
nodes_2outmap
=
$
.
extend
({},
FlagsBuffer
[
"outmap"
])
var
nodes_2outmap
=
$
.
extend
({},
FlagsBuffer
[
"outmap"
])
console
.
log
(
""
)
//
console.log("")
console
.
log
(
""
)
//
console.log("")
console
.
log
(
" nodes_2del: "
)
//
console.log(" nodes_2del: ")
console
.
log
(
nodes_2del
)
//
console.log(nodes_2del)
console
.
log
(
" nodes_2keep: "
)
//
console.log(" nodes_2keep: ")
console
.
log
(
nodes_2keep
)
//
console.log(nodes_2keep)
console
.
log
(
" nodes_2group: "
)
//
console.log(" nodes_2group: ")
console
.
log
(
nodes_2group
)
//
console.log(nodes_2group)
console
.
log
(
" nodes_2inmap: "
)
//
console.log(" nodes_2inmap: ")
console
.
log
(
nodes_2inmap
)
//
console.log(nodes_2inmap)
console
.
log
(
" nodes_2outmap: "
)
//
console.log(" nodes_2outmap: ")
console
.
log
(
nodes_2outmap
)
//
console.log(nodes_2outmap)
console
.
log
(
""
)
//
console.log("")
console
.
log
(
""
)
//
console.log("")
var
list_id
=
$
(
"#list_id"
).
val
()
var
list_id
=
$
(
"#list_id"
).
val
()
var
corpus_id
=
getIDFromURL
(
"corpus"
)
// not used
var
corpus_id
=
getIDFromURL
(
"corpus"
)
// not used
...
@@ -925,13 +1019,13 @@ function Main_test( data , initial , search_filter) {
...
@@ -925,13 +1019,13 @@ function Main_test( data , initial , search_filter) {
// Any <th> defined here will end up in the 'columns' arg of ulWriter
// Any <th> defined here will end up in the 'columns' arg of ulWriter
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// uncomment for column tableId
// uncomment for column tableId
(here and in transformContent)
// div_table += "\t"+"\t"+'<th data-dynatable-column="rec_id" style="background-color:grey">local id</th>'+"\n";
// div_table += "\t"+"\t"+'<th data-dynatable-column="rec_id" style="background-color:grey">local id</th>'+"\n";
// uncomment for column ngramId
// uncomment for column ngramId
(here and in transformContent - l553)
// div_table += "\t"+"\t"+'<th data-dynatable-column="ngramId" style="background-color:grey">ngramId</th>'+"\n";
// div_table += "\t"+"\t"+'<th data-dynatable-column="ngramId" style="background-color:grey">ngramId</th>'+"\n";
// uncomment for column stateId
// uncomment for column stateId
(here and in transformContent)
// div_table += "\t"+"\t"+'<th data-dynatable-column="state" style="background-color:grey">State</th>'+"\n" ;
// div_table += "\t"+"\t"+'<th data-dynatable-column="state" style="background-color:grey">State</th>'+"\n" ;
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="name">Terms</th>'
+
"
\n
"
;
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="name">Terms</th>'
+
"
\n
"
;
...
@@ -970,7 +1064,16 @@ function Main_test( data , initial , search_filter) {
...
@@ -970,7 +1064,16 @@ function Main_test( data , initial , search_filter) {
div_table
+=
'</table>'
+
"
\n
"
;
div_table
+=
'</table>'
+
"
\n
"
;
div_table
+=
'</p>'
;
div_table
+=
'</p>'
;
$
(
"#div-table"
).
html
(
div_table
)
$
(
"#div-table"
).
html
(
div_table
)
// indeterminate: only visual
$
(
'#delAll'
).
prop
(
"indeterminate"
,
true
)
$
(
'#mapAll'
).
prop
(
"indeterminate"
,
true
)
// real checkAll states : SOME|ALL|NONE
$
(
'#delAll'
).
data
(
"columnSelection"
,
'SOME'
)
$
(
'#mapAll'
).
data
(
"columnSelection"
,
'SOME'
)
var
div_stats
=
"<p>"
;
var
div_stats
=
"<p>"
;
for
(
var
i
in
data
.
scores
)
{
for
(
var
i
in
data
.
scores
)
{
var
value
=
(
!
isNaN
(
Number
(
data
.
scores
[
i
])))?
Number
(
data
.
scores
[
i
]).
toFixed
(
1
)
:
data
.
scores
[
i
];
var
value
=
(
!
isNaN
(
Number
(
data
.
scores
[
i
])))?
Number
(
data
.
scores
[
i
]).
toFixed
(
1
)
:
data
.
scores
[
i
];
...
@@ -1099,7 +1202,7 @@ function Main_test( data , initial , search_filter) {
...
@@ -1099,7 +1202,7 @@ function Main_test( data , initial , search_filter) {
.
renderlet
(
function
(
chart
)
{
.
renderlet
(
function
(
chart
)
{
chart
.
select
(
"g.y"
).
style
(
"display"
,
"none"
);
chart
.
select
(
"g.y"
).
style
(
"display"
,
"none"
);
LineChart
.
filter
(
chart
.
filter
());
LineChart
.
filter
(
chart
.
filter
());
console
.
log
(
"lalaal moveChart.focus(chartfilt);"
)
//
console.log("lalaal moveChart.focus(chartfilt);")
})
})
.
on
(
"filtered"
,
function
(
chart
)
{
.
on
(
"filtered"
,
function
(
chart
)
{
dc
.
events
.
trigger
(
function
()
{
dc
.
events
.
trigger
(
function
()
{
...
@@ -1292,7 +1395,8 @@ var url = [
...
@@ -1292,7 +1395,8 @@ var url = [
// The AJAX's in cascade:
// The AJAX's in cascade:
GET_
(
url
[
0
]
,
function
(
result
)
{
GET_
(
url
[
0
]
,
function
(
result
)
{
// = = = = MIAM = = = = //
// = = = = MIAM = = = = //
if
(
result
!=
false
)
{
if
(
result
!=
false
)
{
NGrams
[
"main"
]
=
{
NGrams
[
"main"
]
=
{
"ngrams"
:
[],
"ngrams"
:
[],
...
@@ -1344,32 +1448,60 @@ GET_( url[0] , function(result) {
...
@@ -1344,32 +1448,60 @@ GET_( url[0] , function(result) {
function
AfterAjax
()
{
function
AfterAjax
()
{
// debug
// -------------------------------------------------------------------
// console.log("\nFUN AfterAjax()")
// dbg: Ngrams structure is too large
// // Deleting subforms from the ngrams-table, clean start baby!
// 1- Ngrams list would be shorter in binary format than JSON
// 2- If sorted, top Ngrams could be loaded partly for 1st page show
// 3- We could keep less ngrams altogether at indexation upstream
// console.log(JSON.stringify(NGrams))
// -------------------------------------------------------------------
// Deleting subforms from the ngrams-table, clean start baby!
if
(
Object
.
keys
(
NGrams
[
"group"
].
links
).
length
>
0
)
{
if
(
Object
.
keys
(
NGrams
[
"group"
].
links
).
length
>
0
)
{
var
_forms
=
{
"main"
:{}
,
"sub"
:{}
}
var
_forms
=
{
"main"
:{}
,
"sub"
:{}
}
// subforms inventory
for
(
var
i
in
NGrams
[
"group"
].
links
)
{
for
(
var
i
in
NGrams
[
"group"
].
links
)
{
_forms
[
"main"
][
i
]
=
true
_forms
[
"main"
][
i
]
=
true
for
(
var
j
in
NGrams
[
"group"
].
links
[
i
])
{
for
(
var
j
in
NGrams
[
"group"
].
links
[
i
])
{
// for each subform {subform_ngramid : true}
_forms
[
"sub"
][
NGrams
[
"group"
].
links
[
i
][
j
]
]
=
true
_forms
[
"sub"
][
NGrams
[
"group"
].
links
[
i
][
j
]
]
=
true
}
}
}
}
// console.log('_forms["sub"]')
// console.log( _forms["sub"] )
// ngrams_data_ will update NGrams.main (with subforms removed)
var
ngrams_data_
=
[]
var
ngrams_data_
=
[]
for
(
var
i
in
NGrams
[
"main"
].
ngrams
)
{
for
(
var
i
in
NGrams
[
"main"
].
ngrams
)
{
if
(
_forms
[
"sub"
][
NGrams
[
"main"
].
ngrams
[
i
].
id
])
{
NGrams
[
"group"
][
"nodes"
][
NGrams
[
"main"
].
ngrams
[
i
].
id
]
=
NGrams
[
"main"
].
ngrams
[
i
]
var
ngram_id
=
NGrams
[
"main"
].
ngrams
[
i
].
id
;
}
else
{
// if( _forms["main"][ NGrams["main"].ngrams[i].id ] )
// if ngram is subform of another
// NGrams["main"].ngrams[i].name = "*"+NGrams["main"].ngrams[i].name
if
(
_forms
[
"sub"
][
ngram_id
])
{
ngrams_data_
.
push
(
NGrams
[
"main"
].
ngrams
[
i
]
)
// subform info storage into NGrams.group.nodes
}
// ---------------------------------------------
}
// (subform goes away from new list but info preserved)
NGrams
[
"main"
].
ngrams
=
ngrams_data_
;
// (useful if we want to see/revive subforms in future)
NGrams
[
"group"
][
"nodes"
][
ngram_id
]
=
NGrams
[
"main"
].
ngrams
[
i
]
}
// normal case
else
{
// we keep the info untouched in the new list
ngrams_data_
.
push
(
NGrams
[
"main"
].
ngrams
[
i
]
)
}
}
// the new list of ngrams replaces the old main
NGrams
[
"main"
].
ngrams
=
ngrams_data_
;
}
}
// console.log('NGrams["group"]["nodes"]')
// console.log( NGrams["group"]["nodes"] )
// initialize state of maplist items
// initialize state of maplist items
if
(
Object
.
keys
(
NGrams
[
"map"
]).
length
>
0
)
{
if
(
Object
.
keys
(
NGrams
[
"map"
]).
length
>
0
)
{
for
(
var
i
in
NGrams
[
"main"
].
ngrams
)
{
for
(
var
i
in
NGrams
[
"main"
].
ngrams
)
{
...
@@ -1382,6 +1514,9 @@ function AfterAjax() {
...
@@ -1382,6 +1514,9 @@ function AfterAjax() {
}
}
}
}
// console.log('NGrams["main"]')
// console.log( NGrams["main"] )
// Building the Score-Selector //NGrams["scores"]
// Building the Score-Selector //NGrams["scores"]
var
FirstScore
=
NGrams
[
"main"
].
scores
.
initial
var
FirstScore
=
NGrams
[
"main"
].
scores
.
initial
var
possible_scores
=
Object
.
keys
(
NGrams
[
"main"
].
ngrams
[
0
].
scores
);
var
possible_scores
=
Object
.
keys
(
NGrams
[
"main"
].
ngrams
[
0
].
scores
);
...
@@ -1392,10 +1527,10 @@ function AfterAjax() {
...
@@ -1392,10 +1527,10 @@ function AfterAjax() {
scores_div
+=
"
\
t"
+
'<option value="'
+
possible_scores
[
i
]
+
'">'
+
possible_scores
[
i
]
+
'</option>'
+
"
\n
"
scores_div
+=
"
\
t"
+
'<option value="'
+
possible_scores
[
i
]
+
'">'
+
possible_scores
[
i
]
+
'</option>'
+
"
\n
"
}
}
}
}
// Initializing the Charts and Table
// Initializing the Charts and Table
console
.
log
(
NGrams
[
"main"
]
)
var
result
=
Main_test
(
NGrams
[
"main"
]
,
FirstScore
,
"filter_all"
)
var
result
=
Main_test
(
NGrams
[
"main"
]
,
FirstScore
,
"filter_all"
)
console
.
log
(
result
)
console
.
log
(
result
)
// OK
// Listener for onchange Score-Selector
// Listener for onchange Score-Selector
scores_div
+=
"<select>"
+
"
\n
"
;
scores_div
+=
"<select>"
+
"
\n
"
;
...
...
templates/authentication.html
View file @
329a9f82
...
@@ -62,8 +62,8 @@
...
@@ -62,8 +62,8 @@
<div
id=
"login"
>
<div
id=
"login"
>
<form
class=
"form-horizontal"
name=
"LoginForm"
action=
"/auth/"
method=
"post"
>
<form
class=
"form-horizontal"
name=
"LoginForm"
action=
"/auth/"
method=
"post"
>
{% csrf_token %}
{% csrf_token %}
{% if next %}
{% if next
_page
%}
<input
type=
"hidden"
name=
"
next"
value=
"{{ next
}}"
/>
<input
type=
"hidden"
name=
"
the_next_page"
value=
"{{ next_page
}}"
/>
{% endif %}
{% endif %}
<div
class=
"grp-row"
>
<div
class=
"grp-row"
>
<label
class=
"control-label"
for=
"username"
>
Username
</label>
<label
class=
"control-label"
for=
"username"
>
Username
</label>
...
@@ -102,4 +102,4 @@
...
@@ -102,4 +102,4 @@
})(
grp
.
jQuery
);
})(
grp
.
jQuery
);
</script>
</script>
</body>
</body>
</html>
</html>
\ No newline at end of file
tests/ngramstable/views.py
View file @
329a9f82
...
@@ -50,7 +50,7 @@ from rest_v1_0.api import JsonHttpResponse
...
@@ -50,7 +50,7 @@ from rest_v1_0.api import JsonHttpResponse
def
get_ngrams
(
request
,
project_id
,
corpus_id
):
def
get_ngrams
(
request
,
project_id
,
corpus_id
):
if
not
request
.
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/
login
/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/
auth
/?next=
%
s'
%
request
.
path
)
try
:
try
:
offset
=
int
(
project_id
)
offset
=
int
(
project_id
)
...
@@ -108,7 +108,7 @@ def get_ngrams(request , project_id , corpus_id ):
...
@@ -108,7 +108,7 @@ def get_ngrams(request , project_id , corpus_id ):
def
get_journals
(
request
,
project_id
,
corpus_id
):
def
get_journals
(
request
,
project_id
,
corpus_id
):
if
not
request
.
user
.
is_authenticated
():
if
not
request
.
user
.
is_authenticated
():
return
redirect
(
'/
login
/?next=
%
s'
%
request
.
path
)
return
redirect
(
'/
auth
/?next=
%
s'
%
request
.
path
)
try
:
try
:
offset
=
int
(
project_id
)
offset
=
int
(
project_id
)
...
...
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