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
5964c948
Commit
5964c948
authored
Oct 01, 2015
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REST] urls factorisation.
parent
407d6778
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
73 additions
and
75 deletions
+73
-75
views.py
annotations/views.py
+1
-1
corpus_views.py
gargantext_web/corpus_views.py
+1
-1
settings.py
gargantext_web/settings.py
+1
-0
urls.py
gargantext_web/urls.py
+25
-55
views.py
gargantext_web/views.py
+1
-1
views_optimized.py
gargantext_web/views_optimized.py
+1
-1
__init__.py
rest_v1_0/__init__.py
+0
-0
__init__.py
rest_v1_0/analyses/__init__.py
+0
-0
api.py
rest_v1_0/api.py
+2
-14
__init__.py
rest_v1_0/crawls/__init__.py
+0
-0
__init__.py
rest_v1_0/lists/__init__.py
+0
-0
ngrams.py
rest_v1_0/ngrams.py
+2
-0
__init__.py
rest_v1_0/nodes/__init__.py
+0
-0
urls.py
rest_v1_0/urls.py
+37
-0
views.py
scrappers/scrap_pubmed/views.py
+1
-1
views.py
tests/ngramstable/views.py
+1
-1
No files found.
annotations/views.py
View file @
5964c948
...
...
@@ -16,7 +16,7 @@ from rest_framework.authentication import SessionAuthentication, BasicAuthentica
from
node.models
import
Node
from
gargantext_web.db
import
*
from
ngram.lists
import
listIds
,
listNgramIds
from
rest.api
import
JsonHttpResponse
from
rest
_v1_0
.api
import
JsonHttpResponse
@
login_required
...
...
gargantext_web/corpus_views.py
View file @
5964c948
...
...
@@ -49,7 +49,7 @@ from sqlalchemy import desc, asc, or_, and_, Date, cast, select
from
gargantext_web
import
about
from
rest.api
import
JsonHttpResponse
from
rest
_v1_0
.api
import
JsonHttpResponse
from
ngram.lists
import
listIds
,
listNgramIds
,
ngramList
,
doList
...
...
gargantext_web/settings.py
View file @
5964c948
...
...
@@ -97,6 +97,7 @@ INSTALLED_APPS = (
'scrappers.scrap_pubmed'
,
'djcelery'
,
'aldjemy'
,
'rest_v1_0'
,
'rest_framework'
,
)
...
...
gargantext_web/urls.py
View file @
5964c948
...
...
@@ -4,17 +4,14 @@ from django.contrib import admin
from
django.contrib.auth.views
import
login
from
gargantext_web
import
views
,
views_optimized
import
gargantext_web.corpus_views
as
corpus_views
from
annotations
import
urls
as
annotations_urls
from
annotations.views
import
main
as
annotations_main_view
import
rest.ngrams
import
rest.api
import
scrappers.scrap_pubmed.views
as
pubmedscrapper
import
tests.ngramstable.views
as
samtest
import
gargantext_web.corpus_views
as
corpus_views
admin
.
autodiscover
()
...
...
@@ -34,6 +31,27 @@ urlpatterns = patterns('',
url
(
r'^img/logo.svg$'
,
views
.
logo
),
url
(
r'^css/bootstrap.css$'
,
views
.
css
),
# REST
url
(
r'^api/'
,
include
(
'rest_v1_0.urls'
)),
url
(
r'^v1.0/'
,
include
(
'rest_v1_0.urls'
)),
# TODO below to put in the rest
url
(
r'^project/(\d+)/corpus/(\d+)/corpus.csv$'
,
views
.
corpus_csv
),
url
(
r'^project/(\d+)/corpus/(tests_mvc_listdocuments+)/corpus.tests_mvc_listdocuments$'
,
views
.
corpus_csv
),
url
(
r'^delete/(\d+)$'
,
views
.
delete_node
),
# => api.node('id' = id, children = 'True', copies = False)
# Visualizations
url
(
r'^project/(\d+)/corpus/(\d+)/chart$'
,
views
.
chart
),
url
(
r'^project/(\d+)/corpus/(\d+)/explorer$'
,
views
.
graph
),
url
(
r'^project/(\d+)/corpus/(\d+)/matrix$'
,
views
.
matrix
),
url
(
r'^chart/corpus/(\d+)/data.csv$'
,
views
.
send_csv
),
# => api.node.children('type' : 'data', 'format' : 'csv')
url
(
r'^corpus/(\d+)/node_link.json$'
,
views
.
node_link
),
# => api.analysis('type': 'node_link', 'format' : 'json')
url
(
r'^corpus/(\d+)/adjacency.json$'
,
views
.
adjacency
),
# => api.analysis('type': 'adjacency', 'format' : 'json')
url
(
r'^ngrams$'
,
views
.
ngrams
),
# to be removed
url
(
r'^nodeinfo/(\d+)$'
,
views
.
nodeinfo
),
# to be removed ?
# TODO above put in the rest
############################################################################
# User Home view
url
(
r'^$'
,
views
.
home_view
),
...
...
@@ -44,7 +62,6 @@ urlpatterns = patterns('',
# Project Management
url
(
r'^projects/$'
,
views
.
projects
),
url
(
r'^project/(\d+)/$'
,
views_optimized
.
project
),
url
(
r'^delete/(\d+)$'
,
views
.
delete_node
),
# => api.node('id' = id, children = 'True', copies = False)
############################################################################
# Corpus management
...
...
@@ -56,66 +73,19 @@ urlpatterns = patterns('',
url
(
r'^project/(\d+)/corpus/(\d+)/journals/journals.json$'
,
samtest
.
get_journals_json
),
url
(
r'^project/(\d+)/corpus/(\d+)/journals$'
,
samtest
.
get_journals
),
# # # Terms view
# url(r'^project/(\d+)/corpus/(\d+)/terms/ngrams.json$', corpus_views.test_ngrams),
# url(r'^project/(\d+)/corpus/(\d+)/terms/?$', corpus_views.get_ngrams),
# Update corpus
# TODO rest to update corpus and information for progress bar
url
(
r'^project/(\d+)/corpus/(\d+)/(\w+)/update$'
,
views
.
update_nodes
),
############################################################################
# annotations App
url
(
r'^project/(\d+)/corpus/(\d+)/document/(\d+)/$'
,
annotations_main_view
),
url
(
r'^annotations/'
,
include
(
annotations_urls
)),
#
url
(
r'^project/(\d+)/corpus/(\d+)/corpus.csv$'
,
views
.
corpus_csv
),
url
(
r'^project/(\d+)/corpus/(tests_mvc_listdocuments+)/corpus.tests_mvc_listdocuments$'
,
views
.
corpus_csv
),
############################################################################
# Visualizations
url
(
r'^project/(\d+)/corpus/(\d+)/chart$'
,
views
.
chart
),
url
(
r'^project/(\d+)/corpus/(\d+)/explorer$'
,
views
.
graph
),
url
(
r'^project/(\d+)/corpus/(\d+)/matrix$'
,
views
.
matrix
),
############################################################################
# Data management
url
(
r'^chart/corpus/(\d+)/data.csv$'
,
views
.
send_csv
),
# => api.node.children('type' : 'data', 'format' : 'csv')
url
(
r'^corpus/(\d+)/node_link.json$'
,
views
.
node_link
),
# => api.analysis('type': 'node_link', 'format' : 'json')
url
(
r'^corpus/(\d+)/adjacency.json$'
,
views
.
adjacency
),
# => api.analysis('type': 'adjacency', 'format' : 'json')
url
(
r'^api/tfidf/(\d+)/(\w+)$'
,
views_optimized
.
tfidf
),
############################################################################
# Data management
#url(r'^api$', rest.api.Root), # = ?
url
(
r'^api/nodes$'
,
rest
.
api
.
NodesList
.
as_view
()),
url
(
r'^v1.0/nodes$'
,
rest
.
api
.
NodesList
.
as_view
()),
url
(
r'^api/nodes/(\d+)$'
,
rest
.
api
.
Nodes
.
as_view
()),
url
(
r'^v1.0/nodes/(\d+)$'
,
rest
.
api
.
Nodes
.
as_view
()),
url
(
r'^api/nodes/(\d+)/children/ngrams$'
,
rest
.
api
.
NodesChildrenNgrams
.
as_view
()),
# => repeated children ?
url
(
r'^v1.0/nodes/(\d+)/children/ngrams$'
,
rest
.
api
.
NodesChildrenNgrams
.
as_view
()),
# => repeated children ?
url
(
r'^api/node/(\d+)/ngrams$'
,
rest
.
ngrams
.
Ngrams
.
as_view
()),
url
(
r'^v1.0/node/(\d+)/ngrams$'
,
rest
.
ngrams
.
Ngrams
.
as_view
()),
url
(
r'^api/nodes/(\d+)/children/hyperdata$'
,
rest
.
api
.
NodesChildrenMetatadata
.
as_view
()),
url
(
r'^v1.0/nodes/(\d+)/children/hyperdata$'
,
rest
.
api
.
NodesChildrenMetatadata
.
as_view
()),
url
(
r'^api/nodes/(\d+)/children/queries$'
,
rest
.
api
.
NodesChildrenQueries
.
as_view
()),
url
(
r'^v1.0/nodes/(\d+)/children/queries$'
,
rest
.
api
.
NodesChildrenQueries
.
as_view
()),
url
(
r'^api/nodes/(\d+)/children/duplicates$'
,
rest
.
api
.
NodesChildrenDuplicates
.
as_view
()),
url
(
r'^v1.0/nodes/(\d+)/children/duplicates$'
,
rest
.
api
.
NodesChildrenDuplicates
.
as_view
()),
# url(r'^api/nodes/(\d+)/children/duplicates/delete$', rest.api.NodesChildrenDuplicates.delete ),
url
(
r'^api/nodes/(\d+)/ngrams$'
,
rest
.
api
.
CorpusController
.
ngrams
),
url
(
r'^v1.0/nodes/(\d+)/ngrams$'
,
rest
.
api
.
CorpusController
.
ngrams
),
# Provisory tests
url
(
r'^ngrams$'
,
views
.
ngrams
),
# to be removed
url
(
r'^nodeinfo/(\d+)$'
,
views
.
nodeinfo
),
# to be removed ?
# TODO put in test folder Provisory tests
url
(
r'^tests/mvc$'
,
views
.
tests_mvc
),
url
(
r'^tests/mvc-listdocuments$'
,
views
.
tests_mvc_listdocuments
),
...
...
gargantext_web/views.py
View file @
5964c948
...
...
@@ -684,7 +684,7 @@ def send_csv(request, corpus_id):
return
response
# To get the data
from
rest.api
import
JsonHttpResponse
from
rest
_v1_0
.api
import
JsonHttpResponse
from
analysis.functions
import
get_cooc
def
node_link
(
request
,
corpus_id
):
'''
...
...
gargantext_web/views_optimized.py
View file @
5964c948
...
...
@@ -16,7 +16,7 @@ from threading import Thread
from
node.admin
import
CustomForm
from
gargantext_web.db
import
*
from
gargantext_web.settings
import
DEBUG
,
MEDIA_ROOT
from
rest.api
import
JsonHttpResponse
from
rest
_v1_0
.api
import
JsonHttpResponse
import
json
import
re
...
...
rest/__init__.py
→
rest
_v1_0
/__init__.py
View file @
5964c948
File moved
rest/analyses/__init__.py
→
rest
_v1_0
/analyses/__init__.py
View file @
5964c948
File moved
rest/api.py
→
rest
_v1_0
/api.py
View file @
5964c948
...
...
@@ -11,7 +11,8 @@ import datetime
import
copy
from
gargantext_web.views
import
move_to_trash
from
gargantext_web.db
import
session
,
Node
,
NodeNgram
,
NodeNgramNgram
,
NodeNodeNgram
,
Ngram
,
Hyperdata
,
Node_Ngram
from
gargantext_web.db
import
session
,
Node
,
NodeNgram
,
NodeNgramNgram
,
NodeNodeNgram
,
Ngram
,
Hyperdata
,
Node_Ngram
\
,
NodeType
from
gargantext_web.validation
import
validate
,
ValidationException
from
node
import
models
...
...
@@ -143,7 +144,6 @@ class NodesChildrenNgrams(APIView):
from
gargantext_web.db
import
get_or_create_node
class
Ngrams
(
APIView
):
def
get
(
self
,
request
,
node_id
):
# query ngrams
ParentNode
=
aliased
(
Node
)
...
...
@@ -262,10 +262,7 @@ class Ngrams(APIView):
],
})
class
NodesChildrenDuplicates
(
APIView
):
def
_fetch_duplicates
(
self
,
request
,
node_id
,
extra_columns
=
None
,
min_count
=
1
):
# input validation
if
extra_columns
is
None
:
...
...
@@ -352,9 +349,7 @@ class NodesChildrenDuplicates(APIView):
'deleted'
:
count
})
class
NodesChildrenMetatadata
(
APIView
):
def
get
(
self
,
request
,
node_id
):
# query hyperdata keys
...
...
@@ -412,9 +407,7 @@ class NodesChildrenMetatadata(APIView):
'data'
:
collection
,
})
class
NodesChildrenQueries
(
APIView
):
def
_sql
(
self
,
input
,
node_id
):
fields
=
dict
()
tables
=
set
(
'nodes'
)
...
...
@@ -594,7 +587,6 @@ class NodesChildrenQueries(APIView):
raise
ValidationException
(
'queried fields are mixing incompatible types of fields'
)
return
JsonHttpResponse
(
method
(
input
,
node_id
),
201
)
class
NodesList
(
APIView
):
authentication_classes
=
(
SessionAuthentication
,
BasicAuthentication
)
...
...
@@ -615,9 +607,7 @@ class NodesList(APIView):
for
node
in
query
.
all
()
]})
class
Nodes
(
APIView
):
def
get
(
self
,
request
,
node_id
):
node
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_id
)
.
first
()
if
node
is
None
:
...
...
@@ -651,9 +641,7 @@ class Nodes(APIView):
except
Exception
as
error
:
msgres
=
"error deleting : "
+
node_id
+
str
(
error
)
class
CorpusController
:
@
classmethod
def
get
(
cls
,
corpus_id
):
try
:
...
...
rest/crawls/__init__.py
→
rest
_v1_0
/crawls/__init__.py
View file @
5964c948
File moved
rest/lists/__init__.py
→
rest
_v1_0
/lists/__init__.py
View file @
5964c948
File moved
rest/ngrams.py
→
rest
_v1_0
/ngrams.py
View file @
5964c948
...
...
@@ -2,6 +2,7 @@ from django.http import HttpResponse, Http404
from
django.core.exceptions
import
PermissionDenied
,
SuspiciousOperation
from
django.core.exceptions
import
ValidationError
from
django.core.urlresolvers
import
reverse
from
django.contrib.auth.decorators
import
login_required
from
sqlalchemy
import
text
,
distinct
,
or_
,
not_
from
sqlalchemy.sql
import
func
,
desc
...
...
@@ -69,6 +70,7 @@ class APIException(_APIException):
from
rest_framework.decorators
import
api_view
@
login_required
class
Ngrams
(
APIView
):
'''
REST application to manage ngrams
...
...
rest/nodes/__init__.py
→
rest
_v1_0
/nodes/__init__.py
View file @
5964c948
File moved
rest_v1_0/urls.py
0 → 100644
View file @
5964c948
from
django.conf.urls
import
patterns
,
url
from
rest_v1_0
import
api
,
ngrams
urlpatterns
=
patterns
(
''
,
# REST URLS
# What is REST ?
# https://en.wikipedia.org/wiki/Representational_state_transfer
#url(r'^api$', rest_v1_0.api.Root), # = ?
url
(
r'nodes$'
,
api
.
NodesList
.
as_view
()),
url
(
r'nodes$'
,
api
.
NodesList
.
as_view
()),
url
(
r'nodes/(\d+)$'
,
api
.
Nodes
.
as_view
()),
url
(
r'nodes/(\d+)$'
,
api
.
Nodes
.
as_view
()),
url
(
r'nodes/(\d+)/children/ngrams$'
,
api
.
NodesChildrenNgrams
.
as_view
()),
# => repeated children ?
url
(
r'nodes/(\d+)/children/ngrams$'
,
api
.
NodesChildrenNgrams
.
as_view
()),
# => repeated children ?
url
(
r'node/(\d+)/ngrams$'
,
ngrams
.
Ngrams
.
as_view
()),
url
(
r'node/(\d+)/ngrams$'
,
ngrams
.
Ngrams
.
as_view
()),
url
(
r'nodes/(\d+)/children/hyperdata$'
,
api
.
NodesChildrenMetatadata
.
as_view
()),
url
(
r'nodes/(\d+)/children/hyperdata$'
,
api
.
NodesChildrenMetatadata
.
as_view
()),
url
(
r'nodes/(\d+)/children/queries$'
,
api
.
NodesChildrenQueries
.
as_view
()),
url
(
r'nodes/(\d+)/children/queries$'
,
api
.
NodesChildrenQueries
.
as_view
()),
url
(
r'nodes/(\d+)/children/duplicates$'
,
api
.
NodesChildrenDuplicates
.
as_view
()),
url
(
r'nodes/(\d+)/children/duplicates$'
,
api
.
NodesChildrenDuplicates
.
as_view
()),
# url(r'^api/nodes/(\d+)/children/duplicates/delete$', api.NodesChildrenDuplicates.delete ),
url
(
r'nodes/(\d+)/ngrams$'
,
api
.
CorpusController
.
ngrams
),
url
(
r'nodes/(\d+)/ngrams$'
,
api
.
CorpusController
.
ngrams
),
#url(r'tfidf/(\d+)/(\w+)$', views_optimized.tfidf),
)
scrappers/scrap_pubmed/views.py
View file @
5964c948
...
...
@@ -30,7 +30,7 @@ import threading
from
node.admin
import
CustomForm
from
gargantext_web.db
import
*
from
gargantext_web.settings
import
DEBUG
,
MEDIA_ROOT
from
rest.api
import
JsonHttpResponse
from
rest
_v1_0
.api
import
JsonHttpResponse
from
parsing.corpustools
import
add_resource
,
parse_resources
,
extract_ngrams
from
ngram.tfidf
import
compute_tfidf
...
...
tests/ngramstable/views.py
View file @
5964c948
...
...
@@ -50,7 +50,7 @@ from sqlalchemy import or_, func
from
gargantext_web
import
about
from
rest.api
import
JsonHttpResponse
from
rest
_v1_0
.api
import
JsonHttpResponse
from
ngram.lists
import
listIds
,
listNgramIds
,
ngramList
,
doList
...
...
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