mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-01-07 06:28:52 +01:00
Restrict possible tickets to merge to the ones that haven't been already merged.
Also check that all selected tickets are within the same queue.
This commit is contained in:
parent
da5028d51a
commit
00a18d8f54
@ -515,14 +515,17 @@ class TicketDependencyForm(forms.ModelForm):
|
|||||||
class MultipleTicketSelectForm(forms.Form):
|
class MultipleTicketSelectForm(forms.Form):
|
||||||
tickets = forms.ModelMultipleChoiceField(
|
tickets = forms.ModelMultipleChoiceField(
|
||||||
label=_('Tickets to merge'),
|
label=_('Tickets to merge'),
|
||||||
queryset=Ticket.objects.all(),
|
queryset=Ticket.objects.filter(merged_to=None),
|
||||||
widget=forms.SelectMultiple(attrs={'class': 'form-control'})
|
widget=forms.SelectMultiple(attrs={'class': 'form-control'})
|
||||||
)
|
)
|
||||||
|
|
||||||
def clean_tickets(self):
|
def clean_tickets(self):
|
||||||
tickets = self.cleaned_data.get('tickets')
|
tickets = self.cleaned_data.get('tickets')
|
||||||
if len(tickets) < 2:
|
if len(tickets) < 2:
|
||||||
raise ValidationError(_('Please choose at least 2 tickets'))
|
raise ValidationError(_('Please choose at least 2 tickets.'))
|
||||||
if len(tickets) > 4:
|
if len(tickets) > 4:
|
||||||
raise ValidationError(_('Impossible to merge more than 4 tickets...'))
|
raise ValidationError(_('Impossible to merge more than 4 tickets...'))
|
||||||
|
queues = tickets.order_by('queue').distinct().values_list('queue', flat=True)
|
||||||
|
if len(queues) != 1:
|
||||||
|
raise ValidationError(_('All selected tickets must share the same queue in order to be merged.'))
|
||||||
return tickets
|
return tickets
|
||||||
|
Loading…
Reference in New Issue
Block a user