Changeset bc1e568 in firmaeventos
- Timestamp:
- Nov 22, 2017, 10:50:29 AM (6 years ago)
- Branches:
- master
- Children:
- 9add819, 6312fce
- Parents:
- ad59aa1 (diff), 287657f (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. - Files:
-
- 1 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
base/templates/base.template.html
rb84cfca ra1de3f1 14 14 <script src="{% static "plugins/material-dialog/material-dialog.min.js" %}"></script> 15 15 <script src="{% static "js/funciones.js" %}"></script> 16 <script src="{% static "js/MultipleSign.js" %}"></script>17 16 {% block headScript %}{%endblock%} 18 17 </head> -
base/templates/base.vars.javascript.html
rae65f8e ra1de3f1 2 2 <script type="text/javascript"> 3 3 // 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' %}"; 5 8 6 9 </script> -
eventos/forms.py
ra4764f9 rad59aa1 44 44 'placeholder': 'Subir Archivo', 45 45 'accept': '.pdf'}) 46 self.fields['pos_x'].widget = forms.HiddenInput() 47 self.fields['pos_y'].widget = forms.HiddenInput() 46 48 47 49 class FirmaEventoForm(forms.Form): -
eventos/models.py
r61f3a75 rad59aa1 14 14 fecha = models.DateField(null=False) 15 15 serial = models.CharField(max_length=128) 16 pos_x = models.CharField(max_length=32) 17 pos_y = models.CharField(max_length=32) 16 18 activo = models.BooleanField(default=True) 17 19 -
participantes/views.py
r27c0bd4 rd17da63 2 2 from django.http import JsonResponse 3 3 from django.views import View 4 from django.utils.decorators import method_decorator 5 from django.views.decorators.csrf import csrf_exempt 4 6 5 7 from .models import ( … … 41 43 return JsonResponse(data,safe=False) 42 44 43 45 @method_decorator(csrf_exempt, name='dispatch') 44 46 class AjaxParticipanteFirmaEvento(View): 45 47 """! … … 69 71 serial = request.POST.get('serial', None) 70 72 pasaporte = request.POST.get('pasaporte', None) 73 pasaporte = request.POST.get('pasaporte', None) 71 74 if evento_id is not None and pasaporte is not None: 72 75 if serial is not None: 73 76 try: 74 update_evento = self.model.object .get(pk=evento_id)77 update_evento = self.model.objects.get(pk=evento_id) 75 78 update_evento.serial = serial 76 79 update_evento.save() … … 81 84 mensaje += 'No existe el evento que desea actualizar \n' 82 85 try: 83 participante = Participante.object .get(pasaporte=pasaporte)86 participante = Participante.objects.get(pasaporte=pasaporte) 84 87 except Exception as e: 85 88 print (e) … … 88 91 participantes que se ecuentran registrados \n' 89 92 try: 90 update_parti_event = self.model_participante.object .get(93 update_parti_event = self.model_participante.objects.get( 91 94 fk_participante=participante.pk, 92 95 fk_evento=evento_id) -
static/js/funciones.js
rb84cfca ra1de3f1 28 28 $.getJSON(url, function(data){ 29 29 if (Object.keys(data).length > 0) { 30 construir_datos(data .datos);30 construir_datos(data); 31 31 } 32 32 else{ … … 65 65 */ 66 66 function construir_datos(data) { 67 firma = data.firmo; 68 data = data.datos; 67 69 $('#datos_paricipante').html(''); 68 70 html = '<ul class="collection">' … … 72 74 html += '<li class="collection-item"><b>Correo: </b>'+data.correo+'</li>'; 73 75 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+'">'; 75 77 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 } 78 85 $('#datos_paricipante').html(html); 79 86 } 87 88 /** 89 * Función para obtener el certificado del participante 90 * @param fileId Recibe el id del documento 91 */ 92 function 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 */ 138 function 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 */ 187 function 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 */ 212 function 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.