mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-13 10:21:05 +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):
|
||||
tickets = forms.ModelMultipleChoiceField(
|
||||
label=_('Tickets to merge'),
|
||||
queryset=Ticket.objects.all(),
|
||||
queryset=Ticket.objects.filter(merged_to=None),
|
||||
widget=forms.SelectMultiple(attrs={'class': 'form-control'})
|
||||
)
|
||||
|
||||
def clean_tickets(self):
|
||||
tickets = self.cleaned_data.get('tickets')
|
||||
if len(tickets) < 2:
|
||||
raise ValidationError(_('Please choose at least 2 tickets'))
|
||||
raise ValidationError(_('Please choose at least 2 tickets.'))
|
||||
if len(tickets) > 4:
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user