From 2cb9d382cbd62ff8b37d589c83045d3dd8adc5c7 Mon Sep 17 00:00:00 2001 From: Georg Lehner Date: Sat, 8 Jun 2024 18:49:53 +0200 Subject: [PATCH] Only show open ticket as dependency/parent candidates It makes no sense to make a ticket depend on an already closed ticket, or to make a closed ticket depend on another. The only case I can think of is to create such a relationship in hindsight for documentation purposes. This can be implemented by adding an admin interface or giving the administrator more choices. --- helpdesk/forms.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 33501190..6c981a3c 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -594,8 +594,8 @@ class TicketDependencyForm(forms.ModelForm): def __init__(self, ticket, *args, **kwargs): super(TicketDependencyForm,self).__init__(*args, **kwargs) - # Exclude duplicate tickets, myself, existing dependencies and parents - self.fields['depends_on'].queryset = Ticket.objects.exclude(status=Ticket.DUPLICATE_STATUS).exclude(id=ticket.id).exclude(depends_on__ticket=ticket).exclude(ticketdependency__depends_on=ticket) + # Only open tickets except myself, existing dependencies and parents + self.fields['depends_on'].queryset = Ticket.objects.filter(status__in=Ticket.OPEN_STATUSES).exclude(id=ticket.id).exclude(depends_on__ticket=ticket).exclude(ticketdependency__depends_on=ticket) class TicketResolvesForm(forms.ModelForm): ''' Adds this ticket as a dependency for a different ticket ''' @@ -608,8 +608,8 @@ class TicketResolvesForm(forms.ModelForm): def __init__(self, ticket, *args, **kwargs): super(TicketResolvesForm,self).__init__(*args, **kwargs) - # Exclude duplicate tickets, myself, existing dependencies and parents - self.fields['ticket'].queryset = Ticket.objects.exclude(status=Ticket.DUPLICATE_STATUS).exclude(id=ticket.id).exclude(depends_on__ticket=ticket).exclude(ticketdependency__depends_on=ticket) + # Only open tickets except myself, existing dependencies and parents + self.fields['ticket'].queryset = Ticket.objects.exclude(status__in=Ticket.OPEN_STATUSES).exclude(id=ticket.id).exclude(depends_on__ticket=ticket).exclude(ticketdependency__depends_on=ticket) class MultipleTicketSelectForm(forms.Form):