From cc233108cde60ade374ef89b5f799db4361c88b2 Mon Sep 17 00:00:00 2001 From: Fran Exposito <8macau8@gmail.com> Date: Mon, 15 Jun 2015 08:55:15 +0200 Subject: [PATCH] confirmar asistencia --- _dt/js/event.js | 25 ++++++++++++++++++++++++- _oo/model/controladorEvento.py | 21 +++++++++++++++++++++ index.py | 18 ++++++++++++++++++ templates/templateEvents.html | 11 +++++++---- 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/_dt/js/event.js b/_dt/js/event.js index 8bdd42a..5a683bd 100644 --- a/_dt/js/event.js +++ b/_dt/js/event.js @@ -58,7 +58,7 @@ $(document).ready(function() { data: data, dataType: 'json', success: function(resp) { - var as = ''+data.nombre+''+data.apellidos+''+data.dni+'No ha asistido'; + var as = ''+data.nombre+''+data.apellidos+''+data.dni+'No ha asistido'; $('#modalAsistente').modal('hide'); $('.tasistentes').append(as); @@ -66,6 +66,29 @@ $(document).ready(function() { }); }); + $('.asitencia-button').on('click', function(evt) { + evt.preventDefault(); + var bt = $(this); + var data = { + 'idE': $('.event-content').data('id'), + 'dni': $(this).data('id') + }; + + $.ajax({ + type: 'POST', + url: '/cAsistente', + data: data, + dataType: 'json', + success: function(resp) { + if (resp.response === 'true') { + $(bt).hide(); + } else { + alert ('Ha habido un error'); + } + } + }); + }); + $('#iponente').on('submit', function(evt) { evt.preventDefault(); var email = $('#email-p').val(); diff --git a/_oo/model/controladorEvento.py b/_oo/model/controladorEvento.py index aec2034..8085984 100644 --- a/_oo/model/controladorEvento.py +++ b/_oo/model/controladorEvento.py @@ -157,3 +157,24 @@ def setPonente(idP, idE): evento = Evento().get_by_id(int(idE)) evento.ponentes.append(str(idP)) evento.put() + +def deleteAsistente(idE, dni): + index = 0 + e = Evento().get_by_id(idE) + for a in e.asistentes: + if a.dni == dni: + del e.asistentes[index] + e.put() + return + index = index + 1 + + +def confirmarAsistente(idE, dni): + e = Evento().get_by_id(int(idE)) + logging.getLogger().setLevel(logging.DEBUG) + logging.error(dni) + for a in e.asistentes: + if a.dni == dni: + a.asistido = True + e.put() + return diff --git a/index.py b/index.py index 550e181..46b8a53 100644 --- a/index.py +++ b/index.py @@ -795,6 +795,22 @@ def post(self): controladorUsuario.deletePonente(idP, user.getKey()) self.response.write(json.dumps({'response': 'true'})) +class BorrarAsistente(webapp2.RequestHandler): + def post(self): + user = controladorUsuario.getUsuarioLogeado(self) + idE = self.request.get('idE').strip() + dni = self.request.get('dni').strip() + controladorEvento.deleteAsistente(idE, dni) + self.response.write(json.dumps({'response': 'true'})) + +class ConfirmarAsistente(webapp2.RequestHandler): + def post(self): + user = controladorUsuario.getUsuarioLogeado(self) + idE = self.request.get('idE').strip() + dni = self.request.get('dni').strip() + controladorEvento.confirmarAsistente(idE, dni) + self.response.write(json.dumps({'response': 'true'})) + application = webapp2.WSGIApplication([ ('/', Index), @@ -821,6 +837,8 @@ def post(self): ('/mUsuario', ModificarUsuario), ('/moOrganizacion', ModificarOrganizacion), ('/bPonente', BorrarPonente), + ('/dAsistente', BorrarAsistente), + ('/cAsistente', ConfirmarAsistente), ('/.*', MostrarError) ], debug=True) diff --git a/templates/templateEvents.html b/templates/templateEvents.html index a63247f..026b0d7 100644 --- a/templates/templateEvents.html +++ b/templates/templateEvents.html @@ -113,8 +113,9 @@
UbicaciĆ³n
Apellidos Indetificacion - - + Confirmar + Eliminar + Diploma @@ -125,11 +126,13 @@
UbicaciĆ³n
{{ a.dni }} {% if a.asistido %} Asistido + {% else %} No ha asistido + {% endif %} - - + + {% endfor %}