Exemplo n.º 1
0
def frecuencia(request, tipo):
    from trocaire.encuesta.models import FRECUENCIA2, FRECUENCIA    
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    
    if tipo == 'mujeres':
        opciones = FRECUENCIA
        titulo = u'¿Con que frecuencia ha vivido VBG este último año?'
    elif tipo == 'hombres':
        titulo = u'¿Con que frecuencia ha ejercido VBG este último año?'
        opciones = FRECUENCIA2
        
    for op in opciones:
        tabla[op[1]] = []
    
    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]
       
        for op in opciones:
            if tipo == 'mujeres':
                tabla[op[1]].append(PrevalenciaVBG.objects.filter(content_type=get_content_type(tipo), 
                                                                    object_id__in=lista, 
                                                                    frecuencia=op[0]).count())
            elif tipo == 'hombres':
                tabla[op[1]].append(PrevalenciaVBGHombre.objects.filter(content_type=get_content_type(tipo), 
                                                                    object_id__in=lista, 
                                                                    frecuencia=op[0]).count())    
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 2
0
def _query_set_cruce(request, var1):
    if request.session['content_type'] == 'mujeres':
        resultados = _query_set_filtrado(request, 'solomujeres')
    else:
        resultados = _query_set_filtrado(request, 'solohombres')
    dicc = {}
    #decidir el app_label segun el modelo
    if TIPO_RELACION_VAR1[var1] == 'generica':
        _app_label = 'encuesta'
    elif TIPO_RELACION_VAR1[var1] == 'normal':
        _app_label = '1-principal'
    elif TIPO_RELACION_VAR1[var1] == 'rango':
        _app_label = 'encuesta'
    
    #obtener el modelo a consultar
    model = get_model(_app_label, MODELO_VAR1[var1])
        
    for op in OPCIONES_VAR1[var1]:
        #validar si el modelo es generico o normal
        if TIPO_RELACION_VAR1[var1] == 'generica':
            objs = model.objects.filter(content_type=get_content_type(request.session['content_type']),
                                        object_id__in=[encuesta.id for encuesta in resultados],
                                        ** {CAMPO_VAR1[var1]: op[0]})
            dicc[op[1]] = [obj.object_id for obj in objs]
            
        elif TIPO_RELACION_VAR1[var1] == 'normal':
            objs = model.objects.filter(id__in=[encuesta.id for encuesta in resultados],
                                        ** {CAMPO_VAR1[var1]: op[0]})
            dicc[op[1]] = [obj.id for obj in objs]
        
        elif TIPO_RELACION_VAR1[var1] == 'rango':
            params = {}
            if op == (0,0):
                key = 'No tiene'
                params['tiene_hijos'] = 'no'
            elif op == (5,5):
                key = '5+ hijos'
                params['%s__gte' % CAMPO_VAR1[var1]] = op[0]
            elif op != (5,5):
                key = '%s-%s hijos' % (op[0], op[1])
                params['%s__range' % CAMPO_VAR1[var1]] = op
                
            objs = model.objects.filter(content_type=get_content_type(request.session['content_type']),
                                        object_id__in=[encuesta.id for encuesta in resultados],
                                         ** params)
            dicc[key] = [obj.object_id for obj in objs]
                                                                                                                                      
    return dicc
Exemplo n.º 3
0
def donde_buscar_ayuda(request, tipo):
    titulo = '¿Donde debe buscar ayuda una mujer que vive VBG?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = BuscarAyuda.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]
        
        for op in opciones:
            tabla[op].append(AccionVBG.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, donde_buscar=op).count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) < 10:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 4
0
def donde_buscar_ayuda(request, tipo):
    titulo = '¿Donde debe buscar ayuda una mujer que vive VBG?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = BuscarAyuda.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(
                AccionVBG.objects.filter(content_type=get_content_type(tipo),
                                         object_id__in=lista,
                                         donde_buscar=op).count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) < 10:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)

    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 5
0
def que_acciones_realizar(request, tipo):
    titulo = "¿Cuando una mujer vive VBG cuales acciones deberia realizar?"
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = Decision.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(
                TomaDecision.objects.filter(
                    content_type=get_content_type(tipo),
                    object_id__in=lista,
                    decision=op).count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) < 10:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 6
0
def hablan_de(request, tipo='mujeres'):    
    titulo = "¿Cuando alguien le habla de VBG usted cree que le estan hablando de?"
    resultados = _query_set_filtrado(request, tipo=tipo)
    tabla = {}
    opciones = HablanDe.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]       

        for opcion in opciones:
            query = ConceptoViolencia.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, hablande=opcion, respuesta='si')
            tabla[opcion].append(query.count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) < 15:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 7
