30 lines
796 B
Python
30 lines
796 B
Python
from django import forms
|
|
from .models import Comment, Ticket
|
|
|
|
|
|
class CommentForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Comment
|
|
fields = ["text"]
|
|
widgets = {
|
|
"text": forms.Textarea(
|
|
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 |