diff --git a/ticketsystem/models.py b/ticketsystem/models.py index b646723..6ff02fc 100644 --- a/ticketsystem/models.py +++ b/ticketsystem/models.py @@ -26,3 +26,12 @@ class Ticket(models.Model): def __str__(self): return f"[{self.get_priority_display()}] {self.title} ({self.get_status_display()})" + +class Comment(models.Model): + ticket = models.ForeignKey("Ticket", on_delete=models.CASCADE, related_name="comments") + author = models.ForeignKey(User, on_delete=models.CASCADE) + text = models.TextField() + created_at = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return f"Kommentar von {self.author} zu Ticket #{self.ticket.id}" diff --git a/ticketsystem/templates/ticketsystem/detail.html b/ticketsystem/templates/ticketsystem/detail.html index 19c855d..aae4d29 100644 --- a/ticketsystem/templates/ticketsystem/detail.html +++ b/ticketsystem/templates/ticketsystem/detail.html @@ -1,5 +1,5 @@ {% block content %} - -
- ✏️ Dieses Ticket bearbeiten + ✏️ Dieses Ticket + bearbeiten
Keine Kommentare vorhanden.
+ {% endif %} + {% if user.is_authenticated %} +Was möchten Sie tun?
+ + +
{{ comment.author.username }} am {{ comment.created_at|date:"d.m.Y H:i" }}
+{{ comment.text }}
+