0
def vbg_resolver_con(request, tipo):
    titulo = u'¿Considera que la VBG es un asunto que debe ser resuelto con la participación de?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = ResolverVBG.objects.all()
    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(
                AsuntoPublicoVBG.objects.filter(
                    content_type=get_content_type(tipo),
                    object_id__in=lista,
                    resolverse_con=op).count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) < 10:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 8
0
def hablan_de(request, tipo='mujeres'):
    titulo = "¿Cuando alguien le habla de VBG usted cree que le estan hablando de?"
    resultados = _query_set_filtrado(request, tipo=tipo)
    tabla = {}
    opciones = HablanDe.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for opcion in opciones:
            query = ConceptoViolencia.objects.filter(
                content_type=get_content_type(tipo),
                object_id__in=lista,
                hablande=opcion,
                respuesta='si')
            tabla[opcion].append(query.count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) < 15:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 9
0
def expresion_vbg(request, tipo):
    """Vista sobre: De que manera cree usted que se expresa la VBG"""
    titulo = '¿De que manera cree usted que se expresa la VBG?'
    resultados = _query_set_filtrado(request, tipo=tipo)
    tabla = {}
    campos = [
        field for field in ExpresionVBG._meta.fields
        if field.get_internal_type() == 'CharField'
    ]
    for field in campos:
        tabla[field.verbose_name] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for field in campos:
            tabla[field.verbose_name].append(
                ExpresionVBG.objects.filter(
                    content_type=get_content_type(tipo),
                    object_id__in=lista,
                    **{
                        field.name: 'si'
                    }).count())

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 10
0
def tipo_vbg_ejercido(request, tipo):
    titulo = u"¿Qué tipo de VBG ha ejercido?"
    resultados = _query_set_filtrado(request, 'hombres')
    tabla = {}
    opciones = TipoVBG.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(
                PrevalenciaVBGHombre.objects.filter(
                    content_type=get_content_type('hombres'),
                    object_id__in=lista,
                    que_tipo=op).count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) == 0:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 11
0
def actividades_hogar(request, tipo):
    """Cuales de las siguientes actividades realiza usted en su hogar"""
    from trocaire.encuesta.models import HOGAR
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    campos = [
        field for field in Corresponsabilidad._meta.fields
        if field.get_internal_type() == 'IntegerField'
        and not field.name == 'object_id'
    ]

    for field in campos:
        tabla[field.verbose_name] = {}
        for key, grupo in resultados.items():
            lista = []
            [lista.append(encuesta.id) for encuesta in grupo]

            tabla[field.verbose_name][key] = []
            for op in HOGAR:
                tabla[field.verbose_name][key].append(
                    Corresponsabilidad.objects.filter(
                        content_type=get_content_type(tipo),
                        object_id__in=lista,
                        **{
                            field.name: op[0]
                        }).count())

    totales = get_total(resultados)
    grafico = convertir_grafico(tabla)
    tabla = get_prom_dead_list2(tabla, totales)
    return render_to_response("monitoreo/actividades_hogar.html",
                              RequestContext(request, locals()))
Exemplo n.º 12
0
def edad_personas(request, tipo='mujeres', **params):
    titulo = params['titulo']
    options = params['options']
    modelo = get_model('encuesta', params['modelo'])
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    for op in options:
        key, val = checkOpt(op, options)
        tabla[key] = []

    for key, grupo in resultados.items():
        for op in options:
            key, val = checkOpt(op, options)
            query = modelo.objects.filter(content_type=get_content_type(tipo),
                                          object_id__in=grupo.values_list(
                                              'id', flat=True))
            tabla[key].append(
                (query.aggregate(campo=Sum(val))['campo'],
                 round(query.aggregate(campo=Avg(val))['campo'], 1)))
    totales = get_total(resultados)

    return render_to_response(
        'monitoreo/generica_1.html',
        RequestContext(
            request, {
                'tabla': tabla,
                'totales': totales,
                'hide_perc': True,
                'graph_title': params['graph_title'],
                'titulo': titulo,
                'tipo': tipo
            }))
