mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-06-17 07:06:54 +02:00
Add redirect_from_chosen_ticket
helper function
Moves the whole handling to own block, reducing complexity greatly.
This commit is contained in:
parent
eb11c4fe0e
commit
a248181857
@ -1031,35 +1031,12 @@ def merge_ticket_values(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@staff_member_required
|
def redirect_from_chosen_ticket(
|
||||||
def merge_tickets(request):
|
request,
|
||||||
"""
|
chosen_ticket,
|
||||||
An intermediate view to merge up to 3 tickets in one main ticket.
|
tickets,
|
||||||
The user has to first select which ticket will receive the other tickets information and can also choose which
|
custom_fields
|
||||||
data to keep per attributes as well as custom fields.
|
) -> HttpResponseRedirect:
|
||||||
Follow-ups and ticketCC will be moved to the main ticket and other tickets won't be able to receive new answers.
|
|
||||||
"""
|
|
||||||
ticket_select_form = MultipleTicketSelectForm(request.GET or None)
|
|
||||||
tickets = custom_fields = None
|
|
||||||
if ticket_select_form.is_valid():
|
|
||||||
tickets = ticket_select_form.cleaned_data.get('tickets')
|
|
||||||
|
|
||||||
custom_fields = CustomField.objects.all()
|
|
||||||
|
|
||||||
merge_ticket_values(request, tickets, custom_fields)
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
# Find which ticket has been chosen to be the main one
|
|
||||||
try:
|
|
||||||
chosen_ticket = tickets.get(
|
|
||||||
id=request.POST.get('chosen_ticket'))
|
|
||||||
except Ticket.DoesNotExist:
|
|
||||||
ticket_select_form.add_error(
|
|
||||||
field='tickets',
|
|
||||||
error=_(
|
|
||||||
'Please choose a ticket in which the others will be merged into.')
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
# Save ticket fields values
|
# Save ticket fields values
|
||||||
for attribute, __ in TICKET_ATTRIBUTES:
|
for attribute, __ in TICKET_ATTRIBUTES:
|
||||||
id_for_attribute = request.POST.get(attribute)
|
id_for_attribute = request.POST.get(attribute)
|
||||||
@ -1149,6 +1126,43 @@ def merge_tickets(request):
|
|||||||
ticketcc=ticketcc)
|
ticketcc=ticketcc)
|
||||||
return redirect(chosen_ticket)
|
return redirect(chosen_ticket)
|
||||||
|
|
||||||
|
|
||||||
|
@staff_member_required
|
||||||
|
def merge_tickets(request):
|
||||||
|
"""
|
||||||
|
An intermediate view to merge up to 3 tickets in one main ticket.
|
||||||
|
The user has to first select which ticket will receive the other tickets information and can also choose which
|
||||||
|
data to keep per attributes as well as custom fields.
|
||||||
|
Follow-ups and ticketCC will be moved to the main ticket and other tickets won't be able to receive new answers.
|
||||||
|
"""
|
||||||
|
ticket_select_form = MultipleTicketSelectForm(request.GET or None)
|
||||||
|
tickets = custom_fields = None
|
||||||
|
if ticket_select_form.is_valid():
|
||||||
|
tickets = ticket_select_form.cleaned_data.get('tickets')
|
||||||
|
|
||||||
|
custom_fields = CustomField.objects.all()
|
||||||
|
|
||||||
|
merge_ticket_values(request, tickets, custom_fields)
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
# Find which ticket has been chosen to be the main one
|
||||||
|
try:
|
||||||
|
chosen_ticket = tickets.get(
|
||||||
|
id=request.POST.get('chosen_ticket'))
|
||||||
|
except Ticket.DoesNotExist:
|
||||||
|
ticket_select_form.add_error(
|
||||||
|
field='tickets',
|
||||||
|
error=_(
|
||||||
|
'Please choose a ticket in which the others will be merged into.')
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return redirect_from_chosen_ticket(
|
||||||
|
request,
|
||||||
|
chosen_ticket,
|
||||||
|
tickets,
|
||||||
|
custom_fields
|
||||||
|
)
|
||||||
|
|
||||||
return render(request, 'helpdesk/ticket_merge.html', {
|
return render(request, 'helpdesk/ticket_merge.html', {
|
||||||
'tickets': tickets,
|
'tickets': tickets,
|
||||||
'TICKET_ATTRIBUTES': TICKET_ATTRIBUTES,
|
'TICKET_ATTRIBUTES': TICKET_ATTRIBUTES,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user