Skip to content

Commit 441ece7

Browse files
committed
Add KANBAN template, url and view
1 parent cf7b003 commit 441ece7

File tree

3 files changed

+305
-30
lines changed

3 files changed

+305
-30
lines changed

tickets/templates/kanban.html

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
{% extends "base.html" %}
2+
{% load bootstrap_tags %}
3+
{% block title %}TrackIt | Kanban{% endblock %}
4+
{% block container-class %}kanban-container{% endblock %}
5+
{% block page_heading %}
6+
<i class="material-icons-outlined">view_week</i> Kanban ({{ tickets.count }})
7+
<hr>
8+
{% endblock %}
9+
{% block content %}
10+
<div class="row">
11+
<div class="col">
12+
<div class="form-check">
13+
<input type="checkbox" class="form-check-input" id="cancelled-checkbox" checked>
14+
<label class="form-check-label" for="cancelled-checkbox"><i class="material-icons-outlined align-middle">
15+
visibility_off
16+
</i> Hide Cancelled ({{ cancelled_tickets_count}})
17+
</label>
18+
</div>
19+
</div>
20+
</div>
21+
<div class="row">
22+
<!-- 'New' Column -->
23+
<div class="col kanban-col">
24+
<div class="jumbotron kanban-todo">
25+
<h5 class="text-center bg-info-light"><i class="material-icons-outlined align-bottom">local_activity</i> New
26+
({{ new_tickets_count }})</h5>
27+
{% for ticket in tickets %}
28+
{% if ticket.status == 'New' %}
29+
<div class="card">
30+
<div class="card-body">
31+
<h6 class="card-title">
32+
{% if ticket.ticket_type == "Bug" %}
33+
<i class="material-icons-outlined align-middle" data-toggle="tooltip" title="Bug"
34+
data-placement="right">bug_report</i>
35+
{% elif ticket.ticket_type == "Feature" %}
36+
<i class="material-icons-outlined align-middle" data-toggle="tooltip" title="Feature"
37+
data-placement="right">build</i>
38+
{% endif %}
39+
<a href="{% url 'view_ticket' ticket.id %}" data-toggle="tooltip" data-placement="bottom"
40+
title="{{ ticket.description }}">
41+
{{ ticket.summary }}
42+
</a>
43+
<!-- Priority Pill Badge -->
44+
<span class="text-muted">
45+
{% if ticket.priority == 'Low' %}
46+
<span class="badge badge-success float-right">{{ ticket.priority }}</span>
47+
{% elif ticket.priority == 'Medium' %}
48+
<span class="badge badge-warning float-right">{{ ticket.priority }}</span>
49+
{% elif ticket.priority == 'High' %}
50+
<span class="badge badge-danger float-right">{{ ticket.priority }}</span>
51+
{% endif %}
52+
</span>
53+
</h6>
54+
<!-- Tags -->
55+
<span>
56+
{% if ticket.tags.names %}
57+
<!-- <b>Tags:</b> -->
58+
{% for tag in ticket.tags.names %}
59+
<span class="badge badge-pill badge-info">{{ tag }}</span>
60+
{% endfor %}
61+
{% endif %}
62+
</span>
63+
<!-- Status change via dropdown only available if User is Submitter or Staff -->
64+
{% if request.user == ticket.submitted_by or request.user.is_staff %}
65+
<div class="btn-group float-right">
66+
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-toggle="dropdown"
67+
aria-haspopup="true" aria-expanded="false">
68+
</button>
69+
<div class="dropdown-menu dropdown-menu-right">
70+
<h6 class="dropdown-header">Move to:</h6>
71+
<a class="dropdown-item" href="{% url 'change_status' pk=ticket.id new_status='In Progress' %}">
72+
<i class="material-icons align-bottom">schedule</i> In Progress</a>
73+
<a class="dropdown-item" href="{% url 'change_status' pk=ticket.id new_status='Resolved' %}"><i
74+
class="material-icons align-bottom">done</i> Resolved</a>
75+
<div class="dropdown-divider"></div>
76+
<a class="dropdown-item" href="{% url 'change_status' pk=ticket.id new_status='Cancelled' %}"><i
77+
class="material-icons-outlined align-bottom">cancel</i> Cancelled</a>
78+
</div>
79+
</div>
80+
{% endif %}
81+
</div>
82+
</div>
83+
{% endif %}
84+
{% endfor %}
85+
</div>
86+
</div>
87+
<!-- In Progress Column -->
88+
<div class="col kanban-col">
89+
<div class="jumbotron kanban-in-progress">
90+
<h5 class="text-center bg-warning-light"><i class="material-icons align-bottom">schedule</i> In Progress
91+
({{ in_progress_tickets_count }})
92+
</h5>
93+
{% for ticket in tickets %}
94+
{% if ticket.status == 'In Progress' %}
95+
<div class="card">
96+
<div class="card-body">
97+
<h6 class="card-title">
98+
<a href="{% url 'view_ticket' ticket.id %}" data-toggle="tooltip" data-placement="bottom"
99+
title="{{ ticket.description }}">{{ ticket.summary }}
100+
</a>
101+
{% if ticket.ticket_type == "Bug" %}
102+
<i class="material-icons-outlined float-right" data-toggle="tooltip" data-placement="right"
103+
title="Bug">bug_report</i>
104+
{% elif ticket.ticket_type == "Feature" %}
105+
<i class="material-icons-outlined float-right" data-toggle="tooltip" data-placement="right"
106+
title="Feature">build</i>
107+
{% endif %}
108+
</h6>
109+
<small class="text-muted">
110+
{% if ticket.priority == 'Low' %}
111+
<span class="badge badge-success">{{ ticket.priority }}</span>
112+
{% elif ticket.priority == 'Medium' %}
113+
<span class="badge badge-warning">{{ ticket.priority }}</span>
114+
{% elif ticket.priority == 'High' %}
115+
<span class="badge badge-danger">{{ ticket.priority }}</span>
116+
{% endif %}
117+
</small>
118+
119+
<!-- Status change via dropdown only available if User is Submitter or Staff -->
120+
{% if request.user == ticket.submitted_by or request.user.is_staff %}
121+
<div class="btn-group float-right">
122+
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-toggle="dropdown"
123+
aria-haspopup="true" aria-expanded="false">
124+
</button>
125+
<div class="dropdown-menu dropdown-menu-right">
126+
<h6 class="dropdown-header">Move to:</h6>
127+
<a class="dropdown-item" href="{% url 'change_status' pk=ticket.id new_status='New' %}"><i
128+
class="material-icons-outlined align-bottom">local_activity</i> New</a>
129+
<a class="dropdown-item" href="{% url 'change_status' pk=ticket.id new_status='Resolved' %}"><i
130+
class="material-icons align-bottom">done</i> Resolved</a>
131+
<div class="dropdown-divider"></div>
132+
<a class="dropdown-item" href="{% url 'change_status' pk=ticket.id new_status='Cancelled' %}"><i
133+
class="material-icons-outlined align-bottom">cancel</i> Cancelled</a>
134+
</div>
135+
</div>
136+
{% endif %}
137+
</div>
138+
</div>
139+
{% endif %}
140+
{% endfor %}
141+
</div>
142+
</div>
143+
<!-- Resolved Column-->
144+
<div class="col kanban-col">
145+
<div class="jumbotron kanban-resolved">
146+
<h5 class="text-center bg-success-light"><i class="material-icons align-bottom">done</i> Resolved
147+
({{ resolved_tickets_count }})
148+
</h5>
149+
{% for ticket in tickets %}
150+
{% if ticket.status == 'Resolved' %}
151+
<div class="card">
152+
<div class="card-body">
153+
<h6 class="card-title">
154+
<a href="{% url 'view_ticket' ticket.id %}" data-toggle="tooltip" data-placement="bottom"
155+
title="{{ ticket.description }}">{{ ticket.summary }}
156+
</a>
157+
{% if ticket.ticket_type == "Bug" %}
158+
<i class="material-icons-outlined float-right" data-toggle="tooltip" data-placement="right"
159+
title="Bug">bug_report</i>
160+
{% elif ticket.ticket_type == "Feature" %}
161+
<i class="material-icons-outlined float-right" data-toggle="tooltip" data-placement="right"
162+
title="Feature">build</i>
163+
{% endif %}
164+
</h6>
165+
<small class="text-muted">
166+
{% if ticket.priority == 'Low' %}
167+
<span class="badge badge-pill badge-success">{{ ticket.priority }}</span>
168+
{% elif ticket.priority == 'Medium' %}
169+
<span class="badge badge-pill badge-warning">{{ ticket.priority }}</span>
170+
{% elif ticket.priority == 'High' %}
171+
<span class="badge badge-pill badge-danger">{{ ticket.priority }}</span>
172+
{% endif %}
173+
</small>
174+
175+
<!-- Status change via dropdown only available if User is Submitter or Staff -->
176+
{% if request.user == ticket.submitted_by or request.user.is_staff %}
177+
<div class="btn-group float-right">
178+
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-toggle="dropdown"
179+
aria-haspopup="true" aria-expanded="false">
180+
</button>
181+
<div class="dropdown-menu dropdown-menu-right">
182+
<h6 class="dropdown-header">Move to:</h6>
183+
<a class="dropdown-item" href="{% url 'change_status' pk=ticket.id new_status='New' %}"><i
184+
class="material-icons-outlined align-bottom">local_activity</i> New</a>
185+
<a class="dropdown-item" href="{% url 'change_status' pk=ticket.id new_status='In Progress' %}">
186+
<i class="material-icons align-bottom">schedule</i> In Progress</a>
187+
<div class="dropdown-divider"></div>
188+
<a class="dropdown-item" href="{% url 'change_status' pk=ticket.id new_status='Cancelled' %}"><i
189+
class="material-icons-outlined align-bottom">cancel</i> Cancelled</a>
190+
</div>
191+
</div>
192+
{% endif %}
193+
</div>
194+
</div>
195+
{% endif %}
196+
{% endfor %}
197+
</div>
198+
</div>
199+
<!-- Cancelled Column -->
200+
<div class="col kanban-col d-none">
201+
<div class="jumbotron kanban-cancelled">
202+
<h5 class="text-center bg-grey-light"><i class="material-icons-outlined align-bottom">cancel</i> Cancelled
203+
({{ cancelled_tickets_count }})
204+
</h5>
205+
{% for ticket in tickets %}
206+
{% if ticket.status == 'Cancelled' %}
207+
<div class="card">
208+
<div class="card-body">
209+
<h6 class="card-title">
210+
<a href="{% url 'view_ticket' ticket.id %}" data-toggle="tooltip" data-placement="bottom"
211+
title="{{ ticket.description }}">
212+
{{ ticket.summary }}
213+
</a>
214+
{% if ticket.ticket_type == "Bug" %}
215+
<i class="material-icons-outlined float-right" data-toggle="tooltip" title="Bug"
216+
data-placement="right">bug_report</i>
217+
{% elif ticket.ticket_type == "Feature" %}
218+
<i class="material-icons-outlined float-right" data-toggle="tooltip" title="Feature"
219+
data-placement="right">build</i>
220+
{% endif %}
221+
</h6>
222+
<small class="text-muted">
223+
{% if ticket.priority == 'Low' %}
224+
<span class="badge badge-pill badge-success">{{ ticket.priority }}</span>
225+
{% elif ticket.priority == 'Medium' %}
226+
<span class="badge badge-pill badge-warning">{{ ticket.priority }}</span>
227+
{% elif ticket.priority == 'High' %}
228+
<span class="badge badge-pill badge-danger">{{ ticket.priority }}</span>
229+
{% endif %}
230+
</small>
231+
232+
<!-- Status change via dropdown only available if User is Submitter or Staff -->
233+
{% if request.user == ticket.submitted_by or request.user.is_staff %}
234+
<div class="btn-group float-right">
235+
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-toggle="dropdown"
236+
aria-haspopup="true" aria-expanded="false">
237+
</button>
238+
<div class="dropdown-menu dropdown-menu-right">
239+
<h6 class="dropdown-header">Move to:</h6>
240+
<a class="dropdown-item" href="{% url 'change_status' pk=ticket.id new_status='New' %}"><i
241+
class="material-icons-outlined align-bottom">local_activity</i> New</a>
242+
<a class="dropdown-item" href="{% url 'change_status' pk=ticket.id new_status='In Progress' %}">
243+
<i class="material-icons align-bottom">schedule</i> In Progress</a>
244+
<a class="dropdown-item" href="{% url 'change_status' pk=ticket.id new_status='Resolved' %}"><i
245+
class="material-icons align-bottom">done</i> Resolved</a>
246+
</div>
247+
</div>
248+
{% endif %}
249+
</div>
250+
</div>
251+
{% endif %}
252+
{% endfor %}
253+
</div>
254+
</div>
255+
</div>
256+
{% endblock %}
257+
{% block scripts %}
258+
{% endblock %}

