diff --git a/ticketsystem/forms.py b/ticketsystem/forms.py
index 3d1c9ec..6b38809 100644
--- a/ticketsystem/forms.py
+++ b/ticketsystem/forms.py
@@ -1,5 +1,5 @@
from django import forms
-from .models import Comment
+from .models import Comment, Ticket
class CommentForm(forms.ModelForm):
@@ -11,3 +11,20 @@ class CommentForm(forms.ModelForm):
attrs={"rows": 3, "placeholder": "Kommentar schreiben..."}
),
}
+
+
+class TicketForm(forms.ModelForm):
+ class Meta:
+ model = Ticket
+ fields = ["title", "description", "status", "priority", "course"]
+
+ def save(self, commit=True):
+ ticket = super().save(commit=False)
+
+ # Automatische Tutor-Zuweisung basierend auf dem ausgewählten Kurs
+ if ticket.course and ticket.course.tutor:
+ ticket.assigned_to = ticket.course.tutor
+
+ if commit:
+ ticket.save()
+ return ticket
\ No newline at end of file
diff --git a/ticketsystem/templates/ticketsystem/detail.html b/ticketsystem/templates/ticketsystem/detail.html
index cdedc6b..e3e264b 100644
--- a/ticketsystem/templates/ticketsystem/detail.html
+++ b/ticketsystem/templates/ticketsystem/detail.html
@@ -38,6 +38,7 @@
-
+
+ {% if ticket.assigned_to %}{{ ticket.assigned_to.username }}{% else %}Niemand zugewiesen{% endif %}
+
+
Wird automatisch basierend auf dem ausgewählten Kurs zugewiesen
{% if view.can_edit %}