Exemplo n.º 13
0
def solucion_problema(request, tipo):
    titulo = u'¿Que se debe hacer para que la solucion a un conflicto entre la pareja sea exitoso?'
    from trocaire.encuesta.models import DES_AC
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    campos = [
        field for field in ComunicacionAsertiva._meta.fields
        if field.get_internal_type() == 'IntegerField'
        and not field.name == 'object_id'
    ]
    for field in campos:
        tabla[field.verbose_name] = {}
        for key, grupo in resultados.items():
            lista = []
            [lista.append(encuesta.id) for encuesta in grupo]

            tabla[field.verbose_name][key] = []
            for op in DES_AC:
                tabla[field.verbose_name][key].append(
                    ComunicacionAsertiva.objects.filter(
                        content_type=get_content_type(tipo),
                        object_id__in=lista,
                        **{
                            field.name: op[0]
                        }).count())

    totales = get_total(resultados)
    grafico = convertir_grafico(tabla)
    tabla = get_prom_dead_list3(tabla, totales)

    return render_to_response("monitoreo/solucion_problema.html",
                              RequestContext(request, locals()))
Exemplo n.º 14
0
def negociacion_pareja(request, tipo):
    """Que se debe hacer para que una negociacion de pareja sea exitosa"""
    titulo = u'¿Que se debe hacer para que una negociacion de pareja sea exitosa?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = NegociacionExitosa.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(
                ComunicacionAsertiva.objects.filter(
                    content_type=get_content_type(tipo),
                    object_id__in=lista,
                    negociacion_exitosa=op).count())

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 15
0
def comportamiento(request, tipo):
    """Como deben comportarse hombres y mujeres"""
    from trocaire.encuesta.models import CREENCIAS_VBG_RESP
    resultados = _query_set_filtrado(request, tipo=tipo)
    tabla = {}
    campos = [
        field for field in Creencia._meta.fields
        if field.get_internal_type() == 'IntegerField'
        and not field.name == 'object_id'
    ]

    for field in campos:
        tabla[field.verbose_name] = {}
        for key, grupo in resultados.items():
            lista = []
            [lista.append(encuesta.id) for encuesta in grupo]

            tabla[field.verbose_name][key] = []
            for op in CREENCIAS_VBG_RESP:
                tabla[field.verbose_name][key].append(
                    Creencia.objects.filter(
                        content_type=get_content_type(tipo),
                        object_id__in=lista,
                        **{
                            field.name: op[0]
                        }).count())

    totales = get_total(resultados)
    grafico = convertir_grafico(tabla)
    tabla = get_prom_dead_list(tabla, totales)

    return render_to_response("monitoreo/comportamiento.html",
                              RequestContext(request, locals()))
Exemplo n.º 16
0
def hombres_violentos(request, tipo):
    titulo = "¿Cree usted que los hombres son violentos debido a?"
    resultados = _query_set_filtrado(request, tipo=tipo)
    tabla = {}
    campos = [
        field for field in CausaVBG._meta.fields
        if field.get_internal_type() == 'CharField'
    ]

    for field in campos:
        tabla[field.verbose_name] = []

        for key, grupo in resultados.items():
            lista = []
            [lista.append(encuesta.id) for encuesta in grupo]

            tabla[field.verbose_name].append(
                CausaVBG.objects.filter(content_type=get_content_type(tipo),
                                        object_id__in=lista,
                                        **{
                                            field.name: 'si'
                                        }).count())

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)

    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 17
0
def prohibido_por_ley(request, tipo):
    """Acciones prohibidas por la ley"""
    from trocaire.encuesta.models import SI_NO_RESPONDE

    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    campos = [
        field for field in ConocimientoLey._meta.fields
        if field.get_internal_type() == 'IntegerField'
        and not (field.name == 'existe_ley' or field.name == 'object_id')
    ]

    for field in campos:
        tabla[field.verbose_name] = {}
        for key, grupo in resultados.items():
            lista = []
            [lista.append(encuesta.id) for encuesta in grupo]

            tabla[field.verbose_name][key] = []

            for op in SI_NO_RESPONDE:
                tabla[field.verbose_name][key].append(
                    ConocimientoLey.objects.filter(
                        content_type=get_content_type(tipo),
                        object_id__in=lista,
                        **{
                            field.name: op[0]
                        }).count())

    totales = get_total(resultados)
    grafico = convertir_grafico(tabla)
    tabla = get_prom_dead_list(tabla, totales)
    return render_to_response("monitoreo/prohibido_por_ley.html",
                              RequestContext(request, locals()))
Exemplo n.º 18
0
def como_afecta(request, tipo):
    titulo = u'¿Como afecta la VBG a las mujeres, comunidad y la familia?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = ComoAfecta.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(EfectoVBG.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, como_afecta=op).count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) < 10:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 19
0
def como_afecta(request, tipo):
    titulo = u'¿Como afecta la VBG a las mujeres, comunidad y la familia?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = ComoAfecta.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(
                EfectoVBG.objects.filter(content_type=get_content_type(tipo),
                                         object_id__in=lista,
                                         como_afecta=op).count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) < 10:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)

    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 20
