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
47f224f8
Commit
47f224f8
authored
Oct 26, 2016
by
c24b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default Langue Fr for user in views
parent
801a279d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
36 deletions
+49
-36
corpora.py
gargantext/views/pages/corpora.py
+8
-20
main.py
gargantext/views/pages/main.py
+32
-2
projects.py
gargantext/views/pages/projects.py
+1
-1
terms.py
gargantext/views/pages/terms.py
+1
-11
views.py
graph/views.py
+7
-2
No files found.
gargantext/views/pages/corpora.py
View file @
47f224f8
from
gargantext.util.http
import
*
from
gargantext.util.db
import
*
from
gargantext.util.db_cache
import
cache
from
gargantext.models
import
*
from
gargantext.constants
import
*
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"
)
.
first
()
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
from
gargantext.util.http
import
*
from
gargantext.util.db
import
*
from
gargantext.util.db_cache
import
cache
from
gargantext.models
import
*
from
gargantext.constants
import
*
from
gargantext.settings
import
*
from
datetime
import
datetime
from
.main
import
get_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.
...
...
gargantext/views/pages/main.py
View file @
47f224f8
from
gargantext.util.http
import
*
from
gargantext.util.http
import
*
from
gargantext.util.db
import
session
from
gargantext.models
import
Node
,
User
import
datetime
from
gargantext.util.generators
import
paragraphs
,
credits
def
get_node_user
(
user
):
#load user parameters from User(Node).hyperdata from request.user or cache.
node_user
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user
.
id
,
Node
.
typename
==
"USER"
)
.
first
()
if
node_user
is
None
:
try
:
node_user
=
Node
(
user_id
=
user
.
id
,
typename
=
'USER'
,
name
=
user
.
name
,
)
except
AttributeError
:
node_user
=
Node
(
user_id
=
user
.
id
,
typename
=
'USER'
,
name
=
"Anne Aunime"
,
)
#default language for now is 'fr'
node_user
.
hyperdata
.
language
=
"fr"
session
.
add
(
node_user
)
session
.
commit
()
return
node_user
def
home
(
request
):
'''Home describes the platform.
A video draws the narratives.
If not logged a project test is shown.
'''
user_node
=
get_node_user
(
request
.
user
)
return
render
(
template_name
=
'pages/main/home.html'
,
request
=
request
,
...
...
@@ -19,12 +43,15 @@ def home(request):
'paragraph_gargantua'
:
paragraphs
.
gargantua
(),
'paragraph_lorem'
:
paragraphs
.
lorem
(),
'paragraph_tutoreil'
:
paragraphs
.
tutoreil
(),
'user_parameters'
:
user_node
.
hyperdata
},
)
def
about
(
request
):
'''About Gargantext, its team and sponsors
'''
user_node
=
get_user_node
(
request
.
user
)
return
render
(
template_name
=
'pages/main/about.html'
,
request
=
request
,
...
...
@@ -35,6 +62,7 @@ def about(request):
'institutions'
:
credits
.
institutions
(),
'labos'
:
credits
.
labs
(),
'grants'
:
credits
.
grants
(),
'user_parameters'
:
user_node
.
hyperdata
},
)
...
...
@@ -50,11 +78,13 @@ def robots(request):
def
maintenance
(
request
):
'''Gargantext out of service
'''
user_node
=
get_user_node
(
request
.
user
)
return
render
(
template_name
=
'pages/main/maintenance.html'
,
request
=
request
,
context
=
{
'user'
:
request
.
user
,
'date'
:
datetime
.
datetime
.
now
(),
'user_parameters'
:
user_node
.
hyperdata
},
)
gargantext/views/pages/projects.py
View file @
47f224f8
...
...
@@ -4,7 +4,7 @@ from gargantext.util.db_cache import cache
from
gargantext.util.files
import
upload
from
gargantext.models
import
*
from
gargantext.constants
import
*
from
.main
import
get_node_user
from
gargantext.util.scheduling
import
scheduled
from
gargantext.util.toolchain
import
parse_extract_indexhyperdata
...
...
gargantext/views/pages/terms.py
View file @
47f224f8
...
...
@@ -3,19 +3,9 @@ from gargantext.util.db import session
from
gargantext.util.db_cache
import
cache
from
gargantext.models
import
Node
from
gargantext.constants
import
get_resource
from
.main
import
get_node_user
from
datetime
import
datetime
def
get_node_user
(
user
):
#load user parameters
node_user
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user
.
id
,
Node
.
typename
==
"USER"
)
.
first
()
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
ngramtable
(
request
,
project_id
,
corpus_id
):
...
...
graph/views.py
View file @
47f224f8
...
...
@@ -4,6 +4,7 @@ from gargantext.util.db_cache import cache
from
gargantext.models
import
*
from
gargantext.constants
import
*
from
gargantext.settings
import
*
from
gargantext.views.pages.main
import
get_node_user
from
datetime
import
datetime
...
...
@@ -19,9 +20,10 @@ def explorer(request, project_id, corpus_id):
# we pass our corpus
corpus
=
cache
.
Node
[
corpus_id
]
# security check
user
=
cache
.
User
[
request
.
user
.
id
]
node_user
=
get_node_user
(
user
)
if
corpus
is
None
:
raise
Http404
()
if
not
user
.
owns
(
corpus
):
...
...
@@ -46,6 +48,7 @@ def explorer(request, project_id, corpus_id):
'corpus'
:
corpus
,
'maplist_id'
:
maplist_id
,
'view'
:
'graph'
,
'user_parameters'
:
node_user
.
hyperdata
,
},
)
...
...
@@ -61,6 +64,7 @@ def myGraphs(request, project_id, corpus_id):
'''
user
=
cache
.
User
[
request
.
user
.
id
]
node_user
=
get_node_user
(
user
)
# we pass our corpus
corpus
=
cache
.
Node
[
corpus_id
]
...
...
@@ -99,6 +103,7 @@ def myGraphs(request, project_id, corpus_id):
'corpus'
:
corpus
,
'view'
:
'myGraph'
,
'coocs'
:
coocs
,
'coocs_count'
:
coocs_count
'coocs_count'
:
coocs_count
,
'user_parameters'
:
user_node
.
hyperdata
,
},
)
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