Skip to content

Commit

Permalink
Merge pull request #293 from evenge/fran
Browse files Browse the repository at this point in the history
confirmar asistencia
  • Loading branch information
camtes committed Jun 15, 2015
2 parents fd444f8 + cc23310 commit 823375a
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 5 deletions.
25 changes: 24 additions & 1 deletion _dt/js/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,37 @@ $(document).ready(function() {
data: data,
dataType: 'json',
success: function(resp) {
var as = '<tr><th>'+data.nombre+'</th><th>'+data.apellidos+'</th><th>'+data.dni+'</th><th>No ha asistido</th><th><button data-id="" class="btn btn-default delete-button"><i class="fa fa-times"></i></button></th><th><button data-id="" class="btn btn-default pdf-button"><i class="fa fa-file-pdf-o"></i></button></th></tr>';
var as = '<tr><th>'+data.nombre+'</th><th>'+data.apellidos+'</th><th>'+data.dni+'</th><th>No ha asistido</th><th><button data-id="'+data.dni+'" class="btn btn-default asitencia-button"><i class="fa fa-check fa-fw"></i></button></th><th><button data-id="'+data.dni+'" class="btn btn-default delete-button"><i class="fa fa-times"></i></button></th><th><button data-id="'+data.dni+'" class="btn btn-default pdf-button"><i class="fa fa-file-pdf-o"></i></button></th></tr>';

$('#modalAsistente').modal('hide');
$('.tasistentes').append(as);
}
});
});

$('.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();
Expand Down
21 changes: 21 additions & 0 deletions _oo/model/controladorEvento.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 18 additions & 0 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -821,6 +837,8 @@ def post(self):
('/mUsuario', ModificarUsuario),
('/moOrganizacion', ModificarOrganizacion),
('/bPonente', BorrarPonente),
('/dAsistente', BorrarAsistente),
('/cAsistente', ConfirmarAsistente),
('/.*', MostrarError)
], debug=True)

Expand Down
11 changes: 7 additions & 4 deletions templates/templateEvents.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ <h5>Ubicación</h5>
<th>Apellidos</th>
<th>Indetificacion</th>
<th></th>
<th></th>
<th></th>
<th>Confirmar</th>
<th>Eliminar</th>
<th>Diploma</th>
</tr>
</thead>
<tbody class="tasistentes">
Expand All @@ -125,11 +126,13 @@ <h5>Ubicación</h5>
<th>{{ a.dni }}</th>
{% if a.asistido %}
<th>Asistido</th>
<th></th>
{% else %}
<th>No ha asistido</th>
<th><button data-id="{{ a.dni }}" class="btn btn-default asitencia-button"><i class="fa fa-check fa-fw"></i></button></th>
{% endif %}
<th><button data-id="" class="btn btn-default delete-button"><i class="fa fa-times"></i></button></th>
<th><button data-id="" class="btn btn-default pdf-button"><i class="fa fa-file-pdf-o"></i></button></th>
<th><button data-id="{{ a.dni }}" class="btn btn-default delete-button"><i class="fa fa-times fa-fw"></i></button></th>
<th><button data-id="{{ a.dni }}" class="btn btn-default pdf-button"><i class="fa fa-file-pdf-o fa-fw"></i></button></th>
</tr>
{% endfor %}
</tbody>
Expand Down

0 comments on commit 823375a

Please sign in to comment.