tickets/urls.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
from django.conf.urls import url, include
22
from . import views
3+
from rest_framework import routers
4+
5+
router = routers.DefaultRouter()
6+
router.register('tickets', views.RestView)
37

48
urlpatterns = [
9+
url(r'^api/', include(router.urls)),
510
url(r'^$', views.view_tickets, name='tickets'),
6-
# url(r'^(?P<sort_field>\w+)/$', views.view_tickets, name='tickets'),
11+
url(r'^kanban/$', views.kanban, name='kanban'),
12+
url(r'^dashboard/$', views.dashboard, name='dashboard'),
13+
url(r'^change_status/(?P<pk>\d+)/(?P<new_status>[a-zA-Z_ ]+)/$',
14+
views.change_status, name='change_status'),
715
url(r'^add_ticket/$', views.add_ticket, name='add_ticket'),
816
url(r'^(?P<pk>\d+)/$', views.view_ticket, name='view_ticket'),
17+
url(r'^upvote/(?P<pk>\d+)/$', views.upvote, name='upvote'),
918
url(r'^edit_ticket/(?P<pk>\d+)/$', views.edit_ticket, name='edit_ticket'),
10-
url(r'^cancel_ticket/(?P<pk>\d+)/$',
11-
views.cancel_ticket, name='cancel_ticket'),
1219
url(r'^delete_ticket/(?P<pk>\d+)/$',
1320
views.delete_ticket, name='delete_ticket'),
14-
# url(r'^add_comment/$', views.add_comment, name='add_comment'),
15-
# url(r'^add_comment/(?P<pk>\d+)/$', views.add_comment, name='add_comment'),
1621
]

0 commit comments

Comments
 (0)