Ejemplo n.º 1
0
def sign_up1(request, my_id,  rvolt, rcurrent, yvolt, ycurrent,  bvolt, bcurrent , battery):
    print("Sign up 1")
    if request.method == 'GET':
        print(request.method)
        # pi = get_object_or_404(OnoffValue, pk=my_id)
        try:
            pst = ValueOfSpliteData(id=my_id, rvolt=rvolt,rcurrent=rcurrent,yvolt=yvolt,ycurrent=ycurrent,bvolt=bvolt,bcurrent=bcurrent,battery=battery)
            pst.save()

        except:
            pass



        try:
            pi = OnoffValue.objects.get(pk=my_id)
        except:
            data = OnoffValue(id=my_id,ronoff='0', yonoff='0', bonoff='0')
            data.save()
            pi = OnoffValue.objects.get(pk=my_id)
            print(pi)
        return render(request, 'blog/deviceresponce.html',{'form': pi}) 
Ejemplo n.º 2
0
def roff_data(request, my_id, my_value):
    if request.user.is_authenticated:
        print(request.method)
        if request.method == 'GET':
            
            try:
                print("try")
                student = OnoffValue.objects.get(pk=my_id)
                pst = OnoffValue(id=my_id, ronoff=my_value, yonoff=student.yonoff, bonoff=student.bonoff)
                pst.save()
            except:
                print("except")
                data = OnoffValue(id=my_id,ronoff='0', yonoff='0', bonoff='0')
                data.save()
                student = OnoffValue.objects.get(pk=my_id)
                pst = OnoffValue(id=my_id, ronoff=my_value, yonoff=student.yonoff, bonoff=student.bonoff)
                pst.save()
            return HttpResponseRedirect('/showdataindividual/'+ str(my_id) + '/')
    else:
        return HttpResponseRedirect('/login/')