def reservar(request): if request.method == 'POST': form = ReservarTurnoForm(request.POST) if form.is_valid(): service = ReservaTurnosService() try: reserva = service.crear_reserva(form.cleaned_data['afiliado'], form.cleaned_data['telefono'], [form.cleaned_data['turno']]) except Exception, e: messages.error(request, __getExceptionMessage(e)) else: messages.success(request, u'Turno reservado con éxito') return HttpResponseRedirect(request.path)
def crear_turnos(request): b = Bussiness() if request.method == 'POST': form = CrearTurnoForm(request.POST) if form.is_valid(): logger.info("<%s> esta creando turnos" % request.user.username) service = ReservaTurnosService() creados = service.crear_turnos(dias=form.cleaned_data['dias']) if creados: messages.success(request, u'%s Turnos creados con éxito' % len(creados)) else: messages.warning(request, u'No se creó ningún turno, puede que ya se \ crearon con anterioridad') return HttpResponseRedirect(request.path) else: hasta = (timezone.now() + datetime.timedelta(days=b.DIAS-1)).strftime("%d-%m-%Y") last = Turno.objects.order_by('fecha').last() frecuencia = b.MINUTOS form = CrearTurnoForm(initial={'dias':b.DIAS}) historial = b.get_historial_creacion_turnos() return render(request, "turno/creacion.html", locals())