summaryrefslogtreecommitdiff
path: root/objectapp/views
diff options
context:
space:
mode:
authorcsitifr <csitifr@gmail.com>2012-05-29 14:26:38 +0530
committercsitifr <csitifr@gmail.com>2012-05-29 14:26:38 +0530
commit4d22607dafd55abee1b993cf55dad74a1eeb323f (patch)
tree2b977d4d8338a2df3687ed00e9e8e9595a98cec9 /objectapp/views
parent67fe49b1dddd01ed94962716b67992c1e3db03ce (diff)
downloadgnowsys-4d22607dafd55abee1b993cf55dad74a1eeb323f.tar.gz
includes condition for checking duplicate attributes
Diffstat (limited to 'objectapp/views')
-rw-r--r--objectapp/views/dynamicAT.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/objectapp/views/dynamicAT.py b/objectapp/views/dynamicAT.py
index a5d71de9..43ddab56 100644
--- a/objectapp/views/dynamicAT.py
+++ b/objectapp/views/dynamicAT.py
@@ -11,17 +11,13 @@ from objectapp.forms import *
from gstudio.models import *
from gstudio.admin.forms import *
+
def MakeForm(model_cls, *args, **kwargs):
class ContextForm(ModelForm):
class Meta:
model = model_cls.values()[0]
- print 'model' ,model
fields = ('value',)
- print 'fields',fields
-
- def __init__(self, *args, **kwargs):
-
- super(ContextForm,self).__init__(*args, **kwargs)
+
return ContextForm(*args, **kwargs)
@@ -39,17 +35,23 @@ def dynamic_save(request, attit, memtit):
at = Attributetype.objects.get(title = str(attit))
dt = str(at.get_dataType_display())
MyModel = eval('Attribute'+dt)
-
+
+ print getattr(models , dt)
+
+ list1 = []
+
rdict.update({str(at.title):MyModel})
+
print "rdict",str(rdict)
+ print 'dt ',dt
if request.method == 'POST':
form = MakeForm(rdict,request.POST,request.FILES)
try:
if form.is_valid():
value = form.cleaned_data['value']
-
- if Attribute.objects.filter(subject = memtit.id) and Attribute.objects.filter(attributetype = at.id):
+
+ if Attribute.objects.filter(subject = memtit.id , attributetype = at.id):
att = Attribute.objects.get(subject = memtit.id, attributetype = at.id)
att.delete()
del att
@@ -72,7 +74,7 @@ def dynamic_save(request, attit, memtit):
template = "objectapp/fillAT.html"
- context = RequestContext(request,{'form' : form,'title':str(attit), 'absolute_url_node':absolute_url_node})
+ context = RequestContext(request,{'form' : form,'title':str(attit), 'absolute_url_node':absolute_url_node, 'datatype':dt})
return render_to_response(template,context)