Implement ticket merge feature in ticket list. Create intermediate page to choose which data and custom field values to keep on the main ticket.

Also add new template tag filter to use the dictionary get function in template.
This commit is contained in:
bbe
2020-10-29 23:32:02 +01:00
parent 9795167d9b
commit e1cd9d0f2e
9 changed files with 332 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ forms.py - Definitions of newforms-based forms for creating and maintaining
"""
import logging
from django.core.exceptions import ObjectDoesNotExist
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django import forms
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
@@ -510,3 +510,19 @@ class TicketDependencyForm(forms.ModelForm):
class Meta:
model = TicketDependency
exclude = ('ticket',)
class MultipleTicketSelectForm(forms.Form):
tickets = forms.ModelMultipleChoiceField(
label=_('Tickets to merge'),
queryset=Ticket.objects.all(),
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'))
if len(tickets) > 4:
raise ValidationError(_('Impossible to merge more than 4 tickets...'))
return tickets