Skip to content

Commit

Permalink
file delete error 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
leejaeyeong committed Aug 9, 2019
1 parent 9a0c863 commit 457f37e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion board/templates/board.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h1 style="text-align: center;">GaSiRi Let's get it! man~</h1>
{% else %}
<button type="button" onclick="alert('로그인을 해주세요'); location.replace('../accounts/login/');" class="btn btn-danger" style="float: right;">글쓰기</button>
{% endif %}

<div style="margin-bottom:60px;"></div>
</div>


Expand Down
5 changes: 4 additions & 1 deletion board/templates/board_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
<div class="classframe">

<h1>게시물 등록</h1>
{% if error %}
<script> alert('모든 항목을 입력해주세요.');</script>

{% endif %}
<form method="POST" action="{% url 'board_create'%}" enctype="multipart/form-data" name = "form1">
{% csrf_token %}
<div class="mb-3">
Expand Down Expand Up @@ -129,7 +132,7 @@ <h1>게시물 등록</h1>
break;
case 6 :
$("#file5").remove();
count--;
count = count - 2;
break;
default :
break
Expand Down
24 changes: 15 additions & 9 deletions board/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ def board_new(request) :

def create(request) :
'''
for key in request.POST:
if len(request.POST[key]) == 0:
for key in request.POST:
print("----")
print(request.POST[key])
if len(request.POST[key]) == 0 or request.POST[key] is None :
return render(request, 'board_new.html', {'error': '빈칸이 있습니다.'})
'''

if request.method == 'POST':
boards = Board()

if request.user.id is None :
return render(request, 'accounts/login.html', {'error': '게시물 작성을 위해 로그인해주세요.'})
else :
boards.userId = request.user.id

boards.title = request.POST['title']
boards.order_price = request.POST['order_price']
boards.body = request.POST['body']
Expand Down Expand Up @@ -62,14 +69,14 @@ def create(request) :

count = count + 1

if request.user.username is None :
print("로그인 안됨")





# 보완 - 로그인 상태 아닐 경우,
#if(request.user.username is None)
boards.userId = request.user.id

print(request.user.id )
#boards.userId = request.user.id
## 수정필요 ##

boards.save()
Expand Down Expand Up @@ -100,7 +107,6 @@ def createcomment(request, board_id):
comments.text = request.POST['text']
comments.price = request.POST['price']
comments.post = board_id

comments.save()

return redirect('test', board_id)
Expand Down

0 comments on commit 457f37e

Please sign in to comment.