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
597b1871
Commit
597b1871
authored
Nov 18, 2014
by
Mathieu Rodic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CODE] Rearranged urls.py, cleaned api.py
parent
aaaa31b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
25 deletions
+28
-25
api.py
gargantext_web/api.py
+12
-8
urls.py
gargantext_web/urls.py
+16
-17
No files found.
gargantext_web/api.py
View file @
597b1871
...
...
@@ -65,7 +65,9 @@ class CorpusController:
raise
Http404
(
"No such corpus:
%
d"
%
(
corpus_id
,
))
corpus
=
corpusQuery
.
first
()
if
corpus
.
type
.
name
!=
'Corpus'
:
raise
Http404
(
"No such corpus.
%
d"
%
(
corpus_id
,
))
raise
Http404
(
"No such corpus:
%
d"
%
(
corpus_id
,
))
# if corpus.user != {currentUser}:
# raise Http403("Unauthorized access.")
return
corpus
...
...
@@ -91,12 +93,15 @@ class CorpusController:
AND ngram.terms LIKE '
%
s
%%
'
GROUP BY ngram.terms
ORDER BY SUM(node_ngram.weight) DESC
'''
%
(
Node
.
_meta
.
db_table
,
NodeType
.
_meta
.
db_table
,
Node_Ngram
.
_meta
.
db_table
,
Ngram
.
_meta
.
db_table
,
corpus
.
id
,
corpus
.
id
,
request
.
GET
.
get
(
'startwith'
,
''
)
.
replace
(
"'"
,
"
\\
'"
),
))
# # how should we order this?
# orderColumn = {
# "frequency" : "-count",
# "alphabetical" : "terms"
# }.get(request.GET.get('order', 'frequency'), '-count')
'''
%
(
Node
.
_meta
.
db_table
,
NodeType
.
_meta
.
db_table
,
Node_Ngram
.
_meta
.
db_table
,
Ngram
.
_meta
.
db_table
,
corpus
.
id
,
corpus
.
id
,
request
.
GET
.
get
(
'startwith'
,
''
)
.
replace
(
"'"
,
"
\\
'"
),
))
# response building
return
JsonHttpResponse
({
"list"
:
[
row
[
0
]
for
row
in
cursor
.
fetchall
()],
...
...
@@ -196,7 +201,6 @@ class CorpusController:
cursor
.
execute
(
sql
)
# response building
return
JsonHttpResponse
({
# "list": [{key:value for key, value in row.items() if isinstance(value, (str, int, float))} for row in query[:20].values()],
"list"
:
[
row
for
row
in
cursor
.
fetchall
()],
})
gargantext_web/urls.py
View file @
597b1871
...
...
@@ -3,10 +3,7 @@ from django.conf.urls import patterns, include, url
from
django.contrib
import
admin
from
django.contrib.auth.views
import
login
from
gargantext_web.views
import
home
,
projects
,
project
,
corpus
from
gargantext_web.views
import
delete_project
,
delete_corpus
from
gargantext_web.views
import
exploration
,
send_csv
,
send_graph
from
gargantext_web.views
import
explorer_graph
,
explorer_matrix
,
explorer_chart
from
gargantext_web
import
views
import
gargantext_web.api
...
...
@@ -20,29 +17,31 @@ urlpatterns = patterns('',
url
(
r'^login/'
,
include
(
admin
.
site
.
urls
)),
url
(
r'^grappelli/'
,
include
(
'grappelli.urls'
)),
url
(
r'^$'
,
home
),
url
(
r'^$'
,
views
.
home
),
url
(
r'^projects/$'
,
projects
),
url
(
r'^project/(\d+)/delete/$'
,
delete_project
),
url
(
r'^projects/$'
,
views
.
projects
),
url
(
r'^project/(\d+)/delete/$'
,
views
.
delete_project
),
url
(
r'^project/(\d+)/$'
,
project
),
url
(
r'^project/(\d+)/$'
,
views
.
project
),
url
(
r'^project/(\d+)/corpus/(\d+)/$'
,
corpus
),
url
(
r'^project/(\d+)/corpus/(\d+)/delete/$'
,
delete_corpus
),
url
(
r'^project/(\d+)/corpus/(\d+)/data.csv$'
,
send_csv
),
url
(
r'^project/(\d+)/corpus/(\d+)/$'
,
views
.
corpus
),
url
(
r'^project/(\d+)/corpus/(\d+)/delete/$'
,
views
.
delete_corpus
),
url
(
r'^project/(\d+)/corpus/(\d+)/data.csv$'
,
views
.
send_csv
),
url
(
r'^graph$'
,
explorer_graph
),
url
(
r'^chart$'
,
explorer_chart
),
url
(
r'^matrix$'
,
explorer_matrix
),
url
(
r'^graph$'
,
views
.
explorer_graph
),
url
(
r'^chart$'
,
views
.
explorer_chart
),
url
(
r'^matrix$'
,
views
.
explorer_matrix
),
url
(
r'^exploration$'
,
exploration
),
url
(
r'^exploration$'
,
views
.
exploration
),
url
(
r'^chart/corpus/(\d+)/data.csv$'
,
send_csv
),
url
(
r'^graph.json$'
,
send_graph
),
url
(
r'^chart/corpus/(\d+)/data.csv$'
,
views
.
send_csv
),
url
(
r'^graph.json$'
,
views
.
send_graph
),
url
(
r'^api/corpus/(\d+)/ngrams$'
,
gargantext_web
.
api
.
CorpusController
.
ngrams
),
url
(
r'^api/corpus/(\d+)/metadata$'
,
gargantext_web
.
api
.
CorpusController
.
metadata
),
url
(
r'^api/corpus/(\d+)/data$'
,
gargantext_web
.
api
.
CorpusController
.
data
),
# url(r'^graph-it$', gargantext_web.api.CorpusController.data),
)
from
django.conf
import
settings
...
...
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