Example #1
0
def alarm(request, tipo):
    if request.user.is_superuser:
        if request.POST:
            state = int(request.POST.get("optradio"))
            estado(state)
        return render_to_response("alarma.html", {"alarma": int(tipo)}, context_instance=RequestContext(request))
    else:
        return HttpResponseRedirect("/")
Example #2
0
def alarm(request, tipo):
    if request.user.is_superuser:
        if request.POST:
            state = int(request.POST.get('optradio'))
            estado(state)
        return render_to_response('alarma.html', {'alarma': int(tipo)},
                                  context_instance=RequestContext(request))
    else:
        return HttpResponseRedirect('/')
Example #3
0
def base():
    x = datetime.datetime.now()
    dicdias = {'MONDAY': 1, 'TUESDAY': 2, 'WEDNESDAY': 3, 'THURSDAY': 4,
               'FRIDAY': 5, 'SATURDAY': 6, 'SUNDAY': 7}
    anho = x.year
    mes = x.month
    dia = x.day
    fecha = datetime.date(anho, mes, dia)
    diactual = dicdias[fecha.strftime('%A').upper()]
    for tiempo in Tiempo.objects.all().raw(
            "Select * From Alarma_tiempo Where tiempo_dia = %s AND tiempo_status = 'Active' Order by tiempo_hora",
            [diactual]):
        x = datetime.datetime.now()
        if tiempo.tiempo_minuto == 0:
            if tiempo.tiempo_hora == x.hour and 59 == x.minute:
                sleep(60 - x.second)
                estado(tiempo.tiempo_tipo)
        else:
            if tiempo.tiempo_hora == x.hour and tiempo.tiempo_minuto - 1 == x.minute:
                sleep(60 - x.second)
                estado(tiempo.tiempo_tipo)