Ejemplo n.º 1
0
def write_to_board(request, lease_code=1, row=0, col=0, msg=''):
    if request.method == 'POST':
        lease_code = request.POST['lease_code']
        row = request.POST['row']
        col = request.POST['col']
        msg = request.POST['msg']
    response_data = dict()
    board_lease = get_current_lease(lease_code)

    if board_lease.top_row:
        row = row + board_lease.top_row

    if board_lease.left_col:
        col = col + board_lease.left_col

    if board_lease == None:
        generate_error(response_data, "bad_lease_code")
        add_lease_expiration(response_data, board_lease)
    else:
        peggy_tasks.write_to_board(int(row), int(col),
                                   board_lease.current_color + msg)
        response_data['result'] = "success"
        add_lease_expiration(response_data, board_lease)

    return HttpResponse(json.dumps(response_data), mimetype="application/json")
Ejemplo n.º 2
0
def write_to_board(request, lease_code, row, col, msg):
    response_data = dict()
    if has_current_lease(lease_code) == False:
        response_data['result'] = "failure"
    else:
        peggy_tasks.write_to_board(int(row), int(col), msg)
        response_data['result'] = "success"

    return HttpResponse(json.dumps(response_data), mimetype="application/json")
Ejemplo n.º 3
0
def write_to_board(request, lease_code, row, col, msg):
    response_data = dict()
    board_lease = get_current_lease(lease_code)
    if board_lease == None:
        response_data['result'] = "failure"
        response_data['reason_code'] = "bad_lease_code"
    else:
        peggy_tasks.write_to_board(int(row), int(col), board_lease.current_color + msg)
        response_data['result'] = "success"

    return HttpResponse(json.dumps(response_data), mimetype="application/json")
Ejemplo n.º 4
0
def write_to_board(request, lease_code=1, row=0, col=0, msg=''):
    if request.method == 'POST':
        lease_code = request.POST['lease_code']
        row = request.POST['row']
        col = request.POST['col']
        msg = request.POST['msg']
    response_data = dict()
    board_lease = get_current_lease(lease_code)
    if board_lease == None:
        response_data['result'] = "failure"
        response_data['reason_code'] = "bad_lease_code"
    else:
        peggy_tasks.write_to_board(int(row), int(col), board_lease.current_color + msg)
        response_data['result'] = "success"

    return HttpResponse(json.dumps(response_data), mimetype="application/json")
Ejemplo n.º 5
0
def write_to_board(request, lease_code=1, row=0, col=0, msg=""):
    if request.method == "POST":
        lease_code = request.POST["lease_code"]
        row = request.POST["row"]
        col = request.POST["col"]
        msg = request.POST["msg"]
    response_data = dict()
    board_lease = get_current_lease(lease_code)

    if board_lease.top_row:
        row = row + board_lease.top_row

    if board_lease.left_col:
        col = col + board_lease.left_col

    if board_lease == None:
        generate_error(response_data, "bad_lease_code")
        add_lease_expiration(response_data, board_lease)
    else:
        peggy_tasks.write_to_board(int(row), int(col), board_lease.current_color + msg)
        response_data["result"] = "success"
        add_lease_expiration(response_data, board_lease)

    return HttpResponse(json.dumps(response_data), mimetype="application/json")