def protoGetFieldTree(request): """ return full field tree """ if request.method != 'POST': return JsonError('Invalid message') viewCode = request.POST.get('viewCode', '') viewEntity = getBaseModelName(viewCode) try: model = getDjangoModel(viewEntity) except Exception as e: return JsonError(getReadableError(e)) fieldList = [] if viewCode.startswith(PROTO_PREFIX) and viewCode != viewEntity : # --------------------------------------------------- Prototipos protoEntityId = request.POST.get('protoEntityId') if not protoEntityId >= 0: return JsonError('invalid idEntity') try: from prototype.actions.viewDefinition import GetProtoFieldsTree fieldList = GetProtoFieldsTree(protoEntityId) except: return JsonError('invalid idEntity') else: # ----------------------------------------------------------------------------------------------------- # Se crean los campos con base al modelo ( trae todos los campos del modelo # for field in model._meta._fields(): # only for django 1.4 for field in model._meta.fields: try: addFiedToList(fieldList, field , '') except Exception as e: traceback.print_exc() return JsonError(getReadableError(e)) # Add __str__ myField = { 'id' : '__str__' , 'text' : '__str__' , 'checked' : False, 'leaf' : True } # Defaults values setDefaultField(myField, model , viewCode) # FormLink redefinition to original view # myField['zoomModel'] = viewCode fieldList.append(myField) # Codifica el mssage json context = json.dumps(fieldList) return HttpResponse(context, content_type="application/json")
def protoGetDetailsTree(request): """ return full field tree """ if not request.user.is_authenticated(): return JsonError('readOnly User') if request.method != 'POST': return JsonError('invalid message') viewCode = request.POST.get('viewCode', '') viewEntity = getBaseModelName(viewCode) try: model = getDjangoModel(viewEntity) except Exception, e: jsondict = {'success': False, 'message': getReadableError(e)} context = json.dumps(jsondict) return HttpResponse(context, content_type="application/json")
def protoGetDetailsTree(request): """ return full field tree """ if not request.user.is_authenticated(): return JsonError('readOnly User') if request.method != 'POST': return JsonError( 'invalid message' ) viewCode = request.POST.get('viewCode', '') viewEntity = getBaseModelName( viewCode ) try: model = getDjangoModel(viewEntity) except Exception, e: jsondict = { 'success':False, 'message': getReadableError( e ) } context = json.dumps( jsondict) return HttpResponse(context, content_type="application/json")
def getReportBase( viewCode ): viewEntity = getBaseModelName( viewCode ) # Obtiene el modelo try: model = getDjangoModel(viewEntity) except Exception as e: pass # Obtiene la definicion try: protoDef = ProtoDefinition.objects.get (code = viewCode ) protoMeta = json.loads( protoDef.metaDefinition ) except Exception as e: pass # hace el QSet de los registros seleccionados Qs = model.objects.select_related(depth=1) return protoMeta, Qs
def getReportBase( viewCode ): viewEntity = getBaseModelName( viewCode ) # Obtiene el modelo try: model = getDjangoModel(viewEntity) except Exception as e : pass # Obtiene la definicion try: protoDef = ProtoDefinition.objects.get (code = viewCode ) protoMeta = json.loads( protoDef.metaDefinition ) except Exception as e : pass # hace el QSet de los registros seleccionados Qs = model.objects.select_related() return protoMeta, Qs
def protoExecuteAction(request): """ Ejecuta una opcion """ def doWfAction(model, selectedKeys, parameters, actionDef, viewEntity, pUser): userProfile = getUserProfile(pUser, 'wflow', viewEntity) try: changeSt = actionDef.get('change', []) stInitial = changeSt[0] stFinal = changeSt[1] Qs = model.objects.filter(pk__in=selectedKeys) Qs = Qs.filter(smWflowStatus=stInitial) # TODO transaction??? if actionDef.get('notifyOwner', False): for wfRow in Qs: if len(parameters) > 0: strMsg = parameters[0].get('value') else: strMsg = actionDef.get('message', '') UserReponse = WflowUserReponse() UserReponse.viewEntity = viewEntity UserReponse.strKey = wfRow.__str__() UserReponse.wfAction = actionDef.get('name') UserReponse.adminMsg = strMsg try: setattr(UserReponse, 'smOwningUser', wfRow.smOwningUser) setattr(UserReponse, 'smOwningTeam', wfRow.smOwningTeam) setattr(UserReponse, 'smCreatedBy', userProfile.user) setattr(UserReponse, 'smRegStatus', '0') setattr(UserReponse, 'smCreatedOn', datetime.now()) except: pass UserReponse.save() if actionDef.get('emailNotification', False): user = User.objects.get( username=wfRow.smOwningUser.username) if user.email: try: subject = actionDef.get('emailSubject', '') message = actionDef.get('emailTemplate', '') variableFormat = { 'sk': wfRow.__str__(), 'concept': viewEntity, 'admmessage': strMsg, 'admin': userProfile.user.username.title(), 'date': strftime('%d/%m/%Y', wfRow.smCreatedOn.timetuple()), 'User': wfRow.smOwningUser.username.title() } message = message.format(**variableFormat) user.email_user(subject, message) except: pass if actionDef.get('setOwner', False): Qs.update(smWflowStatus=stFinal, smOwningTeam=userProfile.userTeam) else: Qs.update(smWflowStatus=stFinal) return doReturn({'success': True, 'message': 'WfAction Ok'}) except Exception as e: return doReturn({'success': False, 'message': str(e)}) # ---------------------------------------- def doAdminAction(model, selectedKeys, parameters, actionDef, modelAdmin): for action in modelAdmin.actions: if action.__name__ == actionName: break if not action: return doReturn({'success': False, 'message': 'Action notFound'}) Qs = model.objects.select_related() Qs = Qs.filter(pk__in=selectedKeys) try: returnObj = action(modelAdmin, request, Qs, parameters) return doReturn(returnObj) except Exception as e: return doReturn({'success': False, 'message': str(e)}) # ---------------------------------------- def doAdminDetailAction(model, selectedKeys, detKeys, parameters, actionDef, modelAdmin): for action in modelAdmin.actions: if action.__name__ == actionName: break if not action: return doReturn({'success': False, 'message': 'Action notFound'}) try: returnObj = action(modelAdmin, request, selectedKeys, detKeys, parameters) return doReturn(returnObj) except Exception as e: return doReturn({'success': False, 'message': str(e)}) # ---------------------------------------- if not request.user.is_authenticated(): return doReturn({'success': False, 'message': 'readOnly User'}) if request.method != 'POST': return doReturn({'success': False, 'message': 'PostAction required'}) actionName = request.POST.get('actionName', '') viewCode = request.POST.get('viewCode', '') viewEntity = getBaseModelName(viewCode) selectedKeys = request.POST.get('selectedKeys', []) selectedKeys = json.loads(selectedKeys) parameters = request.POST.get('parameters', []) parameters = json.loads(parameters) actionDef = request.POST.get('actionDef', {}) actionDef = json.loads(actionDef) # hace el QSet de los registros seleccionados if actionDef.get('selectionMode', '') != 'none' and selectedKeys.__len__() == 0: return doReturn({'success': False, 'message': 'No record selected'}) # Obtiene el modelo try: model = getDjangoModel(viewEntity) modelAdmin = site._registry.get(model) except: return doReturn({'success': False, 'message': 'Model notFound'}) # details if actionDef.get('selectionMode', '') == 'details': detKeys = request.POST.get('detKeys', {}) detKeys = json.loads(detKeys) return doAdminDetailAction(model, selectedKeys, detKeys, parameters, actionDef, modelAdmin) elif actionDef.get('actionType', '') == 'wflow': return doWfAction(model, selectedKeys, parameters, actionDef, viewEntity, request.user) elif hasattr(modelAdmin, 'actions'): return doAdminAction(model, selectedKeys, parameters, actionDef, modelAdmin) else: return doReturn({'success': False, 'message': 'Action notFound'}) # ----------------------------------------
def protoGetPCI(request): """ return full metadata (columns, renderers, totalcount...) """ if not request.user.is_authenticated(): return JsonError('readOnly User') if request.method != 'POST': return JsonError('invalid message') viewCode = request.POST.get('viewCode', '') viewEntity = getBaseModelName(viewCode) try: model = getDjangoModel(viewEntity) except : return JsonError('model not found: {0}'.format( viewEntity)) # userProfile = getUserProfile(request.user, 'getPci', viewEntity) # PROTOTIPOS isPrototype = False if viewCode.startswith(PROTO_PREFIX) and viewCode != viewEntity : try: prototypeView = viewCode.replace(PROTO_PREFIX, '') protoDef = Prototype.objects.get(code=prototypeView, smOwningTeam=userProfile.userTeam) created = False isPrototype = True except: return JsonError('prototype not found: {0}'.format( viewCode )) else: # protoDef : PCI leida de la DB ; created : El objeto es nuevo protoDef, created = ProtoDefinition.objects.get_or_create(code=viewCode) if ( not isPrototype ) : # if ( not protoDef.active) : # return JsonError('Inactive definition : {0}'.format( viewCode )) if protoDef.overWrite : # Si la directiva es reescribirlo es como si fuera nuevo cada vez created = True # Si es nuevo lee Django if created : model_admin, protoMeta = getProtoAdmin(model) # Genera la definicion de la vista grid = protoGrid.ProtoGridFactory(model, viewCode, model_admin, protoMeta) if not createProtoMeta(model, grid, viewEntity, viewCode) : return JsonError('Document type required: {0}.???'.format( viewCode )) # Guarda o refresca la Meta y mantiene la directiva overWrite protoDef.metaDefinition = json.dumps(grid.protoMeta) protoDef.description = protoMeta['description'] protoDef.save() else: protoMeta = json.loads(protoDef.metaDefinition) protoMeta['viewCode'] = viewCode # La definicion del arbol es fija, pues las cols deben ser siempre uniformes sin importar el tipo de modelo. # pStyle = protoMeta.get( 'pciStyle', '') # if pStyle == 'tree': setTreeDefinition() customCode = '_custom.' + viewCode try: custom = CustomDefinition.objects.get(code=customCode, smOwningTeam=userProfile.userTeam) custom = json.loads(custom.metaDefinition) protoMeta['custom'] = custom['custom'] except: pass # TODO: Verificacion de la metadata # try: # protoMeta = verifyMeta(protoMeta, 'pcl') # except Exception, e: # traceback.print_exc() # message = getReadableError(e) # WorkFlow if hasattr(model , '_WorkFlow') : wflowControl = getattr(model, '_WorkFlow', {}) if request.user.is_superuser or getModelPermissions(request.user , model, 'wfadmin') : protoMeta['WFlowActions'] = wflowControl.get('transitions', []) wfFilterSet = wflowControl.get('wfFilters', []) if len(wfFilterSet) > 0: protoMeta['gridSets'] = protoMeta.get('gridSets', {}) protoMeta['gridSets']['filtersSet'] = wfFilterSet for lFilter in wfFilterSet: lFilter['customFilter'] = [{ "property": "smWflowStatus", "filterStmt": lFilter[ 'wfStatus'] }] jsondict = { 'success':True, 'message': '', 'metaData':{ # The name of the property which contains the Array of row objects. ... 'root': 'rows', # Name of the property within a row object that contains a record identifier value. ... 'idProperty': protoMeta['idProperty'], # Name of the property from which to retrieve the total number of records in t 'totalProperty':'totalCount', # Name of the property from which to retrieve the success attribute. ... 'successProperty':'success', # The name of the property which contains a response message. (optional) 'messageProperty': 'message', }, 'protoMeta': protoMeta, 'permissions': getModelPermissions(request.user, model), 'rows':[], 'totalCount': 0, } # Codifica el mssage json context = json.dumps(jsondict) return HttpResponse(context, content_type="application/json")
def protoSaveProtoObj(request): """ Save full metadata * objetos del tipo _XXX se guardan siempre en CustomDefinition * objetos del tipo prototype.protoTable se guardan siempre en Prototype * Solo los adminstradores tienen el derecho de guardar pcls custom : Los objetos de tipo custom, manejan la siguiente llave _ColSet.[viewCode] listDisplaySet _QrySet.[viewCode] filterSet _menu Para manejar el modelo en las generacion de protoPci's se usa : prototype.protoTable.[protoModel-viewCode] --> al leer la pcl se leera prototype.protoTable.[protoModel-viewCode] """ if request.method != 'POST': return JsonError('invalid message') custom = False prototype = False create = False viewCode = request.POST.get('viewCode', '') userProfile = getUserProfile(request.user, 'saveObjs', viewCode) # Reglas para definir q se guarda if viewCode.find('_') == 0 : custom = True if viewCode.startswith(PROTO_PREFIX) : prototype = True # Carga la meta sMeta = request.POST.get('protoMeta', '') # Es customProperty if custom: try: protoDef, create = CustomDefinition.objects.get_or_create(code=viewCode, smOwningTeam=userProfile.userTeam) except Exception as e: return JsonError(getReadableError(e)) # Es prototype elif prototype: try: # debe existir previamente protoCode = viewCode.replace(PROTO_PREFIX, '') protoMeta = json.loads(sMeta) entityId = protoMeta['protoEntityId'] entityObj = Entity.objects.get(id=entityId) protoDef, create = Prototype.objects.get_or_create(code=protoCode, entity=entityObj, smOwningTeam=userProfile.userTeam) except Exception as e: return JsonError(getReadableError(e)) else: # Verifica los permisos viewEntity = getBaseModelName(viewCode) model = getDjangoModel(viewEntity) if not getModelPermissions(request.user, model, 'config') : return JsonError('permission denied') try: protoDef = ProtoDefinition.objects.get_or_create(code=viewCode)[0] except Exception as e: return JsonError(getReadableError(e)) protoDef.active = True protoDef.overWrite = False # borra el custom por q confunde haecer modif en un lado y otro try: CustomDefinition.objects.filter(code='_custom.' + viewCode, smOwningTeam=userProfile.userTeam).delete() except: pass if custom or prototype: setSecurityInfo(protoDef, {}, userProfile, create) protoDef.metaDefinition = sMeta protoDef.save() return JsonSuccess({ 'message': 'Ok' })
def protoGetPCI(request): """ return full metadata (columns, renderers, totalcount...) """ if not request.user.is_authenticated(): return JsonError('readOnly User') if request.method != 'POST': return JsonError('invalid message') viewCode = request.POST.get('viewCode', '') viewEntity = getBaseModelName(viewCode) try: model = getDjangoModel(viewEntity) except : return JsonError('model not found:' + viewEntity) # userProfile = getUserProfile(request.user, 'getPci', viewEntity) # PROTOTIPOS if viewCode.startswith(PROTO_PREFIX) and viewCode != viewEntity : try: prototypeView = viewCode.replace(PROTO_PREFIX, '') protoDef = Prototype.objects.get(code=prototypeView, smOwningTeam=userProfile.userTeam) created = False except: jsondict = { 'success':False, 'message': viewCode + ' notFound' } return HttpResponse(json.dumps(jsondict), content_type="application/json") else: # created : El objeto es nuevo # protoDef : PCI leida de la DB protoDef, created = ProtoDefinition.objects.get_or_create(code=viewCode) # Verifica si es una version vieja if created: protoDef.overWrite = True # active solo viene de protoDefinition try: active = protoDef.active except: active = True # Si es nuevo o no esta activo lee Django if created or (not active) : model_admin, protoMeta = getProtoAdmin(model) version = protoMeta.get('metaVersion') # La version determina q es una carga completa de la meta y no es necesario reconstruirla # solo en caso de q la definicion no este en la Db if (version is None) or (version < PROTOVERSION): # Verifica si existe una propiedad ProtoMeta es la copia de la meta cargada a la Db, grid = protoGrid.ProtoGridFactory(model, viewCode, model_admin, protoMeta) protoMeta = createProtoMeta(model, grid, viewEntity, viewCode) # Guarda la Meta si es nuevo o si se especifica overWrite if created or protoDef.overWrite: protoDef.metaDefinition = json.dumps(protoMeta) protoDef.description = protoMeta['description'] protoDef.save() else: protoMeta = json.loads(protoDef.metaDefinition) protoMeta['viewCode'] = viewCode # La definicion del arbol es fija, pues las cols deben ser siempre uniformes sin importar el tipo de modelo. # pStyle = protoMeta.get( 'pciStyle', '') # if pStyle == 'tree': setTreeDefinition() customCode = '_custom.' + viewCode try: custom = CustomDefinition.objects.get(code=customCode, smOwningTeam=userProfile.userTeam) custom = json.loads(custom.metaDefinition) protoMeta['custom'] = custom['custom'] except: pass # TODO: Verificacion de la metadata # try: # protoMeta = verifyMeta(protoMeta, 'pcl') # except Exception, e: # traceback.print_exc() # message = getReadableError(e) # WorkFlow if hasattr(model , '_WorkFlow') : wflowControl = getattr(model, '_WorkFlow', {}) if request.user.is_superuser or getModelPermissions(request.user , model, 'wfadmin') : protoMeta['WFlowActions'] = wflowControl.get('transitions', []) wfFilterSet = wflowControl.get('wfFilters', []) if len(wfFilterSet) > 0: protoMeta['gridSets'] = protoMeta.get('gridSets', {}) protoMeta['gridSets']['filtersSet'] = wfFilterSet for lFilter in wfFilterSet: lFilter['customFilter'] = [{ "property": "smWflowStatus", "filterStmt": lFilter[ 'wfStatus'] }] jsondict = { 'success':True, 'message': '', 'metaData':{ # The name of the property which contains the Array of row objects. ... 'root': 'rows', # Name of the property within a row object that contains a record identifier value. ... 'idProperty': protoMeta['idProperty'], # Name of the property from which to retrieve the total number of records in t 'totalProperty':'totalCount', # Name of the property from which to retrieve the success attribute. ... 'successProperty':'success', # The name of the property which contains a response message. (optional) 'messageProperty': 'message', }, 'protoMeta': protoMeta, 'permissions': getModelPermissions(request.user, model), 'rows':[], 'totalCount': 0, } # Codifica el mssage json context = json.dumps(jsondict) return HttpResponse(context, content_type="application/json")
def protoExecuteAction(request): """ Ejecuta una opcion """ def doWfAction(model, selectedKeys, parameters, actionDef, viewEntity, pUser): userProfile = getUserProfile(pUser, 'wflow', viewEntity) try: changeSt = actionDef.get('change', []) stInitial = changeSt[0] stFinal = changeSt[1] Qs = model.objects.filter(pk__in=selectedKeys) Qs = Qs.filter(smWflowStatus=stInitial) # TODO transaction??? if actionDef.get('notifyOwner', False) : for wfRow in Qs : if len (parameters) > 0: strMsg = parameters[0].get('value') else : strMsg = actionDef.get('message', '') UserReponse = WflowUserReponse() UserReponse.viewEntity = viewEntity UserReponse.strKey = wfRow.__str__() UserReponse.wfAction = actionDef.get('name') UserReponse.adminMsg = strMsg try: setattr(UserReponse, 'smOwningUser', wfRow.smOwningUser ) setattr(UserReponse, 'smOwningTeam', wfRow.smOwningTeam ) setattr(UserReponse, 'smCreatedBy', userProfile.user) setattr(UserReponse, 'smRegStatus', '0') setattr(UserReponse, 'smCreatedOn', datetime.now()) except : pass UserReponse.save() if actionDef.get('setOwner', False) : Qs.update(smWflowStatus=stFinal, smOwningTeam=userProfile.userTeam) else : Qs.update(smWflowStatus=stFinal) return doReturn ({'success':True, 'message' : 'WfAction Ok'}) except Exception as e: return doReturn ({'success':False, 'message' : str(e) }) # ---------------------------------------- def doAdminAction(model, selectedKeys, parameters, actionDef, modelAdmin): for action in modelAdmin.actions: if action.__name__ == actionName: break; if not action: return doReturn ({'success':False, 'message' : 'Action notFound'}) Qs = model.objects.select_related(depth=1) Qs = Qs.filter(pk__in=selectedKeys) try: returnObj = action(modelAdmin, request, Qs , parameters) return doReturn (returnObj) except Exception as e: return doReturn ({'success':False, 'message' : str(e) }) # ---------------------------------------- if not request.user.is_authenticated(): return doReturn ({'success':False , 'message' : 'readOnly User'}) if request.method != 'POST': return doReturn ({'success':False , 'message' : 'PostAction required'}) actionName = request.POST.get('actionName', '') viewCode = request.POST.get('viewCode', '') viewEntity = getBaseModelName(viewCode) selectedKeys = request.POST.get('selectedKeys', []) selectedKeys = json.loads(selectedKeys) parameters = request.POST.get('parameters', []) parameters = json.loads(parameters) actionDef = request.POST.get('actionDef', {}) actionDef = json.loads(actionDef) # hace el QSet de los registros seleccionados if actionDef.get('selectionMode', '') != 'none' and selectedKeys.__len__() == 0: return doReturn ({'success':False, 'message' : 'No record selected'}) # Obtiene el modelo try: model = getDjangoModel(viewEntity) modelAdmin = site._registry.get(model) except : return doReturn ({'success':False, 'message' : 'Model notFound'}) if actionDef.get('actionType', '') == 'wflow': return doWfAction(model, selectedKeys, parameters, actionDef, viewEntity, request.user) elif hasattr(modelAdmin, 'actions'): return doAdminAction (model, selectedKeys, parameters, actionDef, modelAdmin) else: return doReturn ({'success':False, 'message' : 'Action notFound'})
def protoGetPCI(request): """ return full metadata (columns, renderers, totalcount...) """ if not request.user.is_authenticated(): return JsonError('readOnly User') if request.method != 'POST': return JsonError( 'invalid message' ) viewCode = request.POST.get('viewCode', '') viewEntity = getBaseModelName( viewCode ) try: model = getDjangoModel(viewEntity) except : return JsonError( 'model not found:' + viewEntity ) # userProfile = getUserProfile( request.user, 'getPci', viewEntity ) # PROTOTIPOS if viewCode.startswith( PROTO_PREFIX ) and viewCode != viewEntity : try: prototypeView = viewCode.replace( PROTO_PREFIX, '') protoDef = Prototype.objects.get(code = prototypeView, smOwningTeam = userProfile.userTeam ) created = False except: jsondict = { 'success':False, 'message': viewCode + ' notFound' } return HttpResponse( json.dumps( jsondict), mimetype="application/json") else: # created : El objeto es nuevo # protoDef : PCI leida de la DB protoDef, created = ProtoDefinition.objects.get_or_create(code = viewCode ) # Verifica si es una version vieja if created: protoDef.overWrite = True # else: # protoMeta = json.loads( protoDef.metaDefinition ) # version = protoMeta.get( 'metaVersion' ) # if ( version is None ) or ( version < PROTOVERSION ): # created = True # active solo viene de protoDefinition try: active = protoDef.active except: active = True # Si es nuevo o no esta activo lee Django if created or ( not active ) : model_admin, protoMeta = getProtoAdmin( model ) version = protoMeta.get( 'metaVersion' ) # La version determina q es una carga completa de la meta y no es necesario reconstruirla # solo en caso de q la definicion no este en la Db if ( version is None ) or ( version < PROTOVERSION ): # Verifica si existe una propiedad ProtoMeta es la copia de la meta cargada a la Db, grid = protoGrid.ProtoGridFactory( model, viewCode, model_admin, protoMeta ) protoMeta = createProtoMeta( model, grid, viewEntity, viewCode ) # Guarda la Meta si es nuevo o si se especifica overWrite if created or protoDef.overWrite: protoDef.metaDefinition = json.dumps( protoMeta ) protoDef.description = protoMeta['description'] protoDef.save() else: protoMeta = json.loads( protoDef.metaDefinition ) protoMeta['viewCode'] = viewCode # La definicion del arbol es fija, pues las cols deben ser siempre uniformes sin importar el tipo de modelo. # pStyle = protoMeta.get( 'pciStyle', '') # if pStyle == 'tree': setTreeDefinition() customCode = '_custom.' + viewCode try: custom = CustomDefinition.objects.get(code = customCode, smOwningTeam = userProfile.userTeam ) custom = json.loads( custom.metaDefinition ) protoMeta['custom'] = custom['custom'] except: pass # WorkFlow if hasattr( model , '_WorkFlow' ) : wflowControl = getattr( model, '_WorkFlow', {} ) if request.user.is_superuser or getModelPermissions( request.user , model, 'wfadmin' ) : protoMeta['WFlowActions'] = wflowControl.get( 'transitions', [] ) wfFilterSet = wflowControl.get( 'wfFilters', [] ) if len( wfFilterSet ) > 0: protoMeta['gridSets'] = protoMeta.get('gridSets', {}) protoMeta['gridSets']['filtersSet'] = wfFilterSet for lFilter in wfFilterSet: lFilter['customFilter'] = [{ "property": "smWflowStatus", "filterStmt": lFilter[ 'wfStatus'] }] jsondict = { 'success':True, 'message': '', 'metaData':{ # The name of the property which contains the Array of row objects. ... 'root': 'rows', #Name of the property within a row object that contains a record identifier value. ... 'idProperty': protoMeta['idProperty'], #Name of the property from which to retrieve the total number of records in t 'totalProperty':'totalCount', #Name of the property from which to retrieve the success attribute. ... 'successProperty':'success', #The name of the property which contains a response message. (optional) 'messageProperty': 'message', }, 'protoMeta': protoMeta, 'permissions': getModelPermissions( request.user, model ), 'rows':[], 'totalCount': 0, } # Codifica el mssage json context = json.dumps( jsondict) return HttpResponse(context, mimetype="application/json")