feat: replaced TicketDetailView with TicketDetailUpdateView

This commit is contained in:
2025-05-26 20:16:10 +02:00
parent 6306ffd432
commit 8cc038ee20
3 changed files with 319 additions and 108 deletions

View File

@@ -1,7 +1,7 @@
{% extends "ticketsystem/base.html" %}
{% block content %}
{% if messages %}
<div style="max-width: 600px; margin: 1rem auto;">
<div style="max-width: 700px; margin: 1rem auto;">
{% for message in messages %}
<div style="padding: 1rem; border-radius: 5px; margin-bottom: 1rem;
background-color: {% if message.tags == 'error' %}#f8d7da
@@ -13,98 +13,228 @@
{% endfor %}
</div>
{% endif %}
<style>
.ticket-container {
max-width: 700px;
margin: 2rem auto;
padding: 2rem;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #fafafa;
font-family: sans-serif;
max-width: 700px;
margin: 2rem auto;
padding: 2rem;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #fafafa;
font-family: sans-serif;
}
.ticket-container h1 {
margin-bottom: 1rem;
font-size: 1.8rem;
color: #333;
.form-group {
margin-bottom: 1rem;
}
.ticket-attribute {
margin-bottom: 1rem;
.form-group label {
display: block;
font-weight: bold;
margin-bottom: 0.3rem;
color: #333;
}
.ticket-attribute strong {
display: inline-block;
width: 150px;
color: #555;
.form-group input, .form-group select, .form-group textarea {
width: 100%;
padding: 0.5rem;
border: 1px solid #ccc;
border-radius: 4px;
font-family: inherit;
}
.form-group textarea {
min-height: 100px;
resize: vertical;
}
.btn {
background: #007bff;
color: white;
padding: 0.5rem 1rem;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
}
.btn:hover {
background: #0056b3;
}
.ticket-meta {
margin-top: 2rem;
font-size: 0.9rem;
color: #666;
margin-top: 2rem;
padding-top: 1rem;
border-top: 1px solid #ddd;
font-size: 0.9rem;
color: #666;
}
.comment {
margin: 1rem 0;
padding: 1rem;
border-left: 4px solid #007bff;
background: #f0f4ff;
border-radius: 4px;
margin: 1rem 0;
padding: 1rem;
border-left: 4px solid #007bff;
background: #f0f4ff;
border-radius: 4px;
}
.comment-meta {
font-size: 0.9rem;
color: #666;
margin-bottom: 0.5rem;
}
.comment-text {
color: #333;
line-height: 1.4;
}
.comment-form {
margin-top: 1.5rem;
padding: 1.5rem;
background: #f8f9fa;
border-radius: 6px;
border: 1px solid #e9ecef;
}
.comment-form h3 {
margin-top: 0;
margin-bottom: 1rem;
color: #333;
}
.comment-form textarea {
width: 100%;
padding: 0.5rem;
border-radius: 4px;
border: 1px solid #ccc;
width: 100%;
padding: 0.75rem;
border-radius: 4px;
border: 1px solid #ccc;
min-height: 80px;
resize: vertical;
}
.comment-form button {
margin-top: 0.5rem;
background: #007bff;
color: white;
padding: 0.5rem 1rem;
border: none;
border-radius: 4px;
margin-top: 0.5rem;
background: #28a745;
color: white;
padding: 0.5rem 1rem;
border: none;
border-radius: 4px;
cursor: pointer;
}
.comment-form button:hover {
background: #218838;
}
.history-entry {
margin-bottom: 1rem;
background-color: #f9f9f9;
border-left: 4px solid #6c757d;
padding: 0.75rem 1rem;
border-radius: 4px;
}
.history-user {
font-weight: bold;
color: #333;
}
.history-field {
background: #e9ecef;
padding: 0.2rem 0.4rem;
border-radius: 3px;
font-family: monospace;
font-size: 0.9rem;
}
.history-change {
margin: 0.5rem 0;
}
.history-old {
color: #dc3545;
font-style: italic;
}
.history-new {
color: #28a745;
font-weight: bold;
}
.history-date {
font-size: 0.8rem;
color: #666;
}
.section-container {
max-width: 700px;
margin: 1rem auto;
padding: 2rem;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #fafafa;
font-family: sans-serif;
}
.section-container h2 {
margin-top: 0;
margin-bottom: 1.5rem;
color: #333;
border-bottom: 2px solid #007bff;
padding-bottom: 0.5rem;
}
.no-content {
color: #666;
font-style: italic;
text-align: center;
padding: 2rem;
background: #f8f9fa;
border-radius: 4px;
border: 1px dashed #dee2e6;
}
</style>
<!-- Ticket Bearbeitung -->
<div class="ticket-container">
<h1>🎫 Ticket #{{ ticket.id }} {{ ticket.title }}</h1>
<p style="text-align: right;">
<a href="{% url 'modify' ticket.pk %}" style="text-decoration: none; font-weight: bold;">✏️ Dieses Ticket
bearbeiten</a>
</p>
<form method="post" style="margin-top: 1rem;">
{% csrf_token %}
{{ form.non_field_errors }}
<div class="ticket-attribute">
<strong>Status:</strong> {{ ticket.get_status_display }}
</div>
<div class="form-group">
<label for="id_title">Titel:</label>
{{ form.title }}
</div>
<div class="ticket-attribute">
<strong>Priorität:</strong> {{ ticket.get_priority_display }}
</div>
<div class="form-group">
<label for="id_description">Beschreibung:</label>
{{ form.description }}
</div>
<div class="ticket-attribute">
<strong>Beschreibung:</strong><br>
<div style="margin-top: 0.5rem;">{{ ticket.description }}</div>
</div>
<div class="form-group">
<label for="id_status">Status:</label>
{{ form.status }}
</div>
<div class="ticket-attribute">
<strong>Erstellt von:</strong> {{ ticket.created_by.username }}
</div>
<div class="form-group">
<label for="id_priority">Priorität:</label>
{{ form.priority }}
</div>
<div class="ticket-attribute">
<strong>Zugewiesen an:</strong>
{% if ticket.assigned_to %}
{{ ticket.assigned_to.username }}
<div class="form-group">
<label for="id_assigned_to">Zugewiesen an:</label>
{{ form.assigned_to }}
</div>
{% if view.can_edit %}
<button type="submit" class="btn">💾 Änderungen speichern</button>
{% else %}
<em>Niemand zugewiesen</em>
<p style="color: #999; margin-top: 1rem;">Du darfst dieses Ticket nicht bearbeiten.</p>
{% endif %}
</div>
</form>
<div class="ticket-meta">
🕒 Erstellt am: {{ ticket.created_at|date:"d.m.Y H:i" }}<br>
@@ -112,43 +242,59 @@
</div>
</div>
<div class="ticket-container" style="margin-top: 2rem;">
<!-- Kommentare Sektion -->
<div class="section-container">
<h2>💬 Kommentare</h2>
{% if ticket.comments.exists %}
{% for comment in ticket.comments.all %}
<div class="comment">
<p><strong>{{ comment.author.username }}</strong> am {{ comment.created_at|date:"d.m.Y H:i" }}</p>
<p>{{ comment.text }}</p>
</div>
{% endfor %}
{% for comment in ticket.comments.all %}
<div class="comment">
<div class="comment-meta">
<strong>{{ comment.author.username }}</strong> am {{ comment.created_at|date:"d.m.Y H:i" }}
</div>
<div class="comment-text">{{ comment.text }}</div>
</div>
{% endfor %}
{% else %}
<p>Keine Kommentare vorhanden.</p>
<div class="no-content">
Keine Kommentare vorhanden.
</div>
{% endif %}
{% if user.is_authenticated %}
<h3>📝 Neuen Kommentar schreiben</h3>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Absenden</button>
</form>
{% endif %}
<div style="margin-top: 3rem;">
<h2>🕓 Bearbeitungshistorie</h2>
{% if ticket.history.exists %}
<ul style="list-style: none; padding: 0;">
{% for entry in ticket.history.all %}
<li style="margin-bottom: 1rem; background-color: #f9f9f9; border-left: 4px solid #ccc; padding: 0.5rem 1rem;">
<strong>{{ entry.changed_by.username }}</strong>
hat <code>{{ entry.field }}</code> geändert:<br>
<em>{{ entry.old_value }}</em><strong>{{ entry.new_value }}</strong><br>
<small>am {{ entry.changed_at|date:"d.m.Y H:i" }}</small>
</li>
{% endfor %}
</ul>
{% else %}
<p><em>Keine Änderungen bisher.</em></p>
{% endif %}
<div class="comment-form">
<h3>📝 Neuen Kommentar schreiben</h3>
<form method="post">
{% csrf_token %}
{{ comment_form.as_p }}
<button type="submit" name="comment_submit">Kommentar absenden</button>
</form>
</div>
{% endif %}
</div>
<!-- Bearbeitungshistorie Sektion -->
<div class="section-container">
<h2>🕓 Bearbeitungshistorie</h2>
{% if ticket.history.exists %}
{% for entry in ticket.history.all %}
<div class="history-entry">
<div class="history-user">{{ entry.changed_by.username }}</div>
<div class="history-change">
hat <span class="history-field">{{ entry.field }}</span> geändert:
</div>
<div class="history-change">
<span class="history-old">{{ entry.old_value }}</span><span class="history-new">{{ entry.new_value }}</span>
</div>
<div class="history-date">am {{ entry.changed_at|date:"d.m.Y H:i" }}</div>
</div>
{% endfor %}
{% else %}
<div class="no-content">
Keine Änderungen bisher.
</div>
{% endif %}
</div>
{% endblock %}