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
4a565104
Commit
4a565104
authored
Oct 25, 2016
by
c24b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generic fonction get_node_user(user) for both
parent
34c0afda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
24 deletions
+35
-24
corpora.py
gargantext/views/pages/corpora.py
+19
-9
projects.py
gargantext/views/pages/projects.py
+16
-15
No files found.
gargantext/views/pages/corpora.py
View file @
4a565104
...
...
@@ -7,6 +7,16 @@ from gargantext.settings import *
from
datetime
import
datetime
def
get_node_user
(
user
):
node_user
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user
.
id
&
Node
.
typename
==
"USER"
)
if
node_user
is
None
:
node_user
=
Node
(
typename
==
"USER"
,
user_id
=
user
.
id
,
name
=
user
.
name
)
#default language for now is 'fr'
node_user
.
hyperdata
[
"language"
]
=
"fr"
session
.
add
(
node_user
)
session
.
commit
()
return
node_user
def
_get_user_project_corpus
(
request
,
project_id
,
corpus_id
):
"""Helper method to get a corpus, knowing the project's and corpus' ID.
...
...
@@ -42,7 +52,7 @@ def docs_by_titles(request, project_id, corpus_id):
'resourcename'
:
get_resource
(
source_type
)[
'name'
],
'view'
:
'titles'
,
'user'
:
request
.
user
,
'user_parameters'
:
node_user
.
hyperdata
'user_parameters'
:
get_node_user
(
user
)[
"hyperdata"
]
},
)
...
...
@@ -58,9 +68,9 @@ def docs_by_sources(request, project_id, corpus_id):
# and the project just for project.id in corpusBannerTop
project
=
cache
.
Node
[
project_id
]
user
=
cache
.
User
[
request
.
user
.
id
]
source_type
=
corpus
.
resources
()[
0
][
'type'
]
node_user
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user
.
id
&
Node
.
typename
==
"USER"
)
# rendered page : sources.html
return
render
(
template_name
=
'pages/corpora/sources.html'
,
...
...
@@ -72,7 +82,7 @@ def docs_by_sources(request, project_id, corpus_id):
'corpus'
:
corpus
,
'resourcename'
:
get_resource
(
source_type
)[
'name'
],
'user'
:
request
.
user
,
"user_parameters"
:
node_user
.
hyperdata
,
'user_parameters'
:
get_node_user
(
user
)[
"hyperdata"
]
'view'
:
'sources'
},
)
...
...
@@ -89,9 +99,9 @@ def docs_by_authors(request, project_id, corpus_id):
# and the project just for project.id in corpusBannerTop
project
=
cache
.
Node
[
project_id
]
user
=
cache
.
User
[
request
.
user
.
id
]
source_type
=
corpus
.
resources
()[
0
][
'type'
]
node_user
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user
.
id
&
Node
.
typename
==
"USER"
)
# rendered page : sources.html
return
render
(
template_name
=
'pages/corpora/authors.html'
,
...
...
@@ -104,7 +114,7 @@ def docs_by_authors(request, project_id, corpus_id):
'resourcename'
:
get_resource
(
source_type
)[
'name'
],
'view'
:
'authors'
,
'user'
:
request
.
user
,
"user_parameters"
:
node_user
.
hyperdata
'user_parameters'
:
get_node_user
(
user
)[
"hyperdata"
]
},
)
...
...
@@ -116,7 +126,7 @@ def analytics(request, project_id, corpus_id):
return
HttpResponseForbidden
()
source_type
=
corpus
.
resources
()[
0
][
'type'
]
node_user
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user
.
id
&
Node
.
typename
==
"USER"
)
# response!
return
render
(
template_name
=
'pages/analytics/histories.html'
,
...
...
@@ -129,6 +139,6 @@ def analytics(request, project_id, corpus_id):
'resourcename'
:
get_resource
(
source_type
)[
'name'
],
'view'
:
'analytics'
,
'user'
:
request
.
user
,
'user_parameters'
:
node_user
.
hyperdata
,
'user_parameters'
:
get_node_user
(
user
)[
"hyperdata"
]
},
)
gargantext/views/pages/projects.py
View file @
4a565104
...
...
@@ -13,6 +13,15 @@ from collections import defaultdict
from
django.utils.translation
import
ugettext_lazy
import
re
def
get_node_user
(
user
):
node_user
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user
.
id
&
Node
.
typename
==
"USER"
)
if
node_user
is
None
:
node_user
=
Node
(
typename
==
"USER"
,
user_id
=
user
.
id
,
name
=
user
.
name
)
#default language for now is 'fr'
node_user
.
hyperdata
[
"language"
]
=
"fr"
session
.
add
(
node_user
)
session
.
commit
()
return
node_user
@
requires_auth
def
overview
(
request
):
...
...
@@ -22,15 +31,7 @@ def overview(request):
'''
user
=
cache
.
User
[
request
.
user
.
id
]
node_user_id
=
session
.
query
(
Node
.
id
)
.
filter
(
Node
.
user_id
==
user
.
id
&
Node
.
typename
==
"USER"
)
if
node_user_id
is
None
:
node_user
=
Node
(
typename
==
"USER"
,
user_id
=
user
.
id
,
name
=
request
.
user
.
name
)
#default language for now is 'fr'
node_user
.
hyperdata
[
"language"
]
=
"fr"
session
.
add
(
node_user
)
session
.
commit
()
node_user_id
=
node_user
.
id
node_user
=
get_node_user
(
user
)
# If POST method, creates a new project...
if
request
.
method
==
'POST'
:
name
=
str
(
request
.
POST
[
'name'
])
...
...
@@ -39,13 +40,12 @@ def overview(request):
user_id
=
user
.
id
,
typename
=
'PROJECT'
,
name
=
name
,
parent_id
=
node_user
_
id
,
parent_id
=
node_user
.
id
,
)
session
.
add
(
new_project
)
session
.
commit
()
user_parameters
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
node_user_id
&
Node
.
typename
==
"USER"
)[
"hyperdata"
]
# list of projects created by the logged user
user_projects
=
user
.
nodes
(
typename
=
'PROJECT'
,
order
=
True
)
...
...
@@ -62,7 +62,7 @@ def overview(request):
# projects owned by the user
'number'
:
user_projects
.
count
(),
'projects'
:
user_projects
,
"user_parameters"
:
user_parameters
,
"user_parameters"
:
node_user
[
"hyperdata"
]
,
# projects owned by the user's contacts
'common_users'
:
(
contact
for
contact
,
projects
in
contacts_projects
),
'common_projects'
:
sum
((
projects
for
contact
,
projects
in
contacts_projects
),
[]),
...
...
@@ -102,6 +102,7 @@ def project(request, project_id):
# security check
project
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
project_id
)
.
first
()
user
=
cache
.
User
[
request
.
user
.
id
]
node_user
=
get_node_user
(
user
)
if
project
is
None
:
raise
Http404
()
...
...
@@ -183,7 +184,7 @@ def project(request, project_id):
'form'
:
NewCorpusForm
,
'user'
:
request
.
user
,
"user_parameters"
:
user_parameters
,
"user_parameters"
:
node_user
[
"hyperdata"
]
,
'date'
:
datetime
.
now
(),
'project'
:
project
,
'donut'
:
donut
,
...
...
@@ -203,7 +204,7 @@ def project(request, project_id):
template_name
=
'pages/projects/project.html'
,
request
=
request
,
context
=
{
"user_parameters"
:
user_parameters
,
"user_parameters"
:
node_user
[
"hyperdata"
]
,
'form'
:
NewCorpusForm
,
'user'
:
request
.
user
,
'date'
:
datetime
.
now
(),
...
...
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