Skip to content

Commit 1aa0ad2

Browse files
authored
Merge pull request #103 from pirogramming/minji
Fix : 프론트에서 데이터 불러오기 위한 views.py & urls.py 수정
2 parents 97a26af + 9139416 commit 1aa0ad2

10 files changed

Lines changed: 127 additions & 75 deletions

File tree

apps/projects/views.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ def _get_project_context(project, user):
2323
members = team.members.filter(is_active=True).select_related("user", "role")
2424
member_count_by_role = team.get_member_count_by_role()
2525

26+
# 각 멤버에 레벨 정보 추가
27+
members_with_level = []
28+
for member in members:
29+
member_data = {
30+
'member': member,
31+
'level': member.user.get_role_level(member.role.code)
32+
}
33+
members_with_level.append(member_data)
34+
35+
2636
# 시즌 정보
2737
season = None
2838
active_season = Season.get_active_season()
@@ -63,6 +73,7 @@ def _get_project_context(project, user):
6373
"project": project,
6474
"team": team,
6575
"members": members,
76+
"members_with_level": members_with_level,
6677
"member_count_by_role": member_count_by_role,
6778
"season": season,
6879
"guide_progress": guide_progress,

apps/teams/urls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
app_name = "teams"
55

66
urlpatterns = [
7+
# 소속팀 여부에 따라 이동 url 상이 (team/team_apply)
8+
path('matching/', views.team_matching_router, name='matching_router'),
9+
710
# 팀 매칭 신청
811
path("apply/", views.team_apply, name="team_apply"), # team_apply.html
912

apps/teams/views.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@
1919
# Template Views (HTML 렌더링)
2020
# ================================
2121

22+
# apps/teams/views.py
23+
24+
@login_required
25+
def team_matching_router(request):
26+
"""
27+
사용자의 상태를 확인하여 매칭 신청 페이지 또는 결과 페이지로 보냄
28+
"""
29+
season = Season.get_active_season()
30+
31+
# 1. 사용자가 이미 팀에 속해 있는지 확인
32+
user_has_team = TeamMember.objects.filter(user=request.user).exists()
33+
34+
# 2. 팀이 있다면 결과 페이지(team.html)로 이동
35+
if user_has_team:
36+
return redirect('teams:team_status')
37+
38+
# 3. 팀이 없다면 신청 페이지(team_apply.html)로 이동
39+
return redirect('teams:team_apply')
40+
2241
@login_required
2342
def team_apply(request):
2443
"""

config/views.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ def main_view(request):
1717
"""
1818

1919
user = request.user
20-
context = {}
20+
season = Season.get_active_season()
21+
context = {
22+
'season': season,
23+
}
2124

2225
# 로그인 상태만 추가 데이터 조회
2326
if user.is_authenticated:

static/css/dashboard.css

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,13 @@ hr {
227227

228228
/* 팀원 카드 */
229229
.t_member > .member {
230+
position: relative;
230231
background: #fff;
231232
box-shadow: 1px 2px 2px 1px #ccc;
232233
padding: 15px 25px;
233234
min-width: 200px;
234235
max-width: 200px;
236+
min-height: 300px;
235237
text-align: center;
236238
border-radius: 20px;
237239
flex-shrink: 0;
@@ -259,7 +261,7 @@ hr {
259261
height: 35px;
260262
position: absolute;
261263
bottom: 0;
262-
right: calc(50% - 65px);
264+
right: calc(50% - 55px);
263265
}
264266

265267
.member > h3 {
@@ -277,10 +279,12 @@ hr {
277279
}
278280

279281
.member > .role_design {
282+
position: absolute;
283+
bottom: 15px; right: 50px;
280284
font-size: 16px;
281285
margin: 15px auto;
282286
padding: 5px 0;
283-
width: 60%;
287+
width: 50%;
284288
height: 30px;
285289
border: 1px solid #00B9B0;
286290
border-radius: 20px;
@@ -289,10 +293,12 @@ hr {
289293
}
290294

291295
.member > .role_frontend {
296+
position: absolute;
297+
bottom: 15px; right: 40px;
292298
font-size: 16px;
293299
margin: 15px auto;
294300
padding: 5px 0;
295-
width: 70%;
301+
width: 60%;
296302
height: 30px;
297303
border: 1px solid #FFCE53;
298304
border-radius: 20px;
@@ -301,10 +307,12 @@ hr {
301307
}
302308

303309
.member > .role_backend {
310+
position: absolute;
311+
bottom: 15px; right: 50px;
304312
font-size: 16px;
305313
margin: 15px auto;
306314
padding: 5px 0;
307-
width: 70%;
315+
width: 50%;
308316
height: 30px;
309317
border: 1px solid #FF3E88;
310318
border-radius: 20px;

static/css/team.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ body {
2929
box-shadow: 0 2px 2px 0 #999;
3030
}
3131

32-
.t_member .profile_img {
32+
.profile_section {
3333
width: 120px; height: 120px;
3434
}
3535

36-
.t_member .level_img {
36+
.t_member > .profile_section > .profile_img {
37+
width: 120px; height: 120px;
38+
}
39+
40+
.t_member >.profile_section> .level_img {
3741
width: 40px; height: 40px;
3842
position: absolute;
3943
top: 100px; right: 30px;
@@ -44,7 +48,7 @@ body {
4448
font-size: 18px; font-weight: 500;
4549
}
4650

47-
.t_member .u_stack {
51+
.t_member .u_frontend {
4852
margin: 10px auto 0;
4953
width: 80%;
5054
padding: 5px 10px;

templates/base.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@ <h3>KITUP</h3>
1515
</a>
1616
<div class="header_menu">
1717
{% if user.is_authenticated %}
18-
<a href="{% url 'teams:team_apply' %}"><p>팀매칭</p></a>
18+
<a href="{% url 'teams:matching_router' %}"><p>팀매칭</p></a>
1919
<div class="dropdown">
2020
<a href="{% url 'projects:dashboard' %}"><p>내 프로젝트</p></a>
21-
<div class="dropdown-content">
22-
<a href="{% url 'projects:dashboard' %}">현재 프로젝트</a>
23-
<a href="{% url 'projects:project_list' %}">지난 프로젝트</a>
24-
</div>
2521
</div>
2622
<a href="{% url 'projects:kitup_list' %}"><p>KITUP 프로젝트</p></a>
2723
<a href="{% url 'reflections:note_list' %}"><p>회고</p></a>

templates/projects/dashboard.html

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,38 +79,36 @@ <h3>Team</h3>
7979
{% endfor %}
8080
</p>
8181
<div class="t_member">
82-
{% for member in members %}
82+
{% for item in members_with_level %}
8383
<div class="member">
8484
<div class="profile_section">
8585
<!-- 프로필 사진 -->
86-
{% if member.user.profile_image %}
87-
<img src="{{ member.user.profile_image.url }}" alt="프로필사진" class="profile">
86+
{% if item.member.user.profile_image %}
87+
<img src="{{ item.member.user.profile_image.url }}" alt="프로필사진" class="profile">
8888
{% else %}
8989
<img src="{% static 'images/default_img.png' %}" alt="프로필사진" class="profile">
9090
{% endif %}
9191
<!-- 레벨 사진 -->
92-
{% with level=member.user.get_role_level %}
93-
{% if level == 1 %}
92+
{% if item.level == 1 %}
9493
<img src="{% static 'images/Level1.png' %}" alt="레벨1" class="level">
95-
{% elif level == 2 %}
94+
{% elif item.level == 2 %}
9695
<img src="{% static 'images/Level2.png' %}" alt="레벨2" class="level">
97-
{% elif level == 3 %}
96+
{% elif item.level == 3 %}
9897
<img src="{% static 'images/Level3.png' %}" alt="레벨3" class="level">
99-
{% elif level == 4 %}
98+
{% elif item.level == 4 %}
10099
<img src="{% static 'images/Level4.png' %}" alt="레벨4" class="level">
101100
{% endif %}
102-
{% endwith %}
103101
</div>
104-
<h3>{{ member.user.nickname|default:member.user.username }}</h3>
105-
<p class="info">✉️ {{ member.user.email }}</p>
106-
{% if member.user.github_id %}
107-
<p class="info">🖥️ @{{ member.user.github_id }}</p>
102+
<h3>{{ item.member.user.nickname|default:item.member.user.username }}</h3>
103+
<p class="info">✉️ {{ item.member.user.email }}</p>
104+
{% if item.member.user.github_id %}
105+
<p class="info">🖥️ @{{ item.member.user.github_id }}</p>
108106
{% endif %}
109-
{% if member.role.code == "PM" %}
107+
{% if item.member.role.code == "PM" %}
110108
<p class="role_design">기획자</p>
111-
{% elif member.role.code == "FRONTEND" %}
109+
{% elif item.member.role.code == "FRONTEND" %}
112110
<p class="role_frontend">프론트엔드</p>
113-
{% elif member.role.code == "BACKEND" %}
111+
{% elif item.member.role.code == "BACKEND" %}
114112
<p class="role_backend">백엔드</p>
115113
{% endif %}
116114
</div>

templates/teams/team.html

Lines changed: 55 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,64 @@ <h3>
88
내 프로젝트에서 업데이트 된 팀 정보를 확인해보세요.
99
</h3>
1010
<div class="team_member">
11+
{% for item in team_members %}
1112
<div class="t_member">
12-
<img
13-
src="{% static 'images/default_img.png' %}"
14-
alt="프로필사진"
15-
class="profile_img"
16-
/>
17-
<img
18-
src="{% static 'images/level3.png' %}"
19-
alt="level"
20-
class="level_img"
21-
/>
22-
<p class="u_name">user1 (Lv3)</p>
23-
<p class="u_stack">프론트엔드</p>
13+
<div class="profile_section">
14+
<!-- 프로필 사진 -->
15+
{% if item.user.profile_image %}
16+
<img
17+
src="{{ item.user.profile_image.url }}"
18+
alt="프로필사진"
19+
class="profile_img"
20+
/>
21+
{% else %}
22+
<img
23+
src="{% static 'images/default_img.png' %}"
24+
alt="프로필사진"
25+
class="profile_img"
26+
/>
27+
{% endif %}
28+
<!-- 레벨 사진 -->
29+
{% if item.level == 1 %}
30+
<img
31+
src="{% static 'images/Level1.png' %}"
32+
alt="레벨1"
33+
class="level_img"
34+
/>
35+
{% elif item.level == 2 %}
36+
<img
37+
src="{% static 'images/Level2.png' %}"
38+
alt="레벨2"
39+
class="level_img"
40+
/>
41+
{% elif item.level == 3 %}
42+
<img
43+
src="{% static 'images/Level3.png' %}"
44+
alt="레벨3"
45+
class="level_img"
46+
/>
47+
{% elif item.level == 4 %}
48+
<img
49+
src="{% static 'images/Level4.png' %}"
50+
alt="레벨4"
51+
class="level_img"
52+
/>
53+
{% endif %}
54+
</div>
55+
<p class="u_name">{{ item.user.nickname }} (Lv{{ item.level }})</p>
56+
{% if item.role.code == "PM" %}
57+
<p class="u_design">기획자</p>
58+
{% elif item.role.code == "FRONTEND" %}
59+
<p class="u_frontend">프론트엔드</p>
60+
{% elif item.role.code == "BACKEND" %}
61+
<p class="u_backend">백엔드</p>
62+
{% endif %}
2463
</div>
25-
<div class="t_member">
26-
<img
27-
src="{% static 'images/default_img.png' %}"
28-
alt="프로필사진"
29-
class="profile_img"
30-
/>
31-
<img
32-
src="{% static 'images/level3.png' %}"
33-
alt="level"
34-
class="level_img"
35-
/>
36-
<p class="u_name">user1 (Lv3)</p>
37-
<p class="u_stack">프론트엔드</p>
38-
</div>
39-
<div class="t_member">
40-
<img src="{% static 'images/default_img.png' %}" alt="프로필사진" class="profile_img">
41-
<img src="{% static 'images/level3.png' %}" alt="level" class="level_img">
42-
<p class="u_name">user1 (Lv3)</p>
43-
<p class="u_stack">프론트엔드</p>
44-
</div>
45-
<div class="t_member">
46-
<img src="{% static 'images/default_img.png' %}" alt="프로필사진" class="profile_img">
47-
<img src="{% static 'images/level3.png' %}" alt="level" class="level_img">
48-
<p class="u_name">user1 (Lv3)</p>
49-
<p class="u_stack">프론트엔드</p>
50-
</div>
51-
<div class="t_member">
52-
<img src="{% static 'images/default_img.png' %}" alt="프로필사진" class="profile_img">
53-
<img src="{% static 'images/level3.png' %}" alt="level" class="level_img">
54-
<p class="u_name">user1 (Lv3)</p>
55-
<p class="u_stack">프론트엔드</p>
56-
</div>
64+
{% endfor %}
5765
</div>
58-
<a href="{% url 'projects:dashboard' %}" class="go_project"><p>내 프로젝트로 이동</p></a>
66+
<a href="{% url 'projects:dashboard' %}" class="go_project"
67+
><p>내 프로젝트로 이동</p></a
68+
>
5969
</div>
6070
<!-- 매칭 실패 -->
6171
<!-- <div class="team_fail">

templates/teams/team_apply.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends 'base.html' %} {% load static %} {% block header %}
22
<link rel="stylesheet" href="{% static 'css/team_apply.css' %}" />
33
{% endblock %} {% block content %}
4-
{% if season and season.is_matching_period %}
4+
{% if season.status == 'MATCHING' %}
55
<div class="team_matching">
66
<h3>팀 매칭 모집 기간이 시작됐어요!</h3>
77
<p>

0 commit comments

Comments
 (0)