Ejemplo n.º 1
0
def set_status(request, connection_id):
    connection = Connection.objects.get(id=connection_id)
    for i in CodeStatus.objects.filter(connection=connection):
        i.delete()
    status = CodeStatus(connection=connection, status=True)
    status.save()
    return HttpResponse('')
Ejemplo n.º 2
0
def send_code(request):
    connection = Connection.objects.get(id=request.POST['connection_id'])
    for i in UsersCode.objects.filter(connection=connection):
        i.delete()
    code = request.POST['code']
    users_code = UsersCode(connection=connection, code=code)
    users_code.save()
    for i in CodeStatus.objects.filter(connection=connection):
        i.delete()
    status = CodeStatus(connection=connection, status=False)
    status.save()
    if request.user.is_authenticated():
        executed_code = ExecutedCode(connection=connection, code=code, user=request.user)
    else:
        executed_code = ExecutedCode(connection=connection, code=code)
    executed_code.save()
    return HttpResponse(str(users_code.id) + '\n' + users_code.code)