0
def motivo_participacion(request, tipo):
    titulo = u'¿Qué le motiva a participar en esta organización?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = MotivoParticipacion.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(
                ParticipacionPublica.objects.filter(
                    content_type=get_content_type(tipo),
                    object_id__in=lista,
                    motivo=op).count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) == 0:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 21
0
def participacion_en_espacios(request, tipo):
    titulo = u"¿En que organización o espacios comunitarios te encuentras integrada/o actualmente?"
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = Espacio.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(
                ParticipacionPublica.objects.filter(
                    content_type=get_content_type(tipo),
                    object_id__in=lista,
                    espacio=op).count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) < 10:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 22
0
def nivel_educativo(request, tipo):
    from trocaire.encuesta.models import NIVEL_EDUCATIVO
    titulo = u'¿Cuál es su nivel educativo más alto?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    opciones = NIVEL_EDUCATIVO

    for op in opciones:
        tabla[op[1]] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op[1]].append(
                InformacionSocioEconomica.objects.filter(
                    content_type=get_content_type(tipo),
                    object_id__in=lista,
                    nivel_educativo=op[0]).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 23
0
def lista_generica(request, tipo, **params):
    titulo = params['titulo']
    resultados = _query_set_filtrado(request, tipo)
    modelo = get_model('encuesta', params['modelo'])
    tabla = {}
    totales = get_total(resultados)
    options = params.get('options', None) 
    
    for key, grupo in resultados.items():
        if options:            
            tabla[key] = modelo.objects.filter(content_type=get_content_type(tipo), object_id__in=grupo.values_list('id', flat=True),
                                               **{params['field']:options}).distinct().values_list(params['field_values'])                
        else:
            tabla[key] = modelo.objects.filter(content_type=get_content_type(tipo), 
                                               object_id__in=grupo.values_list('id', flat=True)).distinct().values_list(params['field'])
        
    return render_to_response("monitoreo/lista_leyes.html", RequestContext(request, locals()))
Exemplo n.º 24
0
def mencione_leyes(request, tipo):
    titulo = u'Mencione la ley que penaliza la VBG contra las mujeres'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    totales = get_total(resultados)
    
    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]
        
        tabla[key] = list(set(ConocimientoLey.objects.filter(content_type=get_content_type(tipo), object_id__in=lista).values_list('mencione')))
        
    return render_to_response("monitoreo/lista_leyes.html", RequestContext(request, locals()))
Exemplo n.º 25
0
def lista_generica(request, tipo, **params):
    titulo = params['titulo']
    resultados = _query_set_filtrado(request, tipo)
    modelo = get_model('encuesta', params['modelo'])
    tabla = {}
    totales = get_total(resultados)
    options = params.get('options', None)

    for key, grupo in resultados.items():
        if options:
            tabla[key] = modelo.objects.filter(
                content_type=get_content_type(tipo),
                object_id__in=grupo.values_list('id', flat=True),
                **{
                    params['field']: options
                }).distinct().values_list(params['field_values'])
        else:
            tabla[key] = modelo.objects.filter(
                content_type=get_content_type(tipo),
                object_id__in=grupo.values_list(
                    'id', flat=True)).distinct().values_list(params['field'])

    return render_to_response("monitoreo/lista_leyes.html",
                              RequestContext(request, locals()))
