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
d95d47d4
Commit
d95d47d4
authored
Jan 24, 2018
by
sim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Quick fix: projects must be child of a user node
parent
fbfb5d60
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
projects.py
gargantext/views/api/projects.py
+7
-0
No files found.
gargantext/views/api/projects.py
View file @
d95d47d4
...
@@ -5,6 +5,7 @@ from collections import defaultdict
...
@@ -5,6 +5,7 @@ from collections import defaultdict
from
gargantext.util.toolchain
import
*
from
gargantext.util.toolchain
import
*
import
copy
import
copy
from
gargantext.util.db
import
session
from
gargantext.util.db
import
session
from
gargantext.models
import
UserNode
class
ProjectList
(
APIView
):
class
ProjectList
(
APIView
):
'''API endpoint that represent a list of projects owned by a user'''
'''API endpoint that represent a list of projects owned by a user'''
...
@@ -36,10 +37,16 @@ class ProjectList(APIView):
...
@@ -36,10 +37,16 @@ class ProjectList(APIView):
return
Response
({
"detail"
:
"Project with this name already exists"
,
"url"
:
"/projects/
%
s"
%
str
(
project
.
id
)},
status
=
HTTP_409_CONFLICT
)
return
Response
({
"detail"
:
"Project with this name already exists"
,
"url"
:
"/projects/
%
s"
%
str
(
project
.
id
)},
status
=
HTTP_409_CONFLICT
)
else
:
else
:
user_node
=
session
.
query
(
UserNode
)
.
filter_by
(
user_id
=
request
.
user
.
id
)
.
one_or_none
()
if
user_node
is
None
:
print
(
"??? Can't find UserNode for
%
r to create ProjectNode with name
%
r ???"
%
(
request
.
user
,
name
))
new_project
=
Node
(
new_project
=
Node
(
user_id
=
request
.
user
.
id
,
user_id
=
request
.
user
.
id
,
typename
=
'PROJECT'
,
typename
=
'PROJECT'
,
name
=
name
,
name
=
name
,
parent_id
=
user_node
and
user_node
.
id
,
)
)
session
.
add
(
new_project
)
session
.
add
(
new_project
)
...
...
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