Commit ·
08ea71d
1
Parent(s): b9b11d7
update file 022
Browse files- app.py +23 -0
- templates/ticket_detail.html +74 -0
- templates/tickets.html +2 -1
app.py
CHANGED
|
@@ -168,6 +168,29 @@ def view_tickets():
|
|
| 168 |
dict_rows = [dict(zip(columns, row)) for row in paginated]
|
| 169 |
return render_template("tickets.html", tickets=dict_rows, page=page, pages=pages, total=total)
|
| 170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
@app.route("/export/csv")
|
| 172 |
def export_csv():
|
| 173 |
conn = sqlite3.connect(DB_PATH)
|
|
|
|
| 168 |
dict_rows = [dict(zip(columns, row)) for row in paginated]
|
| 169 |
return render_template("tickets.html", tickets=dict_rows, page=page, pages=pages, total=total)
|
| 170 |
|
| 171 |
+
@app.route("/ticket/<id>")
|
| 172 |
+
def view_ticket(id):
|
| 173 |
+
conn = sqlite3.connect("tickets.db")
|
| 174 |
+
c = conn.cursor()
|
| 175 |
+
c.execute("SELECT * FROM tickets WHERE id = ?", (id,))
|
| 176 |
+
row = c.fetchone()
|
| 177 |
+
conn.close()
|
| 178 |
+
|
| 179 |
+
if row:
|
| 180 |
+
ticket = {
|
| 181 |
+
"id": row[0],
|
| 182 |
+
"first_name": row[1],
|
| 183 |
+
"last_name": row[2],
|
| 184 |
+
"email": row[3],
|
| 185 |
+
"issue": row[4],
|
| 186 |
+
"priority": row[5],
|
| 187 |
+
"date": row[6],
|
| 188 |
+
"filename": row[7]
|
| 189 |
+
}
|
| 190 |
+
return render_template("ticket_detail.html", ticket=ticket)
|
| 191 |
+
else:
|
| 192 |
+
return "Ticket not found", 404
|
| 193 |
+
|
| 194 |
@app.route("/export/csv")
|
| 195 |
def export_csv():
|
| 196 |
conn = sqlite3.connect(DB_PATH)
|
templates/ticket_detail.html
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<title>Ticket Details</title>
|
| 5 |
+
<style>
|
| 6 |
+
body {
|
| 7 |
+
font-family: Arial, sans-serif;
|
| 8 |
+
padding: 40px;
|
| 9 |
+
background-color: #f2f2f2;
|
| 10 |
+
}
|
| 11 |
+
.container {
|
| 12 |
+
background: white;
|
| 13 |
+
padding: 30px;
|
| 14 |
+
border-radius: 10px;
|
| 15 |
+
max-width: 600px;
|
| 16 |
+
margin: auto;
|
| 17 |
+
}
|
| 18 |
+
h2 {
|
| 19 |
+
color: #007bff;
|
| 20 |
+
}
|
| 21 |
+
.field {
|
| 22 |
+
margin-bottom: 15px;
|
| 23 |
+
}
|
| 24 |
+
.field label {
|
| 25 |
+
font-weight: bold;
|
| 26 |
+
}
|
| 27 |
+
.field p {
|
| 28 |
+
margin: 5px 0 0;
|
| 29 |
+
}
|
| 30 |
+
a.button {
|
| 31 |
+
text-decoration: none;
|
| 32 |
+
padding: 10px 20px;
|
| 33 |
+
background: #007bff;
|
| 34 |
+
color: white;
|
| 35 |
+
border-radius: 5px;
|
| 36 |
+
}
|
| 37 |
+
</style>
|
| 38 |
+
</head>
|
| 39 |
+
<body>
|
| 40 |
+
<div class="container">
|
| 41 |
+
<h2>📄 Ticket Details</h2>
|
| 42 |
+
<div class="field">
|
| 43 |
+
<label>First Name:</label>
|
| 44 |
+
<p>{{ ticket.first_name }}</p>
|
| 45 |
+
</div>
|
| 46 |
+
<div class="field">
|
| 47 |
+
<label>Last Name:</label>
|
| 48 |
+
<p>{{ ticket.last_name }}</p>
|
| 49 |
+
</div>
|
| 50 |
+
<div class="field">
|
| 51 |
+
<label>Email:</label>
|
| 52 |
+
<p>{{ ticket.email }}</p>
|
| 53 |
+
</div>
|
| 54 |
+
<div class="field">
|
| 55 |
+
<label>Issue Date:</label>
|
| 56 |
+
<p>{{ ticket.date }}</p>
|
| 57 |
+
</div>
|
| 58 |
+
<div class="field">
|
| 59 |
+
<label>Priority:</label>
|
| 60 |
+
<p>{{ ticket.priority }}</p>
|
| 61 |
+
</div>
|
| 62 |
+
<div class="field">
|
| 63 |
+
<label>Issue:</label>
|
| 64 |
+
<p>{{ ticket.issue }}</p>
|
| 65 |
+
</div>
|
| 66 |
+
<div class="field">
|
| 67 |
+
<label>Generated Text:</label>
|
| 68 |
+
<p style="white-space: pre-line;">{{ ticket.filename }}</p>
|
| 69 |
+
</div>
|
| 70 |
+
<a class="button" href="/download/{{ ticket.id }}">Download PDF</a>
|
| 71 |
+
<a class="button" href="/tickets" style="background: #6c757d;">Back</a>
|
| 72 |
+
</div>
|
| 73 |
+
</body>
|
| 74 |
+
</html>
|
templates/tickets.html
CHANGED
|
@@ -69,7 +69,8 @@
|
|
| 69 |
<td>{{ ticket.priority }}</td>
|
| 70 |
<td>{{ ticket.date }}</td>
|
| 71 |
<td>{{ ticket.generated }}</td>
|
| 72 |
-
<td><a class="button" href="/download/{{ ticket.id }}">Download</a>
|
|
|
|
| 73 |
</tr>
|
| 74 |
{% endfor %}
|
| 75 |
</tbody>
|
|
|
|
| 69 |
<td>{{ ticket.priority }}</td>
|
| 70 |
<td>{{ ticket.date }}</td>
|
| 71 |
<td>{{ ticket.generated }}</td>
|
| 72 |
+
<td><a class="button" href="/download/{{ ticket.id }}">Download</a>
|
| 73 |
+
<a class="button" href="/ticket/{{ ticket.id }}" style="background:#17a2b8;">View</a></td>
|
| 74 |
</tr>
|
| 75 |
{% endfor %}
|
| 76 |
</tbody>
|