Exemplo n.º 26
0
def frecuencia(request, tipo):
    from trocaire.encuesta.models import FRECUENCIA2, FRECUENCIA
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    if tipo == 'mujeres':
        opciones = FRECUENCIA
        titulo = u'¿Con que frecuencia ha vivido VBG este último año?'
    elif tipo == 'hombres':
        titulo = u'¿Con que frecuencia ha ejercido VBG este último año?'
        opciones = FRECUENCIA2

    for op in opciones:
        tabla[op[1]] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            if tipo == 'mujeres':
                tabla[op[1]].append(
                    PrevalenciaVBG.objects.filter(
                        content_type=get_content_type(tipo),
                        object_id__in=lista,
                        frecuencia=op[0]).count())
            elif tipo == 'hombres':
                tabla[op[1]].append(
                    PrevalenciaVBGHombre.objects.filter(
                        content_type=get_content_type(tipo),
                        object_id__in=lista,
                        frecuencia=op[0]).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 27
0
def generic_view_hm(request, tipo=None, **params):
    titulo = params['titulo']
    template = params.get('template_name', 'monitoreo/generica_1.html')
    if tipo == None:
        tipo = params.get('tipo', '')

    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = params['options']
    modelo = get_model('encuesta', params['modelo'])

    for op in opciones:
        key, val = checkOpt(op, params['options'])
        tabla[key] = []

    for key, grupo in resultados.items():
        for op in opciones:
            key, val = checkOpt(op, params['options'])
            tabla[key].append(
                modelo.objects.filter(content_type=get_content_type(tipo),
                                      object_id__in=grupo.values_list(
                                          'id', flat=True),
                                      **{
                                          params['field']: val
                                      }).count())

    checkvalue = lambda x: sum(x)
    #mandar a chequear si la suma de valores es menos de 10 (opcional)
    if not params.get('nocheck', False) == True:
        for key, value in tabla.items():
            if checkvalue(value) < 10:
                del tabla[key]

    #mandar a chequear si la suma de valores es cero (opcional)
    if params.get('checkcero', False) == True:
        for key, value in tabla.items():
            if sum(value) == 0:
                del tabla[key]

    totales = get_total(resultados)
    if tipo in ['mujeres', 'hombres']:
        tabla = get_list_with_total(tabla, totales)
    else:
        tabla = get_prom_lista_func(tabla, totales)

    #de no necesitar los grafos, activar esta variable nografo
    nografo = params.get('nografo', False)
    return render_to_response(template, locals(), RequestContext(request))
Exemplo n.º 28
0
def ayuda_mujer_violencia(request, tipo):    
    titulo = u'¿En el último año ha ayudado usted a alguna mujer que ha vivido VBG?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    for op in ['si', 'no']:
        tabla[op.title()] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]
        
        for op in ['si', 'no']:
            tabla[op.title()].append(AccionVBG.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, ha_ayudado=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_pie.html", RequestContext(request, locals()))
Exemplo n.º 29
0
def ha_vivido_vbg(request, tipo):
    titulo = u'¿Considera usted que alguna vez ha vivido VBG?'
    resultados = _query_set_filtrado(request, 'mujeres')
    tabla = {}

    for op in ['si', 'no']:
        tabla[op.title()] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in ['si', 'no']:
            tabla[op.title()].append(PrevalenciaVBG.objects.filter(content_type=get_content_type('mujeres'), object_id__in=lista, ha_vivido_vbg=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_pie.html", RequestContext(request, locals()))
Exemplo n.º 30
0
def mujeres_vbg(request, tipo):    
    titulo = '¿Conoce usted si en su comunidad existen mujeres que han vivido VBG?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    for op in ['si', 'no']:
        tabla[op.title()] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]
        
        for op in ['si', 'no']:
            tabla[op.title()].append(SituacionVBG.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, conoce_mujeres=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_pie.html", RequestContext(request, locals()))
Exemplo n.º 31
0
def mujeres_representan(request, tipo):    
    titulo = u'¿En su comunidad existen mujeres que representan a otras mujeres?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    for op in ['si', 'no']:
        tabla[op.title()] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]
        
        for op in ['si', 'no']:
            tabla[op.title()].append(IncidenciaPolitica.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, existen_mujeres=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_pie.html", RequestContext(request, locals()))
Exemplo n.º 32
0
def conoce_leyes(request, tipo):
    titulo = u'¿Sabe usted si en existe alguna ley que penaliza la violencia contra las mujeres?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    for op in SI_NO_RESPONDE:
        tabla[op[1]] = []
    
    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in SI_NO_RESPONDE:
            tabla[op[1]].append(ConocimientoLey.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, existe_ley=op[0]).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    
    return render_to_response("monitoreo/generica_pie.html", RequestContext(request, locals()))
Exemplo n.º 33
0
def afeccion_vbg(request, tipo):    
    titulo = u'¿Cree usted que la VBG afecta a las mujeres, la familia y la comunidad?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    for op in ['si', 'no']:
        tabla[op.title()] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in ['si', 'no']:
            tabla[op.title()].append(EfectoVBG.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, afecta_mujeres=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)

    return render_to_response("monitoreo/generica_pie.html", RequestContext(request, locals()))
Exemplo n.º 34
0
def viven_con_pareja(request, tipo):
    from trocaire.encuesta.models import SI_NO
    titulo = u'¿Actualmente tiene esposo/a o compañero/a?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    for op in SI_NO:
        tabla[op[1]] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]
        
        for op in SI_NO:
            tabla[op[1]].append(ComposicionHogar.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, tiene_pareja=op[0]).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_pie.html", RequestContext(request, locals()))
Exemplo n.º 35
0
def mencione_leyes(request, tipo):
    titulo = u'Mencione la ley que penaliza la VBG contra las mujeres'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    totales = get_total(resultados)

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        tabla[key] = list(
            set(
                ConocimientoLey.objects.filter(
                    content_type=get_content_type(tipo),
                    object_id__in=lista).values_list('mencione')))

    return render_to_response("monitoreo/lista_leyes.html",
                              RequestContext(request, locals()))
Exemplo n.º 36
0
def hombres_violentos(request, tipo):
    titulo = "¿Cree usted que los hombres son violentos debido a?"
    resultados = _query_set_filtrado(request, tipo=tipo)
    tabla = {}
    campos = [field for field in CausaVBG._meta.fields if field.get_internal_type() == 'CharField']

    for field in campos:
        tabla[field.verbose_name] = []

        for key, grupo in resultados.items():
            lista = []
            [lista.append(encuesta.id) for encuesta in grupo]

            tabla[field.verbose_name].append(CausaVBG.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, ** {field.name: 'si'}).count())

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 37
0
def generic_view_hm(request, tipo=None, ** params):
    titulo = params['titulo']
    template = params.get('template_name', 'monitoreo/generica_1.html')
    if tipo == None:
        tipo = params.get('tipo', '')
                    
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = params['options']
    modelo = get_model('encuesta', params['modelo'])

    for op in opciones:
        key, val = checkOpt(op, params['options'])
        tabla[key] = []

    for key, grupo in resultados.items():
        for op in opciones:
            key, val = checkOpt(op, params['options'])
            tabla[key].append(modelo.objects.filter(content_type=get_content_type(tipo), object_id__in=grupo.values_list('id', flat=True), 
                                                    ** {params['field']:val}).count())
    
    checkvalue = lambda x: sum(x)
    #mandar a chequear si la suma de valores es menos de 10 (opcional)
    if not params.get('nocheck', False) == True:        
        for key, value in tabla.items():
            if checkvalue(value) < 10:
                del tabla[key]
                
    #mandar a chequear si la suma de valores es cero (opcional)
    if params.get('checkcero', False) == True:
        for key, value in tabla.items():
            if sum(value) == 0:
                del tabla[key]

    totales = get_total(resultados)
    if tipo in ['mujeres', 'hombres']:
        tabla = get_list_with_total(tabla, totales)
    else:
        tabla = get_prom_lista_func(tabla, totales)
        
    #de no necesitar los grafos, activar esta variable nografo
    nografo = params.get('nografo', False)
    return render_to_response(template, locals(), RequestContext(request))
Exemplo n.º 38
0
def persona_ejercido(request, tipo):
    titulo = u'¿Quién es la persona que ha ejercido VBG sobre usted?'
    resultados = _query_set_filtrado(request, 'mujeres')
    tabla = {}
    
    opciones = Quien.objects.all()
    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(PrevalenciaVBG.objects.filter(content_type=get_content_type('mujeres'), 
                                                                      object_id__in=lista, 
                                                                      quien=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)    
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))    
Exemplo n.º 39
0
def decide_recursos(request, tipo):
    titulo = u'¿Mencione los recursos sobre los cuales ud decide?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = Recurso.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(AccesoControlRecurso.objects.filter(content_type=get_content_type(tipo), 
                                                                      object_id__in=lista, 
                                                                      recursos_decide=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)    
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 40
0
def que_debe_hacer(request, tipo):    
    titulo = "¿Si un hombre le pega a su pareja que acciones deberia de tomar?"
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = QueDebeHacer.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(AccionVBG.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, accion_tomar=op).count())

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)

    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 41
