diff options
Diffstat (limited to 'gstudio/views')
-rw-r--r-- | gstudio/views/ajaxviews.py | 30 | ||||
-rw-r--r-- | gstudio/views/graphs.py | 24 |
2 files changed, 41 insertions, 13 deletions
diff --git a/gstudio/views/ajaxviews.py b/gstudio/views/ajaxviews.py index 8fbb6e03..23c06e54 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 070ceab3..757a838e 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() |