Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
[BE][은서] :: 전체 게시판 뷰수정, 배포를 위한 셋팅
Browse files Browse the repository at this point in the history
[BE][은서] :: 전체 게시판 뷰수정, 배포를 위한 셋팅
  • Loading branch information
eunseoJeong authored Nov 19, 2021
2 parents 18a4985 + d24b398 commit 489cfea
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 97 deletions.
Binary file added requirements.txt
Binary file not shown.
188 changes: 92 additions & 96 deletions school/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,78 +287,76 @@ def study_detail(request, id):
print(detail_notice)
return render(request, 'notice_detail.html', {'detail_notice':detail_notice})

#공지사항 update
#스터디게시판 update
@login_required
@staff_member_required
def notice_edit(request, id):
notice = Notice.objects.get(id = id)
return render(request, 'notice_edit.html', {'notice': notice})
def study_edit(request, id):
study = Study_board.objects.get(id = id)
return render(request, 'study_edit.html', {'study': study})

def notice_update(request, id):
notice_update = Notice.objects.get(id = id)
def study_update(request, id):
study_update = Study_board.objects.get(id = id)
user_id = request.user.id
# user_id 값과 User 모델의 객체 중 일치하는 값. 즉 글 작성자의 user 객체를 user 변수에 저장합니다.
user = User.objects.get(id = user_id)
notice_update.Notice_title = request.POST['title']
notice_update.Notice_author = user
notice_update.Notice_image = request.FILES.get('image')
notice_update.Notice_body = request.POST['body']
notice_update.Notice_pub_date = timezone.now()
notice_update.save()
return redirect('notice_detail', notice_update.id)

#공지사항 delete
@login_required
@staff_member_required
def notice_delete(request, id):
notice_delete = Notice.objects.get(id = id)
study_update.Study_title = request.POST['title']
study_update.Study_author = user
study_update.Study_image = request.FILES.get('image')
study_update.Study_body = request.POST['body']
study_update.Study_pub_date = timezone.now()
study_update.save()
return redirect('study_detail', study_update.id)

#스터디게시판 delete
@login_required
def study_delete(request, id):
study_delete = Study_board.objects.get(id = id)
user_id = request.user.id
save_score = User.objects.get(id = user_id)
save_score.rank_count -= 1
save_score.save()
notice_delete.delete()
return redirect('notice')
study_delete.delete()
return redirect('study')


#****공지사항 댓글*******
#****스터디게시판 댓글*******
@login_required
def create_notice_comment(request, notice_id):
def create_study_comment(request, study_id):
if request.method == 'POST':
notice_comment = Notice_Comment()
study_comment = Study_Comment()
user_id = request.user.id
user = User.objects.get(id = user_id)
print(user)
# 작성자 = user 가 됩니다.
notice_comment.notice = get_object_or_404(Notice, pk=notice_id)
notice_comment.notice_author = user
notice_comment.notice_content = request.POST['content']
notice_comment.notice_at = timezone.datetime.now()
notice_comment.save()
return redirect('notice_detail', notice_id)
study_comment.study = get_object_or_404(Study_board, pk=study_id)
study_comment.study_author = user
study_comment.study_content = request.POST['content']
study_comment.study_at = timezone.datetime.now()
study_comment.save()
return redirect('study_detail', study_id)

# 공지사항 댓글 delete
# 스터디 댓글 delete
@login_required
def delete_notice_comment(request, id, comment_id):
delete_notice_comment = Notice_Comment.objects.get(pk = comment_id)
delete_notice_comment.delete()
return redirect('notice_detail', id)
def delete_study_comment(request, id, comment_id):
delete_study_comment = Study_Comment.objects.get(pk = comment_id)
delete_study_comment.delete()
return redirect('study_detail', id)

# 공지사항 댓글 update
# 스터디 댓글 update
@login_required
def update_notice_comment(request, id, comment_id):
def update_study_comment(request, id, comment_id):
if request.method == 'POST':
user_id = request.user.id
# user_id 값과 User 모델의 객체 중 일치하는 값. 즉 글 작성자의 user 객체를 user 변수에 저장합니다.
user = User.objects.get(id = user_id)
update_notice_comment = get_object_or_404(Notice_Comment, pk=comment_id)
update_notice_comment.notice_author = user
update_notice_comment.notice_content = request.POST['content']
update_notice_comment.save()
return redirect('notice_detail', id)
update_study_comment = get_object_or_404(Study_Comment, pk=comment_id)
update_study_comment.study_author = user
update_study_comment.study_content = request.POST['content']
update_study_comment.save()
return redirect('study_detail', id)
else:
notice = get_object_or_404(Notice, pk=id)
comment = get_object_or_404(Notice_Comment, pk=comment_id)
return render(request, 'notice_comment_edit.html', {'notice':notice, 'comment':comment})
study = get_object_or_404(Study_board, pk=id)
comment = get_object_or_404(Study_Comment, pk=comment_id)
return render(request, 'study_comment_edit.html', {'study':study, 'comment':comment})



Expand Down Expand Up @@ -392,93 +390,91 @@ def contest_post(request):
else:
return render(request, 'contest_new.html')