0
def edad_personas(request, tipo='mujeres', **params):
    titulo = params['titulo']
    options = params['options']
    modelo = get_model('encuesta', params['modelo'])
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    for op in options:
        key, val = checkOpt(op, options)
        tabla[key] = []
        
    for key, grupo in resultados.items():
        for op in options:
            key, val = checkOpt(op, options)
            query = modelo.objects.filter(content_type=get_content_type(tipo), object_id__in=grupo.values_list('id', flat=True))
            tabla[key].append((query.aggregate(campo=Sum(val))['campo'], round(query.aggregate(campo=Avg(val))['campo'], 1)))
    totales = get_total(resultados)   
    
    return render_to_response('monitoreo/generica_1.html', RequestContext(request, {'tabla': tabla, 'totales': totales, 'hide_perc': True, 
                                                                                    'graph_title': params['graph_title'],
                                                                                    'titulo': titulo, 'tipo': tipo}))
Exemplo n.º 42
0
def negociacion_pareja(request, tipo):
    """Que se debe hacer para que una negociacion de pareja sea exitosa"""
    titulo = u'¿Que se debe hacer para que una negociacion de pareja sea exitosa?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = NegociacionExitosa.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(ComunicacionAsertiva.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, negociacion_exitosa=op).count())

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 43
0
def aporte_ingresos(request, tipo):
    titulo = u'¿Quién a quienes aportan ingresos al hogar?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    
    opciones = Aporta.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(InformacionSocioEconomica.objects.filter(content_type=get_content_type(tipo), 
                                                                      object_id__in=lista, 
                                                                      aportan=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)    
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 44
0
def ayuda_mujer_violencia(request, tipo):
    titulo = u'¿En el último año ha ayudado usted a alguna mujer que ha vivido VBG?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    for op in ['si', 'no']:
        tabla[op.title()] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in ['si', 'no']:
            tabla[op.title()].append(
                AccionVBG.objects.filter(content_type=get_content_type(tipo),
                                         object_id__in=lista,
                                         ha_ayudado=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_pie.html",
                              RequestContext(request, locals()))
Exemplo n.º 45
0
def calidad_servicios(request, tipo):
    titulo = u'¿Cómo valora Ud los servicios que las intituciones ofrecen a las mujeres que viven VBG?'
    from trocaire.encuesta.models import SERVICIOS
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = SERVICIOS
        
    for op in opciones:
        tabla[op[1]] = []
    
    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]
       
        for op in opciones:            
            tabla[op[1]].append(CalidadAtencion.objects.filter(content_type=get_content_type(tipo), 
                                                                    object_id__in=lista, 
                                                                    valor_servicio=op[0]).count())    
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_pie.html", RequestContext(request, locals()))
Exemplo n.º 46
0
def satisfaccion(request, tipo):
    titulo = u'¿Qué tan satisfechas están las mujeres con quienes las representan?'
    from trocaire.encuesta.models import SATISFECHAS    
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = SATISFECHAS
        
    for op in opciones:
        tabla[op[1]] = []
    
    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]
       
        for op in opciones:            
            tabla[op[1]].append(IncidenciaPolitica.objects.filter(content_type=get_content_type(tipo), 
                                                                    object_id__in=lista, 
                                                                    satisfecha=op[0]).count())    
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 47
0
def mujeres_vbg(request, tipo):
    titulo = '¿Conoce usted si en su comunidad existen mujeres que han vivido VBG?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    for op in ['si', 'no']:
        tabla[op.title()] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in ['si', 'no']:
            tabla[op.title()].append(
                SituacionVBG.objects.filter(
                    content_type=get_content_type(tipo),
                    object_id__in=lista,
                    conoce_mujeres=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_pie.html",
                              RequestContext(request, locals()))
Exemplo n.º 48
0
def afeccion_vbg(request, tipo):
    titulo = u'¿Cree usted que la VBG afecta a las mujeres, la familia y la comunidad?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    for op in ['si', 'no']:
        tabla[op.title()] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in ['si', 'no']:
            tabla[op.title()].append(
                EfectoVBG.objects.filter(content_type=get_content_type(tipo),
                                         object_id__in=lista,
                                         afecta_mujeres=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)

    return render_to_response("monitoreo/generica_pie.html",
                              RequestContext(request, locals()))
Exemplo n.º 49
0
def mujeres_representan(request, tipo):
    titulo = u'¿En su comunidad existen mujeres que representan a otras mujeres?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    for op in ['si', 'no']:
        tabla[op.title()] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in ['si', 'no']:
            tabla[op.title()].append(
                IncidenciaPolitica.objects.filter(
                    content_type=get_content_type(tipo),
                    object_id__in=lista,
                    existen_mujeres=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_pie.html",
                              RequestContext(request, locals()))
Exemplo n.º 50
0
def trabaja_fuera(request, tipo):
    titulo = u'¿Trabaja usted fuera del hogar?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    for op in ['si', 'no']:
        tabla[op.title()] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in ['si', 'no']:
            tabla[op.title()].append(
                InformacionSocioEconomica.objects.filter(
                    content_type=get_content_type(tipo),
                    object_id__in=lista,
                    trabaja_fuera=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_pie.html",
                              RequestContext(request, locals()))
Exemplo n.º 51
0
def ha_ejercido_vbg(request, tipo):
    titulo = u'Considera usted que ejercido VBG contra una mujer el ultimo año?'
    resultados = _query_set_filtrado(request, 'hombres')
    tabla = {}

    for op in ['si', 'no']:
        tabla[op.title()] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in ['si', 'no']:
            tabla[op.title()].append(
                PrevalenciaVBGHombre.objects.filter(
                    content_type=get_content_type('hombres'),
                    object_id__in=lista,
                    ha_vivido_vbg=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_pie.html",
                              RequestContext(request, locals()))
Exemplo n.º 52
0
def persona_ejercido(request, tipo):
    titulo = u'¿Quién es la persona que ha ejercido VBG sobre usted?'
    resultados = _query_set_filtrado(request, 'mujeres')
    tabla = {}

    opciones = Quien.objects.all()
    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(
                PrevalenciaVBG.objects.filter(
                    content_type=get_content_type('mujeres'),
                    object_id__in=lista,
                    quien=op).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html",
                              RequestContext(request, locals()))
Exemplo n.º 53
0
def vbg_resolver_con(request, tipo):    
    titulo = u'¿Considera que la VBG es un asunto que debe ser resuelto con la participación de?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = ResolverVBG.objects.all()
    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]
        
        for op in opciones:
            tabla[op].append(AsuntoPublicoVBG.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, resolverse_con=op).count())
            
    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():        
        if checkvalue(value) < 10:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 54
0
def conoce_leyes(request, tipo):
    titulo = u'¿Sabe usted si en existe alguna ley que penaliza la violencia contra las mujeres?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}

    for op in SI_NO_RESPONDE:
        tabla[op[1]] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in SI_NO_RESPONDE:
            tabla[op[1]].append(
                ConocimientoLey.objects.filter(
                    content_type=get_content_type(tipo),
                    object_id__in=lista,
                    existe_ley=op[0]).count())
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)

    return render_to_response("monitoreo/generica_pie.html",
                              RequestContext(request, locals()))
Exemplo n.º 55
0
def motivo_participacion(request, tipo):
    titulo = u'¿Qué le motiva a participar en esta organización?'
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = MotivoParticipacion.objects.all()
    
    for op in opciones:
        tabla[op] = []
        
    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(ParticipacionPublica.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, motivo=op).count())
    
    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) == 0:
            del tabla[key]
    
    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 56
