summaryrefslogtreecommitdiff
path: root/gstudio
diff options
context:
space:
mode:
authorcsitifr <csitifr@gmail.com>2012-05-28 18:40:43 +0530
committercsitifr <csitifr@gmail.com>2012-05-28 18:40:43 +0530
commitf28648fce9a224b6f4c3a24cfaf4b29082dbb775 (patch)
treeb15ab0641c907405928c7997d3bc0a3f2c1d52d9 /gstudio
parent15c2f2561c23a656d792003b089e28ecc500b720 (diff)
downloadgnowsys-f28648fce9a224b6f4c3a24cfaf4b29082dbb775.tar.gz
Relation can be now saved and viewed hierachy wise.Attribute does not get saved in duplicate
Diffstat (limited to 'gstudio')
-rw-r--r--gstudio/models.py73
-rw-r--r--gstudio/templates/gstudio/nodetype_detail.html3
2 files changed, 51 insertions, 25 deletions
diff --git a/gstudio/models.py b/gstudio/models.py
index 5b5cf42..d4cdc5f 100644
--- a/gstudio/models.py
+++ b/gstudio/models.py
@@ -288,36 +288,61 @@ class NID(models.Model):
@property
def getat(self):
+
"""This is will give the possible attributetypes """
try:
+ pt = []
attributetype = []
- ot = self.ref
- attributetype.append(ot.subjecttype_of.all())
+ returndict = {}
+
+ pt.append(self.ref)
+ obj = self.ref
+ while obj.parent:
+ pt.append((obj.parent).ref)
+ obj=obj.parent
+
+ for each in pt:
+ attributetype.append(each.subjecttype_of.all())
+
attributetype = [num for elem in attributetype for num in elem]
- return attributetype
+
+ for i in attributetype:
+ if str(i.applicable_nodetypes) == 'OT':
+ returndict.update({str(i.title):i.id})
+
+ return returndict.keys()
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 =[] 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 =[]
+ reltype =[]
+ titledict = {}
+ inverselist = []
+ finaldict = {}
+ listval=[]
+
pt.append(self.ref)
+ obj = self.ref
+ while obj.parent:
+ pt.append((obj.parent).ref)
+ obj=obj.parent
+
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})
@@ -325,16 +350,16 @@ class NID(models.Model):
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]})
+ if pt[j].id == listval[i].left_subjecttype_id and str(listval[i].left_applicable_nodetypes) == 'OT' :
+ finaldict.update({titledict.keys()[i]:titledict.values()[i]})
+ if pt[j].id == listval[i].right_subjecttype_id and str(listval[i].right_applicable_nodetypes)=='OT':
+ finaldict.update({inverselist[i]:titledict.values()[i]})
+
- return finaldict.values()
+ return finaldict.keys()
@property
@@ -1959,7 +1984,7 @@ class AttributeTimeField(Attribute):
class AttributeEmailField(Attribute):
- value = models.CharField(max_length=100,verbose_name='value')
+ value = models.EmailField(max_length=100,verbose_name='value')
def __unicode__(self):
return self.title
@@ -1975,7 +2000,7 @@ class AttributeEmailField(Attribute):
class AttributeFileField(Attribute):
- value = models.FileField(upload_to='/media', verbose_name='file')
+ value = models.FileField(upload_to='media/'+UPLOAD_TO, verbose_name='file')
def __unicode__(self):
return self.title
@@ -2009,7 +2034,7 @@ class AttributeFilePathField(Attribute):
class AttributeImageField(Attribute):
- value = models.ImageField(upload_to='/media', verbose_name='image')
+ value = models.ImageField(upload_to='media/'+UPLOAD_TO, verbose_name='image')
def __unicode__(self):
return self.title
diff --git a/gstudio/templates/gstudio/nodetype_detail.html b/gstudio/templates/gstudio/nodetype_detail.html
index 7947e58..1a01279 100644
--- a/gstudio/templates/gstudio/nodetype_detail.html
+++ b/gstudio/templates/gstudio/nodetype_detail.html
@@ -250,6 +250,7 @@
{% endblock %}
<!-- Dynamic form begins -->
+{% if user.is_authenticated %}
<p>
{% if object.reftype == 'Objecttype' %}
<b>Add Attributes:</b>
@@ -264,7 +265,7 @@
<a href="{{ get_absolute_url }}/objects/dynamicRelation/displaymem/{{ i }}/{{ object.title }}">{{ i }}</a><nbsp>;
{% endfor %}
{% endif %}
-
+{% endif %}
</p>
<!-- Dyanic form ends -->
<div class="nodetype-content">