Commit 2d470e64 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge remote-tracking branch 'origin/simon-dev' into dev

parents 2bf705d9 d95d47d4
......@@ -5,6 +5,7 @@ from collections import defaultdict
from gargantext.util.toolchain import *
import copy
from gargantext.util.db import session
from gargantext.models import UserNode
class ProjectList(APIView):
'''API endpoint that represent a list of projects owned by a user'''
......@@ -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)
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(
user_id = request.user.id,
typename = 'PROJECT',
name = name,
parent_id = user_node and user_node.id,
)
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