0
def que_acciones_realizar(request, tipo):
    titulo = "¿Cuando una mujer vive VBG cuales acciones deberia realizar?"
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = Decision.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]
        
        for op in opciones:
            tabla[op].append(TomaDecision.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, decision=op).count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) < 10:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 57
0
def tipo_vbg_ejercido(request, tipo):
    titulo = u"¿Qué tipo de VBG ha ejercido?"
    resultados = _query_set_filtrado(request, 'hombres')
    tabla = {}
    opciones = TipoVBG.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]
       
        for op in opciones:
            tabla[op].append(PrevalenciaVBGHombre.objects.filter(content_type=get_content_type('hombres'), object_id__in=lista, que_tipo=op).count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) == 0:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))
Exemplo n.º 58
0
def cruce_mujeres(request):
    var1 = int(request.session['var1'])
    var2 = int(request.session['var2'])
    dicc = _query_set_cruce(request, var1)
    tabla = {}
    modelo_var2 = get_model('encuesta', MODELO_VAR2[var2])
    total_var1 = {}
    total_var2 = {}
    
    for op in OPCIONES_VAR2[var2]:
        #obtener el tipo de opcion
        if TIPO_OPCION_VAR2[var2] == 'tupla':
            llave = op[1]
            opcion = op[0]
        elif TIPO_OPCION_VAR2[var2] == 'queryset':
            llave = op
            opcion = op
            
        tabla[llave] = {}
        for key, ids in dicc.items():
            tabla[llave][key] = modelo_var2.objects.filter(content_type=get_content_type(request.session['content_type']),
                                                           object_id__in=ids,
                                                           ** {CAMPO_VAR2[var2]: opcion}).count()
        #calcular los totales para variable2
        total_var2[llave] = sum(tabla[llave].values())
    
    #calcular los totales variable1
    for key in dicc.keys():
        total_var1[key] = 0
        for k,v in tabla.items():
            total_var1[key] += tabla[k][key]
    
    #calcular el total general
    total_general = sum(total_var1.values())    
    
    return render_to_response('pf/cruce_mujeres.html', RequestContext(request, locals()))
Exemplo n.º 59
0
def participacion_en_espacios(request, tipo):
    titulo = u"¿En que organización o espacios comunitarios te encuentras integrada/o actualmente?"
    resultados = _query_set_filtrado(request, tipo)
    tabla = {}
    opciones = Espacio.objects.all()

    for op in opciones:
        tabla[op] = []

    for key, grupo in resultados.items():
        lista = []
        [lista.append(encuesta.id) for encuesta in grupo]

        for op in opciones:
            tabla[op].append(ParticipacionPublica.objects.filter(content_type=get_content_type(tipo), object_id__in=lista, espacio=op).count())

    checkvalue = lambda x: sum(x)
    for key, value in tabla.items():
        if checkvalue(value) < 10:
            del tabla[key]

    totales = get_total(resultados)
    tabla = get_list_with_total(tabla, totales)
    return render_to_response("monitoreo/generica_1.html", RequestContext(request, locals()))