Commit 1dbb656a authored by sim's avatar sim

Quick fix: projects must be child of a user node

parent c1c53cc9
...@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment