summaryrefslogtreecommitdiff
path: root/gstudio/views
diff options
context:
space:
mode:
authorArun yadav <arunkumar5587@gmail.com>2012-05-09 16:46:57 +0530
committerArun yadav <arunkumar5587@gmail.com>2012-05-09 16:46:57 +0530
commitfe4a82b80954e4a4666afa71ab3161c8b824f9e9 (patch)
tree323a20001563644fead153a9debbc684a446a9c2 /gstudio/views
parent7e02e008009c476c831d7dcda78db9bc22beb42e (diff)
parent6b77378be56f722d36459056b7d3083d1a422448 (diff)
downloadgnowsys-fe4a82b80954e4a4666afa71ab3161c8b824f9e9.tar.gz
merged with gn repository
Diffstat (limited to 'gstudio/views')
-rw-r--r--gstudio/views/ajaxviews.py30
-rw-r--r--gstudio/views/graphs.py24
2 files changed, 41 insertions, 13 deletions
diff --git a/gstudio/views/ajaxviews.py b/gstudio/views/ajaxviews.py
index 8fbb6e0..23c06e5 100644
--- a/gstudio/views/ajaxviews.py
+++ b/gstudio/views/ajaxviews.py
@@ -27,10 +27,19 @@ def AjaxAttribute(request):
subjecttype = attr.subjecttype
returndict = {}
- for each in Objecttype.objects.all():
- if attr.subjecttype.id == each.id:
- for member in each.get_members:
+ for ots in Objecttype.objects.all():
+ if attr.subjecttype.id ==ots.id:
+ for member in ots.get_members:
returndict[member.id] = member.title
+ childrenots = ots.get_children()
+
+ if childrenots:
+ for eachchild in childrenots:
+ returndict[eachchild.id] = eachchild.title
+ membs=eachchild.ref.get_members
+ for each in membs:
+ returndict[each.id] = each.title
+
jsonobject = json.dumps(returndict)
return HttpResponse(jsonobject, "application/json")
@@ -76,22 +85,37 @@ def additemdict(sdict,itemtoadd):
sdict[itemtoadd.id]=itemtoadd.title
return sdict
def selectionlist_OT(obj):
+ # Basically the filter must filter out the OT, their members, the children and members of the children
+
global rlist
# Return all OTs and members of subtypes of OT
obs=Objecttype.objects.filter(title=obj)
# Get all members of subtypes of each OT
if obs:
+ # Add the items first
+ for each in obs:
+ rlist=additemdict(rlist,each)
obs=Objecttype.objects.get(title=obj)
+ # Add the objects first
+ # for each in obs:
+ # rlist = additemdict(rlist,each)
memobs=obs.get_members
if memobs:
for each in memobs:
rlist=additemdict(rlist,each)
childrenots=obs.get_children()
+ # Add children first
+ for each in childrenots:
+ rlist=additemdict(rlist,each)
+ # Add memebers of each child
if childrenots:
for eachchild in childrenots:
membs=eachchild.ref.get_members
for each in membs:
rlist=additemdict(rlist,each)
+
+
+
return rlist
def selectionlist_MT(obj):
diff --git a/gstudio/views/graphs.py b/gstudio/views/graphs.py
index 070ceab..757a838 100644
--- a/gstudio/views/graphs.py
+++ b/gstudio/views/graphs.py
@@ -73,30 +73,36 @@ from gstudio.gnowql import *
#import d3
import json
import os
-from gstudio.models import *
from gstudio.views.decorators import protect_nodetype
from gstudio.views.decorators import update_queryset
-def graph_json(request, node_id):
+
+
+def graph_json(request, node_id):
+
if(node_id=='189087228'):
jsonFile = open( os.path.join(os.path.dirname(__file__), '../static/gstudio/js/egonet.json'), "r")
- #testjson = json.loads(jsonFile)
+ testjson = json.loads(jsonFile)
return HttpResponse(str(jsonFile.read()), "application/json")
try:
- node = Objecttype.objects.get(id=node_id)
- node = node.ref
+ node = NID.objects.get(id=node_id)
+ node = node.ref
except:
- return HttpResponse("Node not found.", "text/html")
+
+ return HttpResponse("node not found", "text/html")
return HttpResponse(node.get_graph_json(), "application/json")
-
+
+
+
+
+
def force_graph(request, node_id):
return render_to_response('gstudio/graph1.html',{'node_id': node_id })
-
def version_graph_json(request,ssid):
if(ssid=='189087228'):
@@ -114,8 +120,6 @@ def version_graph_json(request,ssid):
return HttpResponse(node.get_Version_graph_json(ssid), "application/json")
-
-
#node = get_node(str(object_id))
#ot = Objecttype.objects.get(title='place')
#G = ot.get_radial_graph_json()