Skip to content

Commit b712945

Browse files
committed
Add basic add ticket and view ticket functions
1 parent 5c299b4 commit b712945

File tree

12 files changed

+229
-25
lines changed

12 files changed

+229
-25
lines changed

templates/base.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% load static from staticfiles %}
12
<!DOCTYPE html>
23
<html lang="en">
34

@@ -6,20 +7,20 @@
67
<meta name="viewport" content="width=device-width, initial-scale=1.0">
78
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
89
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
9-
<title>Base.html</title>
10+
<title>{% block title %}{% endblock %}</title>
1011
</head>
1112

1213
<body>
1314
<nav class="navbar navbar-expand-lg navbar-light bg-light">
14-
<a class="navbar-brand" href="#">IshTrak</a>
15+
<a class="navbar-brand" href="{% url 'tickets' %}">IshTrak</a>
1516
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup"
1617
aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
1718
<span class="navbar-toggler-icon"></span>
1819
</button>
1920
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
2021
<div class="navbar-nav">
21-
<a class="nav-item nav-link active" href="#">Tickets <span class="sr-only">(current)</span></a>
22-
<a class="nav-item nav-link" href="#">Add Ticket</a>
22+
<a class="nav-item nav-link active" href="{% url 'tickets' %}">Tickets <span class="sr-only">(current)</span></a>
23+
<a class="nav-item nav-link" href="{% url 'add_ticket' %}">Add Ticket</a>
2324
</div>
2425
</div>
2526
</nav>

tickets/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
class AddTicketForm(forms.ModelForm):
55
class Meta:
66
model = Ticket
7-
fields = ('ticket_type', 'summary')
7+
fields = ('ticket_type', 'summary', 'description')
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.24 on 2020-02-17 11:19
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
import django.utils.timezone
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
('tickets', '0004_remove_ticket_created_date'),
13+
]
14+
15+
operations = [
16+
migrations.AddField(
17+
model_name='ticket',
18+
name='created_date',
19+
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
20+
preserve_default=False,
21+
),
22+
]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.24 on 2020-02-17 11:22
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('tickets', '0005_ticket_created_date'),
12+
]
13+
14+
operations = [
15+
migrations.AddField(
16+
model_name='ticket',
17+
name='status',
18+
field=models.CharField(default='New', max_length=50),
19+
preserve_default=False,
20+
),
21+
]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.24 on 2020-02-17 11:37
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('tickets', '0006_ticket_status'),
12+
]
13+
14+
operations = [
15+
migrations.AddField(
16+
model_name='ticket',
17+
name='priority',
18+
field=models.CharField(default='Medium', max_length=50),
19+
),
20+
migrations.AlterField(
21+
model_name='ticket',
22+
name='status',
23+
field=models.CharField(default='New', max_length=50),
24+
),
25+
]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.24 on 2020-02-17 12:50
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('tickets', '0007_auto_20200217_1137'),
12+
]
13+
14+
operations = [
15+
migrations.AddField(
16+
model_name='ticket',
17+
name='description',
18+
field=models.TextField(default='test description'),
19+
preserve_default=False,
20+
),
21+
migrations.AlterField(
22+
model_name='ticket',
23+
name='ticket_type',
24+
field=models.CharField(max_length=10),
25+
),
26+
]

tickets/models.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33

44
# Create your models here.
55
class Ticket(models.Model):
6-
ticket_type = models.CharField(max_length=50)
6+
ticket_type = models.CharField(max_length=10)
77
summary = models.CharField(max_length=300)
8+
created_date = models.DateTimeField(auto_now_add=True)
9+
status = models.CharField(max_length=50, default='New')
10+
priority = models.CharField(max_length=50, default='Medium')
11+
description = models.TextField()
812
def __str__(self):
913
return self.summary
1014
class Meta:
1115
verbose_name_plural = "Tickets"
12-
# raised_by = models.CharField(maximum_length=200)
13-
# created_date = models.DateTimeField(auto_now_add=True)
14-
# assigned_to = models.CharField(maximum_length=200)
15-
# priority = models.CharField(maximum_length=200)
16-
# status = models.CharField(maximum_length=200)
17-
# description = models.CharField(maximum_length=200)
16+
# reporter = models.CharField(maximum_length=200)
17+
# assignee = models.CharField(maximum_length=200)
1818
# tags = models.CharField(maximum_length=200)
1919
# attachments = models.CharField(maximum_length=200)
2020
# upvotes = models.IntegerField()

