feat: replaced priority with mistake
This commit is contained in:
@@ -38,7 +38,7 @@ class TicketForm(forms.ModelForm):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Ticket
|
model = Ticket
|
||||||
fields = ["title", "description", "status", "priority", "course", "answer", "material"]
|
fields = ["title", "description", "status", "mistake", "course", "answer", "material"]
|
||||||
widgets = {
|
widgets = {
|
||||||
'answer': forms.Textarea(attrs={
|
'answer': forms.Textarea(attrs={
|
||||||
'rows': 4,
|
'rows': 4,
|
||||||
@@ -68,14 +68,17 @@ class TicketForm(forms.ModelForm):
|
|||||||
|
|
||||||
def _set_field_permissions(self, is_tutor, is_creator, is_superuser):
|
def _set_field_permissions(self, is_tutor, is_creator, is_superuser):
|
||||||
"""Setzt welche Felder bearbeitet werden dürfen"""
|
"""Setzt welche Felder bearbeitet werden dürfen"""
|
||||||
if is_tutor and not is_superuser:
|
if self.ticket.status == 'resolved' and is_creator and not is_superuser:
|
||||||
|
for field_name in self.fields:
|
||||||
|
if field_name == "answer":
|
||||||
|
self.fields[field_name].disabled = True
|
||||||
|
elif is_tutor and not is_superuser:
|
||||||
# Tutor darf ändern:
|
# Tutor darf ändern:
|
||||||
readonly_fields = ['title', 'description', 'material']
|
readonly_fields = ['title', 'description', 'material']
|
||||||
for field_name in readonly_fields:
|
for field_name in readonly_fields:
|
||||||
if field_name in self.fields:
|
if field_name in self.fields:
|
||||||
self.fields[field_name].disabled = True
|
self.fields[field_name].disabled = True
|
||||||
elif is_creator and not is_superuser and self.ticket.status != 'resolved':
|
elif is_creator and not is_superuser and self.ticket.status != 'resolved':
|
||||||
# Creator darf ändern bei resolved
|
|
||||||
for field_name in self.fields:
|
for field_name in self.fields:
|
||||||
self.fields[field_name].disabled = True
|
self.fields[field_name].disabled = True
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,14 @@ class Ticket(models.Model):
|
|||||||
("closed", "Geschlossen"),
|
("closed", "Geschlossen"),
|
||||||
]
|
]
|
||||||
|
|
||||||
PRIORITY_CHOICES = [
|
MISTAKE_CHOICES = [
|
||||||
("low", "Niedrig"),
|
("typo", "Tippfehler"),
|
||||||
("medium", "Mittel"),
|
("formatting_issue", "Formatierungsfehler"),
|
||||||
("high", "Hoch"),
|
("missing_content", "Fehlender Inhalt"),
|
||||||
|
("outdated_content", "Veralteter Inhalt"),
|
||||||
|
("audio_problem", "Audio-Problem"),
|
||||||
|
("video_problem", "Video-Problem"),
|
||||||
|
("other", "Sonstiges"),
|
||||||
]
|
]
|
||||||
|
|
||||||
MATERIAL_CHOICES = [
|
MATERIAL_CHOICES = [
|
||||||
@@ -58,7 +62,7 @@ class Ticket(models.Model):
|
|||||||
title = models.CharField(max_length=200)
|
title = models.CharField(max_length=200)
|
||||||
description = models.TextField()
|
description = models.TextField()
|
||||||
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default="new")
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default="new")
|
||||||
priority = models.CharField(max_length=10, choices=PRIORITY_CHOICES, default="medium")
|
mistake = models.CharField(max_length=20, choices=MISTAKE_CHOICES, default="medium")
|
||||||
material = models.CharField(max_length=20, choices=MATERIAL_CHOICES, default="script")
|
material = models.CharField(max_length=20, choices=MATERIAL_CHOICES, default="script")
|
||||||
|
|
||||||
answer = models.TextField(
|
answer = models.TextField(
|
||||||
@@ -89,7 +93,7 @@ class Ticket(models.Model):
|
|||||||
updated_at = models.DateTimeField(auto_now=True)
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"[{self.get_priority_display()}] {self.title} ({self.get_status_display()})"
|
return f"[{self.get_mistake_display()}] {self.title} ({self.get_status_display()})"
|
||||||
|
|
||||||
|
|
||||||
class Comment(models.Model):
|
class Comment(models.Model):
|
||||||
|
|||||||
@@ -76,13 +76,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium mb-1">Priorität:</label>
|
<label class="block text-sm font-medium mb-1">Priorität:</label>
|
||||||
<select name="priority"
|
<select name="mistake"
|
||||||
{% if not view.can_edit or form.priority.field.disabled %}disabled{% endif %}
|
{% if not view.can_edit or form.mistake.field.disabled %}disabled{% endif %}
|
||||||
class="w-full p-2 border border-gray-300 rounded shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 {% if not view.can_edit or form.priority.field.disabled %}bg-gray-100{% endif %}">
|
class="w-full p-2 border border-gray-300 rounded shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 {% if not view.can_edit or form.mistake.field.disabled %}bg-gray-100{% endif %}">
|
||||||
<option value="low" {% if ticket.priority == 'low' %}selected{% endif %}>Niedrig</option>
|
{% for value, label in form.mistake.field.choices %}
|
||||||
<option value="medium"
|
<option value="{{ value }}"
|
||||||
{% if ticket.priority == 'medium' %}selected{% endif %}>Normal</option>
|
{% if value == ticket.mistake %}selected{% endif %}>{{ label }}</option>
|
||||||
<option value="high" {% if ticket.priority == 'high' %}selected{% endif %}>Hoch</option>
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -124,7 +124,9 @@
|
|||||||
class="w-full p-2 border border-gray-300 rounded shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 placeholder:text-black {% if not view.can_edit or ticket.status != 'resolved' %}bg-gray-100 cursor-not-allowed{% endif %}">{{ ticket.answer|default:'' }}</textarea>
|
class="w-full p-2 border border-gray-300 rounded shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 placeholder:text-black {% if not view.can_edit or ticket.status != 'resolved' %}bg-gray-100 cursor-not-allowed{% endif %}">{{ ticket.answer|default:'' }}</textarea>
|
||||||
{% if form.answer.errors %}<div class="text-red-600 text-sm mt-1">{{ form.answer.errors }}</div>{% endif %}
|
{% if form.answer.errors %}<div class="text-red-600 text-sm mt-1">{{ form.answer.errors }}</div>{% endif %}
|
||||||
<p class="text-xs text-gray-500 mt-1">
|
<p class="text-xs text-gray-500 mt-1">
|
||||||
{% if ticket.status != 'resolved' or ticket.status != 'closed' %}Eine Antwort ist erforderlich beim Setzen des Status auf "Gelöst"{% endif %}
|
{% if ticket.status != 'resolved' or ticket.status != 'closed' %}
|
||||||
|
Eine Antwort ist erforderlich beim Setzen des Status auf "Gelöst"
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
<th class="px-4 py-3 text-center text-sm font-bold">#</th>
|
<th class="px-4 py-3 text-center text-sm font-bold">#</th>
|
||||||
<th class="px-4 py-3 text-left text-sm font-bold">Titel</th>
|
<th class="px-4 py-3 text-left text-sm font-bold">Titel</th>
|
||||||
<th class="px-4 py-3 text-center text-sm font-bold">Status</th>
|
<th class="px-4 py-3 text-center text-sm font-bold">Status</th>
|
||||||
<th class="px-4 py-3 text-center text-sm font-bold">Priorität</th>
|
<th class="px-4 py-3 text-center text-sm font-bold">Fehlerart</th>
|
||||||
<th class="px-4 py-3 text-left text-sm font-bold">Zugewiesen an</th>
|
<th class="px-4 py-3 text-left text-sm font-bold">Zugewiesen an</th>
|
||||||
<th class="px-4 py-3 text-center text-sm font-bold">Erstellt</th>
|
<th class="px-4 py-3 text-center text-sm font-bold">Erstellt</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -163,19 +163,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="px-4 py-3 text-center">
|
<td class="px-4 py-3 text-center">
|
||||||
{% if ticket.priority == 'low' %}
|
<span class="px-2 py-1 rounded-full text-xs font-bold bg-blue-500 text-white">{{ ticket.get_mistake_display }}</span>
|
||||||
<span class="px-2 py-1 rounded-full text-xs font-bold bg-blue-500 text-white">{{ ticket.get_priority_display }}</span>
|
|
||||||
{% elif ticket.priority == 'medium' %}
|
|
||||||
<span class="px-2 py-1 rounded-full text-xs font-bold bg-yellow-400 text-gray-900">
|
|
||||||
{{ ticket.get_priority_display }}
|
|
||||||
</span>
|
|
||||||
{% elif ticket.priority == 'high' %}
|
|
||||||
<span class="px-2 py-1 rounded-full text-xs font-bold bg-orange-500 text-white">
|
|
||||||
{{ ticket.get_priority_display }}
|
|
||||||
</span>
|
|
||||||
{% elif ticket.priority == 'urgent' %}
|
|
||||||
<span class="px-2 py-1 rounded-full text-xs font-bold bg-red-500 text-white">{{ ticket.get_priority_display }}</span>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
</td>
|
||||||
<td class="px-4 py-3 text-sm text-gray-600">
|
<td class="px-4 py-3 text-sm text-gray-600">
|
||||||
{% if ticket.assigned_to %}
|
{% if ticket.assigned_to %}
|
||||||
|
|||||||
@@ -93,15 +93,15 @@
|
|||||||
{% if form.status.errors %}<div class="text-red-600 text-sm mt-1">{{ form.status.errors }}</div>{% endif %}
|
{% if form.status.errors %}<div class="text-red-600 text-sm mt-1">{{ form.status.errors }}</div>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium mb-1">Priorität:</label>
|
<label class="block text-sm font-medium mb-1">Fehlerart:</label>
|
||||||
<select name="priority"
|
<select name="mistake"
|
||||||
class="w-full p-2 border border-gray-300 rounded shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
class="w-full p-2 border border-gray-300 rounded shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
||||||
{% for value, display in form.fields.priority.choices %}
|
{% for value, display in form.fields.mistake.choices %}
|
||||||
<option value="{{ value }}"
|
<option value="{{ value }}"
|
||||||
{% if form.priority.value == value %}selected{% endif %}>{{ display }}</option>
|
{% if form.mistake.value == value %}selected{% endif %}>{{ display }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
{% if form.priority.errors %}<div class="text-red-600 text-sm mt-1">{{ form.priority.errors }}</div>{% endif %}
|
{% if form.mistake.errors %}<div class="text-red-600 text-sm mt-1">{{ form.mistake.errors }}</div>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Zugewiesen an -->
|
<!-- Zugewiesen an -->
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class TicketDetailUpdateView(UpdateView):
|
|||||||
response = super().form_valid(form) # Speichert das Ticket
|
response = super().form_valid(form) # Speichert das Ticket
|
||||||
|
|
||||||
# History tracking für geänderte Felder
|
# History tracking für geänderte Felder
|
||||||
tracked_fields = ["title", "description", "status", "priority", "course", "answer", "material"]
|
tracked_fields = ["title", "description", "status", "mistake", "course", "answer", "material"]
|
||||||
for field in tracked_fields:
|
for field in tracked_fields:
|
||||||
if field in form.changed_data:
|
if field in form.changed_data:
|
||||||
old_value = getattr(original, field)
|
old_value = getattr(original, field)
|
||||||
@@ -138,9 +138,9 @@ class TicketDetailUpdateView(UpdateView):
|
|||||||
if field == "status":
|
if field == "status":
|
||||||
old_value = original.get_status_display()
|
old_value = original.get_status_display()
|
||||||
new_value = ticket.get_status_display()
|
new_value = ticket.get_status_display()
|
||||||
elif field == "priority":
|
elif field == "mistake":
|
||||||
old_value = original.get_priority_display()
|
old_value = original.get_mistake_display()
|
||||||
new_value = ticket.get_priority_display()
|
new_value = ticket.get_mistake_display()
|
||||||
elif field == "course":
|
elif field == "course":
|
||||||
old_value = str(old_value)
|
old_value = str(old_value)
|
||||||
new_value = str(new_value)
|
new_value = str(new_value)
|
||||||
@@ -239,7 +239,7 @@ class TicketCreateView(CreateView):
|
|||||||
|
|
||||||
class TicketUpdateView(LoginRequiredMixin, UpdateView):
|
class TicketUpdateView(LoginRequiredMixin, UpdateView):
|
||||||
model = Ticket
|
model = Ticket
|
||||||
fields = ["title", "description", "status", "priority", "assigned_to", "course"]
|
fields = ["title", "description", "status", "mistake", "assigned_to", "course"]
|
||||||
template_name = "ticketsystem/ticket_form.html"
|
template_name = "ticketsystem/ticket_form.html"
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
@@ -259,7 +259,7 @@ class TicketUpdateView(LoginRequiredMixin, UpdateView):
|
|||||||
|
|
||||||
response = super().form_valid(form) # Speichert das Ticket
|
response = super().form_valid(form) # Speichert das Ticket
|
||||||
|
|
||||||
tracked_fields = ["status", "description", "priority"]
|
tracked_fields = ["status", "description", "mistake"]
|
||||||
for field in tracked_fields:
|
for field in tracked_fields:
|
||||||
if field in form.changed_data:
|
if field in form.changed_data:
|
||||||
old_value = getattr(original, field)
|
old_value = getattr(original, field)
|
||||||
|
|||||||
Reference in New Issue
Block a user