Skip to content

Commit

Permalink
Merge pull request daldal-Mango#37 from dddooo9/main
Browse files Browse the repository at this point in the history
날짜체크, 목적 마감 체크
  • Loading branch information
SJLEE316 authored Aug 28, 2021
2 parents 24e6cc3 + 4591ea0 commit 9677580
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 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
3 changes: 2 additions & 1 deletion groups/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
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"),
]
7 changes: 7 additions & 0 deletions groups/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
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
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 9677580

Please sign in to comment.