Example #1
0
def updateform(request):
    authuser = request.session.get('authuser')  # 로그인이 안된 상태에서의 접근인지 확인.
    if authuser is None:
        return HttpResponseRedirect('/user/loginform')

    no = request.GET['no']
    result = models.listbyno(no)
    if result['bno'] != authuser['no']:  # 비정상 로그인일 때.
        return HttpResponseRedirect('/')

    data = {'result': result}
    return render(request, 'board/updateform.html', data)
Example #2
0
def update(request):
    authuser = request.session.get('authuser')  # 로그인이 안된 상태에서의 접근인지 확인.
    if authuser is None:
        return HttpResponseRedirect('/user/loginform')

    ano = request.POST['post_id']
    result = models.listbyno(ano)
    if result['bno'] != authuser['no']:  # 비정상 로그인일 때 메인으로.
        return HttpResponseRedirect('/')
    title = request.POST['title']
    contents = request.POST['contents']

    models.update(ano, title, contents)
    return HttpResponseRedirect(f'/board/view?no={ano}')
Example #3
0
def reply(request):
    authuser = request.session.get('authuser')  # 로그인이 안된 상태에서의 접근인지 확인.
    if authuser is None:
        return HttpResponseRedirect('/user/loginform')

    user_no = authuser['no']  # 'no' = user_no
    ano = request.POST['post_id']
    result = models.listbyno(ano)
    title = request.POST['title']
    contents = request.POST['content']
    g_no = result['g_no']
    depth = result['depth'] + 1
    models.insert_reply(title, contents, g_no, depth, user_no)
    return HttpResponseRedirect('/board')
Example #4
0
def delete(request):
    authuser = request.session.get('authuser')  # 로그인이 안된 상태에서의 접근인지 확인.
    if authuser is None:
        return HttpResponseRedirect('/user/loginform')

    no = request.POST['post_id']
    result = models.listbyno(no)
    if result['bno'] != authuser['no']:  # 비정상 로그인일 때.
        return HttpResponseRedirect('/')

    password = request.POST['password']
    user_id = models.findby_no_and_pw(no, password)
    if user_id is None:
        return HttpResponseRedirect(f'/board/deleteform?no={no}&result=fail')

    models.deleteby_no(no)

    return HttpResponseRedirect('/board')
Example #5
0
def view(request):
    no = request.GET['no']
    result = models.listbyno(no)
    data = {'result': result}
    return render(request, 'board/view.html', data)