Changeset 2c1cb23 in firmaeventos


Ignore:
Timestamp:
Nov 22, 2017, 11:59:52 AM (6 years ago)
Author:
rudmanmrrod <rudman22@…>
Branches:
master
Children:
2ce257a
Parents:
aef49cb
Message:

Añadida vista y ajax para verificar si el firmante es el último, agregados campos para enviar a la api de la firma

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • base/templates/base.vars.javascript.html

    rd2472e8 r2c1cb23  
    66    // URL para actualizar la firma de un participante
    77    var URL_ACTUALIZAR_PARTICIPACION = "{% url 'participantes:update_participante_evento' %}";
     8   
     9    // URL para comprobar si el firmante es el último
     10    var URL_ULTIMO_FIRMANTE = "{% url 'participantes:participante_restante_evento_nid' %}";
    811           
    912</script>
  • participantes/urls.py

    re91566e r2c1cb23  
    88    url(r'^search-participante/$', ParticipanteEventoSearch.as_view(), name='search_participante_nid'),
    99    url(r'^update-participante-evento/$', AjaxParticipanteFirmaEvento.as_view(), name='update_participante_evento'),
     10    url(r'^participante-restante/(?P<evento>\d+)/$', ParticipantesRestantes.as_view(), name='participante_restante_evento'),
     11    url(r'^participante-restante/$', ParticipantesRestantes.as_view(), name='participante_restante_evento_nid'),
    1012]
  • participantes/views.py

    rd17da63 r2c1cb23  
    113113
    114114        return JsonResponse(data, safe=False)
     115
     116class ParticipantesRestantes(View):
     117    """!
     118    Muestra si el participante restante es el último
     119
     120    @author Rodrigo Boet  (rboet at cenditel.gob.ve)
     121    @copyright <a href='https://www.gnu.org/licenses/gpl-3.0.en.html'>GNU Public License versión 3 (GPLv3)</a>
     122    @date 22-11-2017
     123    @version 1.0.0
     124    """
     125
     126    def get(self,request,evento):
     127        """!
     128        Metodo para antender la vista por GET
     129
     130        @author Rodrigo Boet (rboet at cenditel.gob.ve)
     131        @copyright GNU/GPLv3
     132        @date 22-11-2017
     133        @param self <b>{object}</b> Objeto que instancia la clase
     134        @param request <b>{object}</b> Objeto que contiene la petición
     135        @param evento <b>{int}</b> Recibe el id del evento
     136        @return Retorna un Json con la respuesta
     137        """
     138        participante_evento = ParticipanteEvento.objects.select_related().filter(fk_evento=evento)
     139        falta_porfirma = participante_evento.filter(firma=False).count()
     140        data = {}
     141        if(falta_porfirma==1):
     142            evento = Evento.objects.get(pk=evento)
     143            data = {'valid':True,'data':{'posX':evento.pos_x,'posY':evento.pos_y,'page':evento.pag}}
     144        else:
     145            data = {'valid':False}
     146
     147        return JsonResponse(data, safe=False)
  • static/js/funciones.js

    ra1de3f1 r2c1cb23  
    9191*/
    9292function 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);
     93    var xPos = yPos= signaturePage = "";
     94    var lastSignature = false;
     95    var routes = $(location).attr('pathname').split('/');
     96    var pk = routes[routes.length-1];
     97   
     98    $.ajax({
     99                type: 'GET',
     100        async: false,
     101                url:URL_ULTIMO_FIRMANTE+pk,
     102                success: function(datos){
     103            if (datos.valid==true) {
     104                xPos = datos.data.posX;
     105                yPos = datos.data.posY;
     106                signaturePage = datos.data.page;
     107                lastSignature = true;
     108            }
     109            window.hwcrypto.getCertificate({lang: "en"}).then(
     110                function(response) {
     111                    var cert = response;
     112                    var parameters = "";
     113                    parameters = JSON.stringify({
     114                        "fileId":fileId,
     115                        "certificate":cert.hex,
     116                        "reason":"Certificado",
     117                        "location":"RedGealc",
     118                        "contact":"RedGealc",
     119                        "signatureVisible":"false",
     120                        "signaturePage": signaturePage,
     121                        "xPos": xPos,
     122                        "yPos": yPos,
     123                        "lastSignature":lastSignature
     124                        });                             
     125       
     126                    // ahora llamar al ajax de obtener la resena del pdf
     127                    ObtenerHashPDFServerMultiples(parameters, cert);   
     128       
     129                },
     130                function(err) {
     131                    var error;
     132                    if(err == "Error: user_cancel") {
     133                        error = "El usuario cancelo la operación";
     134                     }     
     135                     else if(err == "Error: no_certificates") {
     136                         error = "No hay certificado disponible";
     137                     }
     138                     else if(err == "Error: no_implementation") {
     139                         error = "No hay soporte para el manejo del certificado";
     140                    }
     141                    simple_modal(error);
     142                }
     143       
     144            );
     145                },
     146                error: function(jqXHR, textStatus, errorThrown){
     147                        console.log('error: ' + textStatus);
    127148                }
    128 
    129         );
     149        });
    130150}
    131151
Note: See TracChangeset for help on using the changeset viewer.