Changeset 452668a in firmaeventos
- Timestamp:
- Nov 27, 2017, 10:46:54 AM (6 years ago)
- Branches:
- master
- Children:
- 163d273
- Parents:
- 2b66ea3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
base/templates/base.vars.javascript.html
r5d88f36 r452668a 9 9 // URL para comprobar si el firmante es el último 10 10 var URL_ULTIMO_FIRMANTE = "{% url 'participantes:participante_restante_evento_nid' %}"; 11 12 // URL para comprobar si el documento esta siendo firmado 13 var URL_COMPROBAR_FIRMA = "{% url 'events:comprobar_evento_nid' %}"; 14 11 15 12 16 </script> -
eventos/urls.py
r2b66ea3 r452668a 13 13 url(r'^detail-evento/(?P<pk>\d+)$', DetailEvent.as_view(), 14 14 name='detail_event'), 15 url(r'^comprobar-evento/(?P<event_id>\d+)$', EventoProcesado.as_view(), 16 name='comprobar_evento'), 15 17 url(r'^comprobar-evento/$', EventoProcesado.as_view(), 16 name='comprobar_evento '),18 name='comprobar_evento_nid'), 17 19 ] -
eventos/views.py
r3ae7c21 r452668a 10 10 from django.core.urlresolvers import reverse_lazy 11 11 from django.http import JsonResponse 12 from django.utils.decorators import method_decorator 13 from django.views.decorators.csrf import csrf_exempt 12 14 from django.shortcuts import ( 13 15 redirect … … 184 186 return context 185 187 186 188 @method_decorator(csrf_exempt, name='dispatch') 187 189 class EventoProcesado(View): 188 190 """! … … 196 198 model = Evento 197 199 198 def get(self, request ):200 def get(self, request, event_id): 199 201 """! 200 202 Metodo que permite verificar si el documento esta procesado … … 206 208 @return Retorna un Json con la respuesta 207 209 """ 208 evento_id = request.GET.get('event_id', None)209 210 mensaje = '' 210 211 procesando = False 211 if event o_id is not None:212 if event_id is not None: 212 213 try: 213 evento_pro = self.model.objects.get(pk=event o_id)214 evento_pro = self.model.objects.get(pk=event_id) 214 215 except: 215 216 print(e) … … 231 232 return JsonResponse(data, safe=False) 232 233 233 def post(self, request ):234 def post(self, request, event_id): 234 235 """! 235 236 Metodo que permite cambiar el valor procesado al evento … … 241 242 @return Retorna un Json con la respuesta 242 243 """ 243 evento_id = request.POST.get('event_id', None) 244 if evento_id is not None: 244 if event_id is not None: 245 245 try: 246 evento = self.model.objects.get(pk=event o_id)246 evento = self.model.objects.get(pk=event_id) 247 247 evento.procesando = not evento.procesando 248 248 evento.save() … … 251 251 print(e) 252 252 validado = False 253 return JsonResponse( validado, safe=False)253 return JsonResponse({'validate': validado}, safe=False) -
static/js/funciones.js
r3ae7c21 r452668a 80 80 } 81 81 else{ 82 html += '<a type="button" id="firmar" class="btn waves-effect blue darken-1" onclick=" ObtenerCertificadoFirmanteMultiples(\''+data.documento+'\')">';82 html += '<a type="button" id="firmar" class="btn waves-effect blue darken-1" onclick="comprobarFirma(\''+data.documento+'\')">'; 83 83 html += '<i class="material-icons left">mode_edit</i> Firmar</a>'; 84 84 } … … 87 87 88 88 /** 89 * Función para comprobar firma 90 * @param fileId Recibe el id del documento 91 */ 92 function comprobarFirma(fileId){ 93 var routes = $(location).attr('pathname').split('/'); 94 var pk = routes[routes.length-1]; 95 $.ajax({ 96 type: 'GET', 97 async: false, 98 url:URL_COMPROBAR_FIRMA+pk, 99 success: function(datos){ 100 if (datos.validate==true) { 101 simple_modal(datos.mensaje); 102 } 103 else{ 104 $.ajax({ 105 type: 'POST', 106 async: false, 107 url:URL_COMPROBAR_FIRMA+pk, 108 success: function(datos){ 109 if (datos.validate==true) { 110 ObtenerCertificadoFirmanteMultiples(fileId,pk); 111 } 112 else{ 113 simple_modal("Ocurrió un error al actualizar los datos"); 114 } 115 }, 116 error: function(jqXHR, textStatus, errorThrown){ 117 console.log('error: ' + textStatus); 118 } 119 }); 120 } 121 }, 122 error: function(jqXHR, textStatus, errorThrown){ 123 console.log('error: ' + textStatus); 124 } 125 }); 126 } 127 128 /** 89 129 * Función para obtener el certificado del participante 90 130 * @param fileId Recibe el id del documento 91 */ 92 function ObtenerCertificadoFirmanteMultiples(fileId){ 131 * @param pk Recibe el id del evento 132 */ 133 function ObtenerCertificadoFirmanteMultiples(fileId,pk){ 93 134 var xPos = yPos= signaturePage = ""; 94 135 var lastSignature = false; 95 var routes = $(location).attr('pathname').split('/');96 var pk = routes[routes.length-1];97 136 98 137 $.ajax({ … … 125 164 126 165 // ahora llamar al ajax de obtener la resena del pdf 127 ObtenerHashPDFServerMultiples(parameters, cert );166 ObtenerHashPDFServerMultiples(parameters, cert, pk); 128 167 129 168 }, … … 139 178 error = "No hay soporte para el manejo del certificado"; 140 179 } 180 $.ajax({ 181 type: 'POST', 182 async: false, 183 url:URL_COMPROBAR_FIRMA+pk, 184 success: function(datos){ 185 console.log(datos); 186 }, 187 error: function(jqXHR, textStatus, errorThrown){ 188 console.log('error: ' + textStatus); 189 } 190 }); 141 191 simple_modal(error); 142 192 } … … 155 205 * @param parameters Recibe los parametros 156 206 * @param cert Recibe los certificados 157 */ 158 function ObtenerHashPDFServerMultiples(parameters,cert){ 207 * @param pk Recibe el id del evento 208 */ 209 function ObtenerHashPDFServerMultiples(parameters,cert,pk){ 159 210 160 211 $.ajax({ … … 175 226 window.hwcrypto.sign(cert, {type: hashtype, hex: hash}, {lang: lang}).then( 176 227 function(signature) { 177 FinalizarFirmaMultiples(signature.hex );228 FinalizarFirmaMultiples(signature.hex, pk); 178 229 }, 179 230 function(err) { … … 188 239 error = "No hay soporte para el manejo del certificado"; 189 240 } 241 $.ajax({ 242 type: 'POST', 243 async: false, 244 url:URL_COMPROBAR_FIRMA+pk, 245 success: function(datos){ 246 console.log(datos); 247 }, 248 error: function(jqXHR, textStatus, errorThrown){ 249 console.log('error: ' + textStatus); 250 } 251 }); 190 252 simple_modal(error); 191 253 }); … … 202 264 * Función para enviar la firma al servidor 203 265 * @param signature Recibe la firma 204 */ 205 function FinalizarFirmaMultiples(signature){ 266 * @param pk Recibe el id del evento 267 */ 268 function FinalizarFirmaMultiples(signature, pk){ 206 269 207 270 $.ajax({ … … 215 278 success: function(data, textStatus, jqXHR){ 216 279 actualizar_participante(data['signedFileId']); 280 $.ajax({ 281 type: 'POST', 282 async: false, 283 url:URL_COMPROBAR_FIRMA+pk, 284 success: function(datos){ 285 console.log(datos); 286 }, 287 error: function(jqXHR, textStatus, errorThrown){ 288 console.log('error: ' + textStatus); 289 } 290 }); 217 291 }, 218 292 error: function(jqXHR, textStatus, errorThrown){ 219 293 console.log('error en pdfs/resenas: ' + textStatus); 294 $.ajax({ 295 type: 'POST', 296 async: false, 297 url:URL_COMPROBAR_FIRMA+pk, 298 success: function(datos){ 299 console.log(datos); 300 }, 301 error: function(jqXHR, textStatus, errorThrown){ 302 console.log('error: ' + textStatus); 303 } 304 }); 220 305 } 221 306 });
Note: See TracChangeset
for help on using the changeset viewer.