feat: auto select tutor as assignee
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user