def get_object_attributes(request): """ Return all attributes for obj passed. It's passed obj id and class id. """ class_id = request.POST.getlist('class_id')[0] obj_id = request.POST.getlist('obj_id')[0] if (obj_id): cls_obj = views_kb.object_get(request, request.session['workspace'].pk, obj_id) cls_obj = simplejson.loads(cls_obj.content) cls_dicts = views_kb.class_get(request, request.session['workspace'].pk, class_id) cls_dicts = simplejson.loads(cls_dicts.content) rtr = {"rows": []} for attribute in cls_dicts['attributes']: tmp = {} tmp['id'] = attribute if (obj_id): tmp['value'] = cls_obj['attributes'][attribute] else: tmp['value'] = None for specific_field in cls_dicts['attributes'][attribute]: tmp[specific_field] = cls_dicts['attributes'][attribute][ specific_field] rtr['rows'].append(tmp) resp = simplejson.dumps(rtr) return HttpResponse(resp)
def get_object_attributes(request): """ Return all attributes for obj passed. It's passed obj id and class id. """ class_id = request.POST.getlist('class_id')[0] obj_id = request.POST.getlist('obj_id')[0] if (obj_id): cls_obj = views_kb.object_get(request, request.session['workspace'].pk,obj_id) cls_obj = simplejson.loads(cls_obj.content) cls_dicts = views_kb.class_get(request, request.session['workspace'].pk,class_id) cls_dicts = simplejson.loads(cls_dicts.content) rtr = {"rows":[]} for attribute in cls_dicts['attributes']: tmp = {} tmp['id'] = attribute if (obj_id): tmp['value'] = cls_obj['attributes'][attribute] else: tmp['value'] = None for specific_field in cls_dicts['attributes'][attribute]: tmp[specific_field] = cls_dicts['attributes'][attribute][specific_field] rtr['rows'].append(tmp) resp = simplejson.dumps(rtr) return HttpResponse(resp)
def get_specific_info_class(request, class_id): """ Return all class information. """ cls_dicts = views_kb.class_get(request, request.session['workspace'].pk,class_id) cls_dicts = simplejson.loads(cls_dicts.content) rtr = {"rows":[]} rtr['rows'].append(cls_dicts) resp = simplejson.dumps(rtr) return HttpResponse(resp)
def get_specific_info_class(request, class_id): """ Return all class information. """ cls_dicts = views_kb.class_get(request, request.session['workspace'].pk, class_id) cls_dicts = simplejson.loads(cls_dicts.content) rtr = {"rows": []} rtr['rows'].append(cls_dicts) resp = simplejson.dumps(rtr) return HttpResponse(resp)
def get_class_attributes(request, class_id): """ Return all attributes for class passed. It's passed the class id. """ cls_dicts = views_kb.class_get(request, request.session['workspace'].pk,class_id) cls_dicts = simplejson.loads(cls_dicts.content) rtr = {"rows":[]} for attribute in cls_dicts['attributes']: tmp = {} tmp['id'] = attribute for specific_field in cls_dicts['attributes'][attribute]: tmp[specific_field] = cls_dicts['attributes'][attribute][specific_field] rtr['rows'].append(tmp) resp = simplejson.dumps(rtr) return HttpResponse(resp)
def get_class_attributes(request, class_id): """ Return all attributes for class passed. It's passed the class id. """ cls_dicts = views_kb.class_get(request, request.session['workspace'].pk, class_id) cls_dicts = simplejson.loads(cls_dicts.content) rtr = {"rows": []} for attribute in cls_dicts['attributes']: tmp = {} tmp['id'] = attribute for specific_field in cls_dicts['attributes'][attribute]: tmp[specific_field] = cls_dicts['attributes'][attribute][ specific_field] rtr['rows'].append(tmp) resp = simplejson.dumps(rtr) return HttpResponse(resp)