Skip to content
Snippets Groups Projects
Commit 67eceb91 authored by Yorgo EL MOUBAYED's avatar Yorgo EL MOUBAYED
Browse files

Minor updates

parent a66d837c
No related branches found
No related tags found
No related merge requests found
......@@ -50,3 +50,9 @@ python manage.py runserver
~~~
python manage.py shell
~~~
## Links to official documentations
* Django: <https://docs.djangoproject.com/en/3.1/>
* Neomodel: <https://neomodel.readthedocs.io/en/latest/>
* Neo4j: <https://neo4j.com/docs/>
\ No newline at end of file
No preview for this file type
No preview for this file type
from neomodel import StructuredNode, StringProperty, IntegerProperty,UniqueIdProperty, RelationshipTo
from uuid import uuid4
# from api.models.ocf_model import OCF
# from api.models.storagehost_model import StorageHost
......@@ -8,7 +7,7 @@ from uuid import uuid4
class Construct(StructuredNode):
uid=UniqueIdProperty(default=uuid4)
uuid=UniqueIdProperty()
name=StringProperty()
# Relationships
......
No preview for this file type
No preview for this file type
......@@ -24,7 +24,7 @@ def indexConstruct(request):
response=[]
for construct in constructs :
obj= {
"uid": construct.uid,
"uuid": construct.uuid,
"name": construct.name,
}
response.append(obj)
......@@ -43,7 +43,7 @@ def showConstruct(request):
name=request.GET.get('name', ' ')
try:
construct=Construct.nodes.get(name=name)
return JsonResponse({"uid": construct.uid, "name": construct.name}, safe=False)
return JsonResponse({"uuid": construct.uuid, "name": construct.name}, safe=False)
except :
return JsonResponse({"error":"Error occurred"}, safe=False)
......@@ -60,7 +60,7 @@ def storeConstruct(request):
try:
construct=Construct(name=name)
construct.save()
return JsonResponse({"uid": construct.uid})
return JsonResponse({"uuid": construct.uuid})
except :
return JsonResponse({"error":"Error occurred"}, safe=False)
......@@ -74,12 +74,12 @@ def updateConstruct(request):
if request.method=='PUT':
json_data=json.loads(request.body)
name=json_data['name']
uid=json_data['uid']
uuid=json_data['uuid']
try:
construct=Construct.nodes.get(uid=uid)
construct=Construct.nodes.get(uuid=uuid)
construct.name=name
construct.save()
return JsonResponse({"uid": construct.uid, "name": name}, safe=False)
return JsonResponse({"uuid": construct.uuid, "name": name}, safe=False)
except:
return JsonResponse({"error":"Error occurred"}, safe=False)
......@@ -87,14 +87,14 @@ def updateConstruct(request):
def destroyConstruct(request):
"""
Delete one construct by uid
Delete one construct by uuid
"""
if request.method=='DELETE':
json_data=json.loads(request.body)
uid=json_data['uid']
uuid=json_data['uuid']
try:
construct=Construct.nodes.get(uid=uid)
construct=Construct.nodes.get(uuid=uuid)
construct.delete()
return JsonResponse({"success": "Construct deleted"}, safe=False)
except:
......
# from django.http import JsonResponse
# from api.models import *
# from django.views.decorators.csrf import csrf_exempt
# import json
# from api.models import *
# @csrf_exempt
# def connectConstructUser(request):
# if request.method == 'PUT':
......
......@@ -20,7 +20,7 @@ def indexUser(request):
if request.method=='GET':
try:
users=User.nodes.all()
users=User.nodes.all(lazy=False)
response=[]
for user in users :
obj= {
......@@ -43,7 +43,8 @@ def showUser(request):
name=request.GET.get('name', ' ')
try:
user=User.nodes.get(name=name)
return JsonResponse({"uid": user.uid, "name": user.name}, safe=False)
# return JsonResponse({"uid": user.uid, "name": user.name}, safe=False)
return JsonResponse({user}, safe=False)
except :
return JsonResponse({"error":"Error occurred"}, safe=False)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment