diff options
author | gnowgi <nagarjun@gnowledge.org> | 2012-05-30 00:20:01 -0700 |
---|---|---|
committer | gnowgi <nagarjun@gnowledge.org> | 2012-05-30 00:20:01 -0700 |
commit | b3744d0a70635dfb702396c82558b46b0d74c054 (patch) | |
tree | 8a74ceeca3fc4652bea317856e9e203fa007ae16 /gstudio | |
parent | 2e911f32ae1fc193c4ab121af099b0b6258f22ef (diff) | |
parent | 81f1310e441c5dfd71e332aaa09e0964052ab9e3 (diff) | |
download | gnowsys-b3744d0a70635dfb702396c82558b46b0d74c054.tar.gz |
Merge pull request #46 from sruthirajagopal/master
get_nbh added for relationtype.
Diffstat (limited to 'gstudio')
-rw-r--r-- | gstudio/models.py | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/gstudio/models.py b/gstudio/models.py index c128c959..1bf43f27 100644 --- a/gstudio/models.py +++ b/gstudio/models.py @@ -1140,8 +1140,12 @@ class Nodetype(Node): nbh['count_title'] = len(nbh['title']) nbh['altnames'] = self.altnames nbh['count_altnames'] = len(nbh['altnames']) - nbh['plural'] = self.plural - nbh['count_plural'] = len(nbh['plural']) + nbh['plural'] = self.plural + try: + nbh['count_plural'] = len(nbh['plural']) + except: + pass + #get all MTs member_of_dict = {} for each in self.metatypes.all(): @@ -1393,11 +1397,7 @@ class Objecttype(Nodetype): def __unicode__(self): return self.title - - - - - + @property def get_attributetypes(self): @@ -1607,6 +1607,37 @@ class Relationtype(Nodetype): def __unicode__(self): return self.title + @property + def get_nbh(self): + """ + Returns the neighbourhood of the nodetype + """ + nbh = {} + nbh['title'] = self.title + nbh['altnames'] = self.altnames + nbh['plural'] = self.plural + + nbh['contains_subtypes'] = Nodetype.objects.filter(parent=self.id) + # get all the objects inheriting this OT + nbh['contains_members'] = self.member_objects.all() + nbh['prior_nodes'] = self.prior_nodes.all() + nbh['posterior_nodes'] = self.posterior_nodes.all() + nbh['inverse']=self.inverse + nbh['left_subjecttype']=self.left_subjecttype + nbh['left_applicable_nodetypes']=self.left_applicable_nodetypes + nbh['left_cardinality']=self.left_cardinality + nbh['right_subjecttype']=self.right_subjecttype + nbh['right_applicable_nodetypes']=self.right_applicable_nodetypes + nbh['right_cardinality']=self.right_cardinality + nbh['is_symmetrical']=self.is_symmetrical + nbh['is_reflexive']=self.is_reflexive + nbh['is_transitive']=self.is_transitive + + + + return nbh + + class Meta: """ relation type's meta class |