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.
This commit is contained in:
Georg Lehner 2024-06-08 18:49:53 +02:00
parent 7bf21685b3
commit 2cb9d382cb

View File

@ -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):