diff options
author | shefali shetty <sshefali44@gmail.com> | 2012-05-09 11:24:16 +0530 |
---|---|---|
committer | shefali shetty <sshefali44@gmail.com> | 2012-05-09 11:24:16 +0530 |
commit | be7765e07e626c8be1e3d433ddb2e4f84259cf59 (patch) | |
tree | ae040295d5633b2f920349a1fcb1ef28459c5fed /gstudio/models.py | |
parent | ee3c53484190eab032c28471d2082310b04dab86 (diff) | |
download | gnowsys-be7765e07e626c8be1e3d433ddb2e4f84259cf59.tar.gz |
bug related to 'relation' is rectified
Diffstat (limited to 'gstudio/models.py')
-rw-r--r-- | gstudio/models.py | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/gstudio/models.py b/gstudio/models.py index 65262cc..0b6886d 100644 --- a/gstudio/models.py +++ b/gstudio/models.py @@ -729,7 +729,7 @@ class Nodetype(Node): predicate_id = {} for key in nbh.keys(): - val = str(counter)+"a" + val = str(counter) + "a" predicate_id[key] = val counter = counter + 1 #print predicate_id @@ -750,14 +750,30 @@ class Nodetype(Node): #g_json[str(key)].append({"from":self.id , "to":predicate_id[key],"value":1, "level":1 }) g_json["relations"].append({"from":self.id ,"type":str(key),"value":1,"to":predicate_id[key] }) + if not isinstance(nbh[key],basestring): for item in nbh[key]: - #create nodes - g_json["node_metadata"].append({"_id":str(item.id),"screen_name":item.title,"title":self.title, "url":item.get_absolute_url(),"expanded":"false"}) - - # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) - #create links - g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item.id }) + if item.reftype!="Relation": + # create nodes + + g_json["node_metadata"].append({"_id":str(item.id),"screen_name":item.title,"title":self.title, "url":item.get_absolute_url(),"expanded":"false"}) + + # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) + #create links + g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item.id }) + + else: + + if item.left_subject.id==self.id: + item1=item.right_subject + elif item.right_subject.id==self.id: + item1=item.left_subject + + g_json["node_metadata"].append({"_id":str(item1.id),"screen_name":item1.title,"title":self.title, "url":item1.get_absolute_url(),"expanded":"false"}) + + # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) + #create links + g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item1.id }) else: #value={nbh["plural"]:"a4",nbh["altnames"]:"a5"} @@ -765,7 +781,7 @@ class Nodetype(Node): #for item in value.keys(): g_json["node_metadata"].append({"_id":(str(attr_counter)+"a"),"screen_name":nbh[key]}) #g_json[str(key)].append({"from":predicate_id[key] , "to":attr_counter ,"value":1, "level":2 }) - g_json["relations"].append({"from":predicate_id[key] ,"type":str(key) ,"value":1,"to":(str(attr_counter)+"a") }) + g_json["relations"].append({"from":predicate_id[key] ,"type":str(key) ,"value":1,"to":(str(attr_counter)+"a")}) attr_counter-=1 except: |