diff options
author | csitifr <csitifr@gmail.com> | 2012-05-11 16:31:53 +0530 |
---|---|---|
committer | csitifr <csitifr@gmail.com> | 2012-05-11 16:31:53 +0530 |
commit | ffa1efc1acfc176c1dbf659210b41a51eb4d4cad (patch) | |
tree | 65f2e9ba8073f153673701c7a829a261e92b0612 /gstudio | |
parent | 850672379e02b758d89ed609e7f8a9c009853104 (diff) | |
download | gnowsys-ffa1efc1acfc176c1dbf659210b41a51eb4d4cad.tar.gz |
Dynamic mapping for attribute types done.Dynamic form for relation types added for both types and tokens.Properties for getting ATs and RTs added into models
Diffstat (limited to 'gstudio')
-rw-r--r-- | gstudio/models.py | 56 | ||||
-rw-r--r-- | gstudio/templates/gstudio/nodetype_detail.html | 22 |
2 files changed, 72 insertions, 6 deletions
diff --git a/gstudio/models.py b/gstudio/models.py index d793db0..be39527 100644 --- a/gstudio/models.py +++ b/gstudio/models.py @@ -268,6 +268,55 @@ class NID(models.Model): except: return None + @property + def getat(self): + """This is will give the possible attributetypes """ + try: + attributetype = [] + ot = self.ref + attributetype.append(ot.subjecttype_of.all()) + attributetype = [num for elem in attributetype for num in elem] + return attributetype + except: + return None + + @property + def getrt(self): + pt =[] #contains parenttype + reltype =[] #contains relationtype + titledict = {} #contains relationtype's title + inverselist = [] #contains relationtype's inverse + finaldict = {} #contains either title of relationtype or inverse of relationtype + listval=[] #contains keys of titledict to check whether parenttype id is equals to listval's left or right subjecttypeid + # pt.append(Objecttype.objects.get(title = str(gbid))) + # name = NID.objects.get(title = str(gbid)) + pt.append(self.ref) + for i in range(len(pt)): + if Relationtype.objects.filter(left_subjecttype = pt[i].id): + reltype.append(Relationtype.objects.filter(left_subjecttype = pt[i].id)) + if Relationtype.objects.filter(right_subjecttype = pt[i].id): + reltype.append(Relationtype.objects.filter(right_subjecttype = pt[i].id)) + + # it converts 2 or more list as one list + reltype = [num for elem in reltype for num in elem] #this rqud for filtering + + for i in reltype: + titledict.update({i:i.id}) + + + for i in range(len(titledict)): + listval.append(Relationtype.objects.get(title = titledict.keys()[i])) + inverselist.append(str(titledict.keys()[i].inverse)) + + + for j in range(len(pt)): + for i in range(len(listval)): + if pt[j].id == listval[i].left_subjecttype_id : + finaldict.update({titledict.values()[i]:titledict.keys()[i]}) + elif pt[j].id == listval[i].right_subjecttype_id: + finaldict.update({titledict.values()[i]:inverselist[i]}) + + return finaldict.values() @property @@ -1385,6 +1434,13 @@ class Attributetype(Nodetype): def __unicode__(self): return self.title + + @property + def getdataType(self): + at = 'attribute'+str(self.get_dataType_display()) + at = at.lower() + return at + class Meta: """ attribute type's meta class diff --git a/gstudio/templates/gstudio/nodetype_detail.html b/gstudio/templates/gstudio/nodetype_detail.html index 404adb9..53fdbbe 100644 --- a/gstudio/templates/gstudio/nodetype_detail.html +++ b/gstudio/templates/gstudio/nodetype_detail.html @@ -243,18 +243,28 @@ s = parseInt(s) //alert(s) } - </script> - + </script> {% endwith %} {% endblock %} -{% if object.reftype == 'Objecttype'%} -<a href="{{ get_absolute_url }}/objects/dynamicAttribute/save/{{ object.title }}">Add Attribute</a> -<br/> -<a href="{{ get_absolute_url }}/objects/dynamicRelation/displayRT/{{ object.title }}">Add Relation</a> +{% if object.reftype == 'Objecttype' %} +<p> +<b>Add Attributes:</b> +{% for i in object.getat %} +<a href="{{ get_absolute_url }}/objects/dynamicAttribute/save/{{ i }}/{{ object.title }}">{{ i }}</a><nbsp>; +{% endfor %} +</p> + +<p> +<b>Add Relations: </b> +{% for i in object.getrt %} +<a href="{{ get_absolute_url }}/objects/dynamicRelation/displaymem/{{ i }}/{{ object.title }}">{{ i }}</a><nbsp>; +{% endfor %} {% endif %} +</p> + <div class="nodetype-content"> </div> |