Exemplo n.º 1
0
 def create(self, request, key_value_id=None):
     if 'system_id' in request.POST:
         n = KeyValue()
         system = System.objects.get(id=request.POST['system_id'])
         n.system = system
         if 'key' in request.POST:
             n.key = request.POST['key']
         if 'value' in request.POST:
             n.value = request.POST['value']
         try:
             n.save()
             resp = rc.ALL_OK
             resp.write('json = {"id":%i}' % (n.id))
         except:
             resp = rc.NOT_FOUND
             resp.write('Unable to Create Key/Value Pair')
         return resp
     if 'truth_name' in request.POST:
         n = TruthKeyValue()
         truth = Truth.objects.get(name=request.POST['truth_name'])
         n.truth = truth
         if 'key' in request.POST:
             n.key = request.POST['key']
         if 'value' in request.POST:
             n.value = request.POST['value']
         try:
             n.save()
             resp = rc.ALL_OK
             resp.write('json = {"id":%i}' % (n.id))
         except:
             resp = rc.NOT_FOUND
             resp.write('Unable to Create Key/Value Pair')
         return resp
 def create(self, request, key_value_id=None):
     if 'system_id' in request.POST:
         n = KeyValue()
         system = System.objects.get(id=request.POST['system_id'])
         n.system = system
         if 'key' in request.POST:
             n.key = request.POST['key']
         if 'value' in request.POST:
             n.value = request.POST['value']
         try:
             n.save()
             resp = rc.ALL_OK
             resp.write('json = {"id":%i}' % (n.id))
         except:
             resp = rc.NOT_FOUND
             resp.write('Unable to Create Key/Value Pair')
         return resp
     if 'truth_name' in request.POST:
         n = TruthKeyValue()
         truth = Truth.objects.get(name=request.POST['truth_name'])
         n.truth = truth
         if 'key' in request.POST:
             n.key = request.POST['key']
         if 'value' in request.POST:
             n.value = request.POST['value']
         try:
             n.save()
             resp = rc.ALL_OK
             resp.write('json = {"id":%i}' % (n.id))
         except:
             resp = rc.NOT_FOUND
             resp.write('Unable to Create Key/Value Pair')
         return resp