Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/daldal-Mango/Miracle30 into…
Browse files Browse the repository at this point in the history
… main
  • Loading branch information
SJLEE316 committed Aug 28, 2021
2 parents 7f05ea0 + af5860b commit 453e5aa
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 11 deletions.
12 changes: 6 additions & 6 deletions Miracle30/templates/shared/_navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ <h4 class="nav_star">⭐<span id="cash">{{request.user.profile.cash}}</span>별<
{% for goal in request.user.goal_set.all %}
{% if goal.category == 'study' %}
<li class="nav_goal">
<a href="{% url 'groups:main' goal.id %}" class="a_deco">{{ goal.name }}</a>
<a href="{% url 'groups:date_check' goal.id %}" class="a_deco">{{ goal.name }}</a>
</li>
{% endif %}
{% endfor %}

{% for goal in request.user.members.all %}
{% if goal.category == 'study' %}
<li class="nav_goal">
<a href="{% url 'groups:main' goal.id %}" class="a_deco">{{ goal.name }}</a>
<a href="{% url 'groups:date_check' goal.id %}" class="a_deco">{{ goal.name }}</a>
</li>
{% endif %}
{% endfor %}
Expand All @@ -55,15 +55,15 @@ <h4 class="nav_star">⭐<span id="cash">{{request.user.profile.cash}}</span>별<
{% for goal in request.user.goal_set.all %}
{% if goal.category == 'hobby' %}
<li class="nav_goal">
<a href="{% url 'groups:main' goal.id %}" class="a_deco">{{ goal.name }}</a>
<a href="{% url 'groups:date_check' goal.id %}" class="a_deco">{{ goal.name }}</a>
</li>
{% endif %}
{% endfor %}

{% for goal in request.user.members.all %}
{% if goal.category == 'hobby' %}
<li class="nav_goal">
<a href="{% url 'groups:main' goal.id %}" class="a_deco">{{ goal.name }}</a>
<a href="{% url 'groups:date_check' goal.id %}" class="a_deco">{{ goal.name }}</a>
</li>
{% endif %}
{% endfor %}
Expand All @@ -78,15 +78,15 @@ <h4 class="nav_star">⭐<span id="cash">{{request.user.profile.cash}}</span>별<
{% for goal in request.user.goal_set.all %}
{% if goal.category == 'etc' %}
<li class="nav_goal">
<a href="{% url 'groups:main' goal.id %}" class="a_deco">{{ goal.name }}</a>
<a href="{% url 'groups:date_check' goal.id %}" class="a_deco">{{ goal.name }}</a>
</li>
{% endif %}
{% endfor %}

{% for goal in request.user.members.all %}
{% if goal.category == 'etc' %}
<li class="nav_goal">
<a href="{% url 'groups:main' goal.id %}" class="a_deco">{{ goal.name }}</a>
<a href="{% url 'groups:date_check' goal.id %}" class="a_deco">{{ goal.name }}</a>
</li>
{% endif %}
{% endfor %}
Expand Down
8 changes: 8 additions & 0 deletions groups/templates/groups/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ <h2>{{dates|index_1:0}} ~ {{dates|index_1:29}}</h2>
</div>
</article>
<article id="tab3" class="content-container__content certify_container">
{{goal.manager}}
{% for member in goal.member.all %}
{% if request.user == goal.manager %}
<a href="{% url 'groups:delete_member' goal.id member.id %}">{{member}}</a>
{% else %}
{{member}}
{% endif %}
{% endfor %}
{% for certify in certifies %}
<ul class="certify_list">
<li>아이디<span>{{ certify.user }}</span></li>
Expand Down
5 changes: 4 additions & 1 deletion groups/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
path('<int:goal_id>/certify/', views.certify, name="certify"),
path('group_list/', views.group_list, name="group_list"),
path('group_detail/', views.group_detail, name="group_detail"),
path('make_group/', views.make_group, name="make_group")
path('make_group/', views.make_group, name="make_group"),
path('<int:goal_id>/date_check', views.date_check, name="date_check"),
path('<int:goal_id>/<int:user_id>/delete_member', views.delete_member, name="delete_member"),

]
17 changes: 16 additions & 1 deletion groups/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from django.shortcuts import render, get_object_or_404, redirect
from main.models import Goal
from .models import Certify
from .models import Certify, User
from datetime import datetime, timedelta
import datetime
from django.utils import timezone

def date_check(request, goal_id):
goal = get_object_or_404(Goal, pk=goal_id)
today = datetime.date.today()
if today < goal.start_date:
return redirect('main:goal_detail', goal_id)
else:
return redirect('groups:main', goal_id)

def main(request, goal_id):
level = []
Expand Down Expand Up @@ -128,3 +135,11 @@ def group_detail(request):

def make_group(request):
return render(request, 'groups/make_group.html')


def delete_member(request, goal_id, user_id):
goal = Goal.objects.get(pk=goal_id)

delete_user = User.objects.get(pk=user_id)
delete_user.members.remove(goal)
return redirect('groups:main', goal_id)
2 changes: 2 additions & 0 deletions main/templates/main/goal_main.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ <h1 class="title">그룹 참여하기</h1>
<div class="container">
<div class="main_container">
{% for goal in goals %}
{% if goal.member_limit > goal.member.count %}
<div class="main_card">
<a href="{% url 'main:goal_detail' goal.pk %}" class="a_deco">{{goal.name}}</a>
</div>
{% endif %}
{% endfor %}
</div>
<a href="{% url 'main:add_goal' %}" class="btn1 btn_center a_deco">그룹 만들기</a>
Expand Down
6 changes: 5 additions & 1 deletion main/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from django.shortcuts import render, redirect
from django.utils import *
from .models import Goal
from datetime import datetime
import datetime


def main_login(request):
return render(request, 'main/main_login.html')
Expand All @@ -11,7 +14,8 @@ def main_logout(request):


def goal_main(request):
goals = Goal.objects.all()
today = datetime.date.today()
goals = Goal.objects.filter(deadline__gte=today)
return render(request, 'main/goal_main.html', {'goals':goals})


Expand Down
4 changes: 2 additions & 2 deletions users/templates/users/mypage.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h3>내가 개설한 목표</h3>
<div class="my_make">
{% for goal in my_goal %}
<div class="my_goalItem">
<a href="{% url 'groups:main' goal.pk %}" class="a_deco">{{goal.name}}</a>
<a href="{% url 'groups:date_check' goal.id %}" class="a_deco">{{goal.name}}</a>
</div>
{% endfor %}
</div>
Expand All @@ -28,7 +28,7 @@ <h3>내가 참여한 목표</h3>
<div class="my_join">
{% for goal in participate_goal %}
<div class="my_goalItem">
<a href="{% url 'groups:main' goal.pk %}" class="a_deco">{{goal.name}}</a>
<a href="{% url 'groups:date_check' goal.id %}" class="a_deco">{{goal.name}}</a>
</div>
{% endfor %}
</div>
Expand Down

0 comments on commit 453e5aa

Please sign in to comment.