#공지사항 detail
#공모전 detail
@login_required
def notice_detail(request, id):
detail_notice = get_object_or_404(Notice, pk = id)
print(detail_notice)
return render(request, 'notice_detail.html', {'detail_notice':detail_notice})
def contest_detail(request, id):
detail_contest = get_object_or_404(Contest_board, pk = id)
print(detail_contest)
return render(request, 'contest_detail.html', {'detail_contest':detail_contest})

#공지사항 update
#공모전 update
@login_required
@staff_member_required
def notice_edit(request, id):
notice = Notice.objects.get(id = id)
return render(request, 'notice_edit.html', {'notice': notice})
def contest_edit(request, id):
contest = Contest_board.objects.get(id = id)
return render(request, 'contest_edit.html', {'contest': contest})

def notice_update(request, id):
notice_update = Notice.objects.get(id = id)
def contest_update(request, id):
contest_update = Contest_board.objects.get(id = id)
user_id = request.user.id
# user_id 값과 User 모델의 객체 중 일치하는 값. 즉 글 작성자의 user 객체를 user 변수에 저장합니다.
user = User.objects.get(id = user_id)
notice_update.Notice_title = request.POST['title']
notice_update.Notice_author = user
notice_update.Notice_image = request.FILES.get('image')
notice_update.Notice_body = request.POST['body']
notice_update.Notice_pub_date = timezone.now()
notice_update.save()
return redirect('notice_detail', notice_update.id)

#공지사항 delete
@login_required
@staff_member_required
def notice_delete(request, id):
notice_delete = Notice.objects.get(id = id)
contest_update.Contest_title = request.POST['title']
contest_update.Contest_author = user
contest_update.Contest_image = request.FILES.get('image')
contest_update.Contest_body = request.POST['body']
contest_update.Contest_pub_date = timezone.now()
contest_update.save()
return redirect('contest_detail', contest_update.id)

#공모전 delete
@login_required
def contest_delete(request, id):
contest_delete = Contest_board.objects.get(id = id)
user_id = request.user.id
save_score = User.objects.get(id = user_id)
save_score.rank_count -= 1
save_score.save()
notice_delete.delete()
return redirect('notice')
contest_delete.delete()
return redirect('contest')


#****공지사항 댓글*******
@login_required
def create_notice_comment(request, notice_id):
def create_contest_comment(request, contest_id):
if request.method == 'POST':
notice_comment = Notice_Comment()
contest_comment = Contest_Comment()
user_id = request.user.id
user = User.objects.get(id = user_id)
print(user)
# 작성자 = user 가 됩니다.
notice_comment.notice = get_object_or_404(Notice, pk=notice_id)
notice_comment.notice_author = user
notice_comment.notice_content = request.POST['content']
notice_comment.notice_at = timezone.datetime.now()
notice_comment.save()
return redirect('notice_detail', notice_id)
contest_comment.contest = get_object_or_404(Contest_board, pk=contest_id)
contest_comment.contest_author = user
contest_comment.contest_content = request.POST['content']
contest_comment.contest_at = timezone.datetime.now()
contest_comment.save()
return redirect('contest_detail', contest_id)

# 공지사항 댓글 delete
@login_required
def delete_notice_comment(request, id, comment_id):
delete_notice_comment = Notice_Comment.objects.get(pk = comment_id)
delete_notice_comment.delete()
return redirect('notice_detail', id)
def delete_contest_comment(request, id, comment_id):
delete_contest_comment = Contest_Comment.objects.get(pk = comment_id)
delete_contest_comment.delete()
return redirect('contest_detail', id)

# 공지사항 댓글 update
@login_required
def update_notice_comment(request, id, comment_id):
def update_contest_comment(request, id, comment_id):
if request.method == 'POST':
user_id = request.user.id
# user_id 값과 User 모델의 객체 중 일치하는 값. 즉 글 작성자의 user 객체를 user 변수에 저장합니다.
user = User.objects.get(id = user_id)
update_notice_comment = get_object_or_404(Notice_Comment, pk=comment_id)
update_notice_comment.notice_author = user
update_notice_comment.notice_content = request.POST['content']
update_notice_comment.save()
return redirect('notice_detail', id)
update_contest_comment = get_object_or_404(Contest_Comment, pk=comment_id)
update_contest_comment.contest_author = user
update_contest_comment.contest_content = request.POST['content']
update_contest_comment.save()
return redirect('contest_detail', id)
else:
notice = get_object_or_404(Notice, pk=id)
comment = get_object_or_404(Notice_Comment, pk=comment_id)
return render(request, 'notice_comment_edit.html', {'notice':notice, 'comment':comment})
contest = get_object_or_404(Contest_board, pk=id)
comment = get_object_or_404(Contest_Comment, pk=comment_id)
return render(request, 'contest_comment_edit.html', {'contest':contest, 'comment':comment})



### 졸업생 게시판
@login_required
def graduate_board(request):
Graduate_boards = Graduate_board.objects.all()
return render(request, 'graduate.html',{'Graduate_boards':Graduate_boards})
graduate_boards = Graduate_board.objects.all()
return render(request, 'graduate.html',{'graduate_boards':graduate_boards})

# 졸업생게시판 create
@login_required
Expand Down
2 changes: 1 addition & 1 deletion school_ties/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_secret(setting, secrets=secrets):
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ["*"]

AUTH_USER_MODEL = 'account.User'

Expand Down

0 comments on commit 489cfea

Please sign in to comment.