Skip to content

Commit

Permalink
make mypage => 마이페이지 기능 구현
Browse files Browse the repository at this point in the history
- 내가 단 댓글
- 내가 쓴 게시글
- 사용자정보
  • Loading branch information
seung-gyu-kim committed Aug 9, 2019
1 parent 8769f77 commit cb12240
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 57 deletions.
9 changes: 8 additions & 1 deletion accounts/templates/accounts/update.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
<div class="col">
<div class="row">
<div style="border-radius: 5px; border:1px dashed rgb(91,155,213); width:100%; ">

<h1 style="text-align: center;">내가 쓴 게시글</h1>
<div style="padding-top: 20px;"></div>
<div class="flexbox">
<div class="item"><a href="{% url 'update'%}">사용자정보</a></div>
<div class="item"><a href="{% url 'mypageComment'%}">내가 단 댓글</a></div>
<div class="item"><a href="{% url 'mypageBlog'%}">내가 쓴 게시글</a></div>
</div>

{% if error %}
{{ error }}
<br>
Expand Down
2 changes: 1 addition & 1 deletion gasili/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
</li>
{% if user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{% url 'update' %}" style="margin:0 60px 0 60px;" style="padding:0;">Mypage</a>
<a class="nav-link" href="{% url 'mypageBlog' %}" style="margin:0 60px 0 60px;" style="padding:0;">Mypage</a>
</li>
<li class="nav-item">
<a class="nav-link" href="javascript:{document.getElementById('logout').submit()}" style="padding:0;">Logout</a>
Expand Down
51 changes: 0 additions & 51 deletions mypage/templates/mypage/mypage.html

This file was deleted.

49 changes: 49 additions & 0 deletions mypage/templates/mypage/mypageBlog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{% extends 'base.html' %}

{% block content %}
<div class="container-fluid row" style="width:100%; margin:0; padding:0;">
<div class="containerleft">
</div>
<div class="containerbody">
<div class="container" style="margin:0,25px,25px,25px; width:100%;">
<section id="recently">
<div class="col">
<div class="row">
<div style="border-radius: 5px; border:1px dashed rgb(91,155,213); width:100%; ">
<h1 style="text-align: center;">내가 단 댓글</h1>
<div style="padding-top: 20px;"></div>
<div class="flexbox">
<div class="item"><a href="{% url 'update'%}">사용자정보</a></div>
<div class="item"><a href="{% url 'mypageComment'%}">내가 단 댓글</a></div>
<div class="item"><a href="{% url 'mypageBlog'%}">내가 쓴 게시글</a></div>
</div>
<table class="table table-hover">
<thead>
<tr style="text-align: center;">
<th scope="col">순번</th>
<th scope="col">글제목</th>
<th scope="col">글내용</th>
<th scope="col">작성일자</th>
</tr>
</thead>
<tbody>
{% for post in posts %}
<tr onclick="location.href='{% url 'test' post.id %}'" style="text-align: center;">
<th scope="row">{{post.id}}</th>
<td>{{post.title}}</td>
<td>{{post.body| truncatechars:10}}</td>
<td>{{post.date}}</td>
</tr>

{%endfor%}
</tbody>
</table>
</div>
</div>
</div>
</section>
</div>
</div>
<div class="containerright"></div>
</div>
{% endblock %}
49 changes: 49 additions & 0 deletions mypage/templates/mypage/mypageComment.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{% extends 'base.html' %}

{% block content %}
<div class="container-fluid row" style="width:100%; margin:0; padding:0;">
<div class="containerleft">
</div>
<div class="containerbody">
<div class="container" style="margin:0,25px,25px,25px; width:100%;">
<section id="recently">
<div class="col">
<div class="row">
<div style="border-radius: 5px; border:1px dashed rgb(91,155,213); width:100%; ">
<h1 style="text-align: center;">내가 쓴 게시글</h1>
<div style="padding-top: 20px;"></div>
<div class="flexbox">
<div class="item"><a href="{% url 'update'%}">사용자정보</a></div>
<div class="item"><a href="{% url 'mypageComment'%}">내가 단 댓글</a></div>
<div class="item"><a href="{% url 'mypageBlog'%}">내가 쓴 게시글</a></div>
</div>
<table class="table table-hover">
<thead>
<tr style="text-align: center;">
<th scope="col">순번</th>
<th scope="col">글제목</th>
<th scope="col">댓글내용</th>
<th scope="col">작성일자</th>
</tr>
</thead>
<tbody>
{% for post in posts %}
<tr onclick="location.href='{% url 'test' post.id %}'" style="text-align: center;">
<th scope="row">{{post.id}}</th>
<td>{{post.title}}</td>
<td>{{post.text | truncatechars:10}}</td>
<td>{{post.created_date}}</td>
</tr>

{%endfor%}
</tbody>
</table>
</div>
</div>
</div>
</section>
</div>
</div>
<div class="containerright"></div>
</div>
{% endblock %}
3 changes: 2 additions & 1 deletion mypage/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
from . import views

urlpatterns = [
path('mypage/', views.mypage, name='mypage'),
path('mypageBlog/', views.mypageBlog, name='mypageBlog'),
path('mypageComment/', views.mypageComment, name='mypageComment'),
]
13 changes: 10 additions & 3 deletions mypage/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from django.shortcuts import render, redirect
from board.models import Board
from board.models import Board, Comment

# Create your views here.
def mypage(request):
def mypageBlog(request):
if request.user.is_authenticated:
posts = Board.objects.filter(userId = request.user.id)
return render(request, 'mypage/mypage.html', {'posts': posts})
return render(request, 'mypage/mypageBlog.html', {'posts': posts})
else:
return redirect('login')

def mypageComment(request):
if request.user.is_authenticated:
posts = Comment.objects.filter(userId = request.user.id)
return render(request, 'mypage/mypageComment.html', {'posts': posts})
else:
return redirect('login')

0 comments on commit cb12240

Please sign in to comment.