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
6182a4fa
Commit
6182a4fa
authored
Mar 01, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix user retrieval from cache
parent
c4fc0354
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
corpora.py
gargantext/views/pages/corpora.py
+7
-4
No files found.
gargantext/views/pages/corpora.py
View file @
6182a4fa
...
...
@@ -12,19 +12,22 @@ def _get_user_project_corpus(request, project_id, corpus_id):
"""Helper method to get a corpus, knowing the project's and corpus' ID.
Raises HTTP errors when parameters (user, IDs...) are invalid.
"""
user
=
cache
.
User
[
request
.
user
.
username
]
user
=
cache
.
User
[
request
.
user
.
id
]
project
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
project_id
)
.
first
()
corpus
=
session
.
query
(
Node
)
.
filter
(
Node
.
id
==
corpus_id
)
.
filter
(
Node
.
parent_id
==
project_id
)
.
first
()
if
corpus
is
None
:
raise
Http404
()
if
not
user
.
owns
(
corpus
):
raise
HttpResponseForbidden
()
return
user
,
project
,
corpus
print
(
"CORPORA: invalid user
%
i (User doesn't own this corpus)"
%
user
.
id
)
return
(
False
,
user
,
project
,
corpus
)
return
(
True
,
user
,
project
,
corpus
)
@
requires_auth
def
corpus
(
request
,
project_id
,
corpus_id
):
user
,
project
,
corpus
=
_get_user_project_corpus
(
request
,
project_id
,
corpus_id
)
authorized
,
user
,
project
,
corpus
=
_get_user_project_corpus
(
request
,
project_id
,
corpus_id
)
if
not
authorized
:
return
HttpResponseForbidden
()
# response!
return
render
(
template_name
=
'pages/corpora/corpus.html'
,
...
...
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