tickets/templates/add_ticket.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
{% extends "base.html" %}
22
{% load bootstrap_tags %}
3+
{% block title %}
4+
Add Ticket
5+
{% endblock %}
36
{% block content %}
7+
48
<h1>Add Ticket</h1>
5-
<form method="post" enctype="multipart/form-data">
6-
{% csrf_token %}
7-
{{ form | as_bootstrap }}
8-
<!-- <select type="range" id="ticket-type">
9+
<div class="row">
10+
<div class="col col-8">
11+
<form method="post" enctype="multipart/form-data">
12+
{% csrf_token %}
13+
{{ form | as_bootstrap }}
14+
<!-- <select type="range" id="ticket-type">
915
<option disabled>Choose Type</option>
1016
<option value="bug">Bug</option>
1117
<option value="feature">Feature</option>
1218
</select>
1319
<textarea type="text" id="summary" placeholder="Summary"></textarea> -->
14-
<button type="submit">Submit</button>
15-
</form>
20+
<button type="submit">Submit</button>
21+
</form>
22+
<a href="{% url 'tickets' %}">Cancel</a>
23+
</div>
24+
</div>
1625
{% endblock %}

tickets/templates/tickets.html

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
{% extends "base.html" %}
2+
{% block title %}
3+
Tickets
4+
{% endblock %}
25
{% block content %}
6+
37
<h1>Tickets</h1>
4-
<ul>
5-
{% for ticket in tickets %}
6-
<li>{{ ticket.ticket_type }} | {{ ticket.summary }}</li>
7-
{% endfor %}
8-
</ul>
9-
{% endblock %}
8+
<table class="table">
9+
<thead>
10+
<tr>
11+
<th scope="col">ID</th>
12+
<th scope="col">Summary</th>
13+
<th scope="col">Type</th>
14+
<th scope="col">Reporter</th>
15+
<th scope="col">Assignee</th>
16+
<th scope="col">Status</th>
17+
<th scope="col">Priority</th>
18+
<th scope="col">Created</th>
19+
</tr>
20+
</thead>
21+
<tbody>
22+
{% for ticket in tickets %}
23+
<tr>
24+
<td scope="row">{{ ticket.id }}</td>
25+
<td><a href="{% url 'view_ticket' ticket.id %}">{{ ticket.summary }}</a></td>
26+
<td>{{ ticket.ticket_type }}</td>
27+
<td>placeholder</td>
28+
<td>placeholder</td>
29+
<td>{{ ticket.status }}</td>
30+
<td>{{ ticket.priority }}</td>
31+
<td>{{ ticket.created_date }}</td>
32+
</tr>
33+
{% endfor %}
34+
</tbody>
35+
</table>
36+
{% endblock %}

tickets/templates/view_ticket.html

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{% extends 'base.html' %}
2+
{% block title %}
3+
View Ticket | {{ ticket.id }}
4+
{% endblock %}
5+
6+
{% block content %}
7+
<h1>View Ticket</h1>
8+
<div class="row">
9+
<div class="col col-6">
10+
<h4>Details</h4>
11+
<table class="table table-sm">
12+
<thead>
13+
<tr>
14+
{% comment %} <th scope="col">Field</th> {% endcomment %}
15+
{% comment %} <th scope="col">Value</th> {% endcomment %}
16+
</tr>
17+
</thead>
18+
<tbody>
19+
{% for key, value in ticket.items %}
20+
<tr>
21+
<th scope="row">{{ key }}</th>
22+
<td>{{ value }}</td>
23+
</tr>
24+
{% endfor %}
25+
</tbody>
26+
</table>
27+
<a class="btn btn-primary" href="#">Edit</a>
28+
<a class="btn btn-danger" href="#">Delete</a>
29+
</div>
30+
<div class="col col-6">
31+
32+
{% comment %} History {% endcomment %}
33+
<h4>Change History</h4>
34+
<table class="table table-sm">
35+
<thead>
36+
<tr>
37+
<th scope="col">Field</th>
38+
<th scope="col">New Value</th>
39+
<th scope="col">Old Value</th>
40+
<th scope="col">Date Changed</th>
41+
</tr>
42+
</thead>
43+
<tbody>
44+
<tr>
45+
<td>Status</td>
46+
<td>High</td>
47+
<td>Medium</td>
48+
<td>20/02/2020</td>
49+
</tr>
50+
</tbody>
51+
</table>
52+
</div>
53+
</div>
54+
<div class="row">
55+
<div class="div col-12">
56+
{% comment %} Comments {% endcomment %}
57+
<h4>Comments</h4>
58+
<ul class="list-group">
59+
<li class="list-group-item">I agree</li>
60+
<li class="list-group-item">Same</li>
61+
</ul>
62+
<br>
63+
<a class="btn btn-primary" href="#">Add Comment</a>
64+
</div>
65+
</div>
66+
{% endblock %}

0 commit comments

Comments
 (0)