Changeset d17da63 in firmaeventos


Ignore:
Timestamp:
Nov 22, 2017, 10:10:29 AM (6 years ago)
Author:
rudmanmrrod <rudman22@…>
Branches:
master
Children:
287657f
Parents:
a1de3f1 (diff), 27c0bd4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Mezclados cambios

Files:
1 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • base/templates/base.template.html

    rb84cfca ra1de3f1  
    1414        <script src="{% static "plugins/material-dialog/material-dialog.min.js" %}"></script>
    1515        <script src="{% static "js/funciones.js" %}"></script>
    16         <script src="{% static "js/MultipleSign.js" %}"></script>
    1716        {% block headScript %}{%endblock%}
    1817    </head>
  • base/templates/base.vars.javascript.html

    rae65f8e ra1de3f1  
    22<script type="text/javascript">
    33    // URL para obtener data de usuario en evento
    4     var URL_USUARIO_EVENTO = "{% url 'participantes:search_participante_nid' %}" ;
     4    var URL_USUARIO_EVENTO = "{% url 'participantes:search_participante_nid' %}";
     5   
     6    // URUL para actualizar la firma de un participante
     7    var URL_ACTUALIZAR_PARTICIPACION = "{% url 'participantes:update_participante_evento' %}";
    58       
    69</script>
  • eventos/templates/evento.list.html

    r4db73c3 r27c0bd4  
    2121            </div>
    2222            <div class="card-action">
    23                 <a type="button" class="btn waves-effect blue darken-1" href="">
     23                <a type="button" class="btn waves-effect blue darken-1" href="{% url 'events:detail_event' evento.id %}">
    2424                    <i class="material-icons left">search</i> Detalle
    2525                </a>
  • eventos/urls.py

    r248b1b4 r27c0bd4  
    99    url(r'^crear-eventos/$', RegisterEvent.as_view(), name='create_events'),
    1010    url(r'^lista-eventos/$', ListEvent.as_view(), name='list_events'),
    11     url(r'^firmar-evento/(?P<pk>\d+)$', SignEvent.as_view(), name='firma_events'),
     11    url(r'^firmar-evento/(?P<pk>\d+)$', SignEvent.as_view(),
     12        name='firma_events'),
     13    url(r'^detail-evento/(?P<pk>\d+)$', DetailEvent.as_view(),
     14        name='detail_event'),
    1215]
  • eventos/views.py

    r61f3a75 r27c0bd4  
    1212    redirect
    1313)
    14 from django.views.generic import ListView, FormView
     14from django.views.generic import (
     15    ListView, FormView
     16)
     17from django.views.generic.detail import DetailView
    1518
    1619from multi_form_view import MultiModelFormView
     
    6265        files = {'file': file}
    6366        try:
    64             r = requests.post('https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/cargar', verify=False, headers={'Authorization': 'Basic YWRtaW46YWRtaW4='}, files=files)
     67            #r = requests.post('https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/cargar', verify=False, headers={'Authorization': 'Basic YWRtaW46YWRtaW4='}, files=files)
     68            r = requests.post('https://192.168.12.154:8443/Murachi/0.1/archivos/cargar', verify=False, headers={'Authorization': 'Basic YWRtaW46YWRtaW4='}, files=files)
    6569            nuevo_participante = self.form_participante(request.POST)
    6670            consulta_api = r.json()['fileId']
     
    150154        kwargs['nombre_evento'] = Evento.objects.get(pk=int(self.kwargs['pk']))
    151155        return super(SignEvent, self).get_context_data(**kwargs)
     156
     157
     158class DetailEvent(DetailView):
     159    """!
     160    Muestra el detalle del evento
     161
     162    @author Rodrigo Boet (rboet at cenditel.gob.ve)
     163    @copyright <a href='https://www.gnu.org/licenses/gpl-3.0.en.html'>GNU Public License versión 3 (GPLv3)</a>
     164    @date 20-11-2017
     165    @version 1.0.0
     166    """
     167    model = Evento
     168    template_name = "evento.detail.html"
     169
     170    def get_context_data(self, **kwargs):
     171        evento = int(self.kwargs['pk'])
     172        context = super(DetailEvent, self).get_context_data(**kwargs)
     173        try:
     174            participante_evento = ParticipanteEvento.objects.select_related().filter(fk_evento=evento)
     175            falta_porfirma = participante_evento.filter(firma=False).count()
     176        except Exception as e:
     177            print(e)
     178            participante_evento = None
     179            falta_porfirma = None
     180        context['participantes'] = participante_evento
     181        context['num_firma'] = falta_porfirma
     182        return context
  • participantes/views.py

    ra1de3f1 rd17da63  
    6969        mensaje = ''
    7070        evento_id = request.POST.get('event_id', None)
    71         print(evento_id)
    7271        serial = request.POST.get('serial', None)
    73         print(serial)
    7472        pasaporte = request.POST.get('pasaporte', None)
    75         print(pasaporte)
     73        pasaporte = request.POST.get('pasaporte', None)
    7674        if evento_id is not None and pasaporte is not None:
    7775            if serial is not None:
  • static/js/funciones.js

    rb84cfca ra1de3f1  
    2828        $.getJSON(url, function(data){
    2929            if (Object.keys(data).length > 0) {
    30                 construir_datos(data.datos);
     30                construir_datos(data);   
    3131            }
    3232            else{
     
    6565*/
    6666function construir_datos(data) {
     67    firma = data.firmo;
     68    data = data.datos;
    6769    $('#datos_paricipante').html('');
    6870    html = '<ul class="collection">'
     
    7274    html += '<li class="collection-item"><b>Correo: </b>'+data.correo+'</li>';
    7375    html += '</ul>';
    74     html += '<iframe width="700px" height="600px" src="https://192.168.12.154:8443/Murachi/0.1/archivos/listadopdf/cbcd0924-bbfe-49dc-afc8-f32348f20350.pdf">';
     76    html += '<iframe width="700px" height="600px" src="https://192.168.12.154:8443/Murachi/0.1/archivos/listadopdf/'+data.documento+'">';
    7577    html += '</iframe><br/>';
    76     html += '<a type="button" class="btn waves-effect blue darken-1" onclick="ObtenerCertificadoFirmanteMultiples(\''+data.documento+'\')">';
    77     html += '<i class="material-icons left">mode_edit</i> Firmar</a>';
     78    if (firma==true) {
     79        html += '<h4 class="red-text center">Ya firmó este documento</h4>'
     80    }
     81    else{
     82        html += '<a type="button" id="firmar" class="btn waves-effect blue darken-1" onclick="ObtenerCertificadoFirmanteMultiples(\''+data.documento+'\')">';
     83        html += '<i class="material-icons left">mode_edit</i> Firmar</a>';   
     84    }
    7885    $('#datos_paricipante').html(html);
    7986}
     87
     88/**
     89 * Función para obtener el certificado del participante
     90 * @param fileId Recibe el id del documento
     91*/
     92function ObtenerCertificadoFirmanteMultiples(fileId){
     93
     94        // identificador del archivo en el servidor
     95        window.hwcrypto.getCertificate({lang: "en"}).then(
     96                function(response) {
     97                        var cert = response;
     98                        var parameters = "";
     99                        parameters = JSON.stringify({
     100                                "fileId":fileId,
     101                                "certificate":cert.hex,
     102                                "reason":"Certificado",
     103                                "location":"RedGealc",
     104                                "contact":"RedGealc",
     105                                "signatureVisible":"false",
     106                                "signaturePage": "",
     107                                "xPos": "",
     108                                "yPos": ""
     109                                });                             
     110
     111                        // ahora llamar al ajax de obtener la resena del pdf
     112                        ObtenerHashPDFServerMultiples(parameters, cert);       
     113
     114                },
     115                function(err) {
     116            var error;
     117            if(err == "Error: user_cancel") {
     118                error = "El usuario cancelo la operación";
     119             }     
     120             else if(err == "Error: no_certificates") {
     121                 error = "No hay certificado disponible";
     122             }
     123             else if(err == "Error: no_implementation") {
     124                 error = "No hay soporte para el manejo del certificado";
     125                        }
     126            simple_modal(error);
     127                }
     128
     129        );
     130}
     131
     132
     133/**
     134 * Función para obtener el hash y procesar la informacion
     135 * @param parameters Recibe los parametros
     136 * @param cert Recibe los certificados
     137*/
     138function ObtenerHashPDFServerMultiples(parameters,cert){
     139
     140        $.ajax({
     141                type: 'POST',
     142                contentType: 'application/json',                               
     143                url:"https://192.168.12.154:8443/Murachi/0.1/archivos/pdfs2",
     144                //url:"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs",
     145        //url: "https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/firmados/pdfs",
     146                dataType: "json",
     147                data: parameters,               
     148                xhrFields: {withCredentials: true},
     149                headers: {"Authorization":"Basic YWRtaW46YWRtaW4="},
     150                success: function(data, textStatus, jqXHR){
     151                        var json_x = data;
     152                        var hash = json_x['hash'];             
     153                        var hashtype = "SHA-256";
     154                        var lang = "eng";
     155                       
     156                        //Procesa la información
     157                        window.hwcrypto.sign(cert, {type: hashtype, hex: hash}, {lang: lang}).then(
     158                                function(signature) {
     159                                        FinalizarFirmaMultiples(signature.hex);
     160                        },
     161                        function(err) {
     162                                        var error;
     163                    if(err == "Error: user_cancel") {
     164                        error = "El usuario cancelo la operación";
     165                     }     
     166                     else if(err == "Error: no_certificates") {
     167                         error = "No hay certificado disponible";
     168                     }
     169                     else if(err == "Error: no_implementation") {
     170                         error = "No hay soporte para el manejo del certificado";
     171                     }
     172                    simple_modal(error);
     173                });
     174                       
     175                },                                                             
     176                error: function(jqXHR, textStatus, errorThrown){
     177                        console.log('ajax error function: ' + jqXHR.responseText);
     178                }
     179               
     180        });     
     181}
     182
     183/**
     184 * Función para enviar la firma al servidor
     185 * @param signature Recibe la firma
     186*/
     187function FinalizarFirmaMultiples(signature){
     188
     189        $.ajax({
     190                type: 'POST',
     191                contentType: 'application/json',
     192                url:"https://192.168.12.154:8443/Murachi/0.1/archivos/pdfs/resenas",
     193                //url:"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs/resenas",
     194                dataType: 'json',
     195                data: JSON.stringify({"signature":signature}),
     196                xhrFields: {withCredentials: true},
     197                headers: {"Authorization":"Basic YWRtaW46YWRtaW4="},
     198                success: function(data, textStatus, jqXHR){
     199            actualizar_participante(data['signedFileId']);
     200                },
     201                error: function(jqXHR, textStatus, errorThrown){
     202                        console.log('error en pdfs/resenas: ' + textStatus);
     203                }
     204        });
     205
     206}
     207
     208/**
     209 * Función para actualizar los datos del participante
     210 * @param id_documento Recibe el id del documento
     211*/
     212function actualizar_participante(id_documento) {
     213    var pasaporte = $('#id_pasaporte').val();
     214    var routes = $(location).attr('pathname').split('/');
     215    var pk = routes[routes.length-1];
     216   
     217    $.post(URL_ACTUALIZAR_PARTICIPACION,{'event_id':pk,'pasaporte':pasaporte,'serial':id_documento})
     218    .done(function(data){
     219        if (data.validate==true) {
     220            simple_modal(data.mensaje);
     221            $('#firmar').remove();
     222        }
     223        else{
     224            simple_modal(data.mensaje);
     225        }
     226    })
     227    .fail(function(err){
     228        console.log(err);
     229    });
     230}
Note: See TracChangeset for help on using the changeset viewer.