예제 #1
0
def buscar(request, **kargs):
    query, msg = "", ""
    if 'numero' in kargs:
        numero = kargs['numero']
        validado = validateNumber(numero)
        query = Denuncia.objects.filter(numero=validado, activo=True)
        vcard("", query)
        if query:
            msg = validado
            resp = query
        else:
            msg = u"No se encontró %s en la base de datos" % numero

    return render(request, 'buscar.html', {'numeros': query, 'msg': msg})
예제 #2
0
파일: views.py 프로젝트: Andresxgf/listahu
def buscar(request, **kargs):
    query, msg = "", ""
    if "numero" in kargs:
        numero = kargs["numero"]
        validado = validateNumber(numero)
        query = Denuncia.objects.filter(numero=validado, activo=True)
        vcard("", query)
        if query:
            msg = validado
            resp = query
        else:
            msg = u"No se encontró %s en la base de datos" % numero

    return render(request, "buscar.html", {"numeros": query, "msg": msg})
예제 #3
0
파일: views.py 프로젝트: Andresxgf/listahu
def download(request, **kwargs):
    print kwargs
    if "formato" in kwargs:
        formato = kwargs["formato"]
        lista = Denuncia.objects.filter(activo=True)
        if formato == "csv":
            archi = getCSV(lista)
            response = HttpResponse(archi, content_type="text/csv")
            response["Content-Disposition"] = 'attachment; filename="LISTA_HU_%s.csv"' % (
                time.strftime("%Y-%m-%d", time.localtime())
            )
            return response
        elif formato == "vcard":
            lista = Denuncia.objects.filter(activo=True).distinct("numero")
            vc = str(vcard("Todos", lista))
            response = HttpResponse(vc, content_type="text/vcard")
            response["Content-Disposition"] = 'attachment; filename="LISTA_HU_%s.VCF"' % (
                time.strftime("%Y-%m-%d", time.localtime())
            )
            return response
        elif formato == "vcard/repetidos":
            lista = (
                Denuncia.objects.values("numero")
                .annotate(the_count=Count("numero"))
                .order_by("-the_count")
                .filter(the_count__gte=2)
            )
            vc = str(vcard("Todos", lista))
            response = HttpResponse(vc, content_type="text/vcard")
            response["Content-Disposition"] = 'attachment; filename="LISTA_HU_REP_%s.VCF"' % (
                time.strftime("%Y-%m-%d", time.localtime())
            )
            return response
        elif formato == "vcard/nospam":
            lista = (
                Denuncia.objects.filter(activo=True).distinct("numero").exclude(tipo=Tipo.objects.get(titulo="SPAM").id)
            )
            vc = str(vcard("Todos", lista))
            response = HttpResponse(vc, content_type="text/vcard")
            response["Content-Disposition"] = 'attachment; filename="LISTA_HU_NOSPAM_%s.VCF"' % (
                time.strftime("%Y-%m-%d", time.localtime())
            )
            return response

    return render(request, "descargar.html", {"msg": "msg"})
    return HttpResponse("<h2>Descargar:</h2><a href='vcard'>vCard</a><br><a href='csv'>CSV</a>")
예제 #4
0
def download(request, **kwargs):
    if 'formato' in kwargs:
        formato = kwargs['formato']
        lista = Denuncia.objects.filter(activo=True)
        if formato == 'csv':
            archi = getCSV(lista)
            response = HttpResponse(archi, content_type='text/csv')
            response[
                'Content-Disposition'] = 'attachment; filename="LISTA_HU_%s.csv"' % (
                    time.strftime("%Y-%m-%d", time.localtime()))
            return response
        elif formato == 'vcard':
            lista = Denuncia.objects.filter(activo=True).distinct('numero')
            vc = str(vcard("Todos", lista))
            response = HttpResponse(vc, content_type='text/vcard')
            response[
                'Content-Disposition'] = 'attachment; filename="LISTA_HU_%s.VCF"' % (
                    time.strftime("%Y-%m-%d", time.localtime()))
            return response
        elif formato == 'vcard/repetidos':
            lista = Denuncia.objects.values('numero').annotate(
                the_count=Count('numero')).order_by('-the_count').filter(
                    the_count__gte=2)
            vc = str(vcard("Todos", lista))
            response = HttpResponse(vc, content_type='text/vcard')
            response[
                'Content-Disposition'] = 'attachment; filename="LISTA_HU_REP_%s.VCF"' % (
                    time.strftime("%Y-%m-%d", time.localtime()))
            return response
        elif formato == 'vcard/nospam':
            lista = Denuncia.objects.filter(
                activo=True).distinct('numero').exclude(tipo=Tipo.objects.get(
                    titulo='SPAM').id)
            vc = str(vcard("Todos", lista))
            response = HttpResponse(vc, content_type='text/vcard')
            response[
                'Content-Disposition'] = 'attachment; filename="LISTA_HU_NOSPAM_%s.VCF"' % (
                    time.strftime("%Y-%m-%d", time.localtime()))
            return response

    return render(request, 'descargar.html', {'msg': 'msg'})
    return HttpResponse(
        "<h2>Descargar:</h2><a href='vcard'>vCard</a><br><a href='csv'>CSV</a>"
    )
예제 #5
0
def buscar(request, **kargs):
    query, msg, withthumbs = "", "", ""
    if 'numero' in kargs:
        numero = kargs['numero']
        validado = validateNumber(numero)
        query = Denuncia.objects.filter(numero=validado, activo=True)
        vcard("", query)
        if query:
            msg = validado
            withthumbs = []
            for denuncia in query:
                withthumbs.append(
                    (denuncia,
                     "%s_th%s" % (path.splitext(str(denuncia.screenshot))[0],
                                  path.splitext(str(denuncia.screenshot))[1])))
        else:
            msg = u"No se encontró %s en la base de datos" % numero

    return render(request, 'buscar.html', {
        'msg': msg,
        'withthumbs': withthumbs
    })