Beispiel #1
0
def replyadd(request):
    authuser = request.session["authuser"]
    user_id = authuser["id"]

    board = Board()

    board.group_no = request.GET['gno']
    board.title = request.POST['title']
    board.message = request.POST['message']
    board.user_id_id = user_id

    numbers = Board.objects.get(id=request.GET['id'])

    if numbers.order_no == 0:
        board.order_no = numbers.order_no + 1
        board.depth = numbers.depth + 1
    elif numbers.order_no >= 1:
        last_ono = Board.objects.filter(group_no=numbers.group_no).aggregate(
            Max('order_no'))
        board.order_no = last_ono['order_no__max'] + 1

        if board.order_no > numbers.order_no:
            board.order_no = numbers.order_no + 1
            board.depth = numbers.depth + 1
        else:
            last_depth = Board.objects.aggregate(Max('depth'))
            numbers.depth = last_depth['depth__max'] + 1

    board.save()

    return HttpResponseRedirect("/board")
Beispiel #2
0
def write(request):
    print(request.POST)
    user_id = request.POST.get('user_id')
    board = Board()
    board.title = request.POST['title']
    board.message = request.POST['content']
    board.user = User.objects.get(id=user_id)

    board.save()

    return HttpResponseRedirect('/board')
Beispiel #3
0
def add(request):
    authuser = request.session["authuser"]
    user_id = authuser["id"]

    board = Board()

    board.title = request.POST['title']
    board.message = request.POST['message']
    board.user_id_id = user_id

    if request.method == 'POST':
        last_gno = Board.objects.aggregate(Max('group_no'))
        board.group_no = last_gno['group_no__max'] + 1

    board.save()

    return HttpResponseRedirect("/board")