Repository: django-helpdesk/django-helpdesk

Issue:
merged_to field needs help_text
**Is your feature request related to a problem? Please describe.**
Some users do not find the "Merged to" title to be intuitive enough.

**Describe the solution you'd like**
Add help_text to the `merged_to` field in the `class Ticket` of `models.py` and update migrations as necessary.
`help_text=_('If selected, this ticket will be merged into the selected ticket.'),`

![image](https://user-images.githubusercontent.com/60234929/106806812-a7cd3a00-6625-11eb-8d64-44a33353db7d.png)

**Describe alternatives you've considered**
Renaming the field was another option, but this seems like a simple solution that will work well with minimal effort.


Discussion:
You're right, the name is not really explicit. But warning : if you edit a ticket and set the `merged_to` field, it won't trigger the real merging action.
To do this, you have to select the tickets you want to merge in the ticket list. Then you would choose which information to keep, and all the followups, ticketcc and attachments will be moved from a ticket to the main one.

So this field in the edit ticket form is not really necessary in fact. It's more for the superuser to correct an error. So maybe the best solution would be to remove it from this form for normal users ?
The field could be disabled (grayed out) on the edit screen for display purposes.
OR
The field change could trigger the merging action.

Either option could work, I'm not familiar with how we would accomplish either.
Yeah I think first option could be nice, I can make a PR for that.
Second might not really be easy to implement since it requires an intermediate page to choose which information to merge.
Will you include the help_text on your PR also please.

On Thu, Feb 4, 2021 at 9:53 AM Benbb96 <notifications@github.com> wrote:

> Yeah I think first option could be nice, I can make a PR for that.
> Second might not really be easy to implement since it requires an
> intermediate page to choose which information to merge.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/django-helpdesk/django-helpdesk/issues/938#issuecomment-773454296>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AOLRZMOEICJ3EDY34XMEHYDS5LGI7ANCNFSM4XBRNRFA>
> .
>

help_text=_('This ticket is merged into the selected ticket.'),
Yes no problem 😉 

Resolving patch:
diff --git a/helpdesk/forms.py b/helpdesk/forms.py
--- a/helpdesk/forms.py
+++ b/helpdesk/forms.py
@@ -83,6 +83,12 @@ def customfield_to_field(self, field, instanceargs):
 
 
 class EditTicketForm(CustomFieldMixin, forms.ModelForm):
+    merged_to = forms.ModelChoiceField(
+        label=_('Merged to'),
+        help_text=_('This ticket is merged into the selected ticket.'),
+        queryset=Ticket.objects.all(),
+        disabled=True
+    )
 
     class Meta:
         model = Ticket
diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py
--- a/helpdesk/views/staff.py
+++ b/helpdesk/views/staff.py
@@ -1213,13 +1213,10 @@ def edit_ticket(request, ticket_id):
     ticket = get_object_or_404(Ticket, id=ticket_id)
     ticket_perm_check(request, ticket)
 
-    if request.method == 'POST':
-        form = EditTicketForm(request.POST, instance=ticket)
-        if form.is_valid():
-            ticket = form.save()
-            return HttpResponseRedirect(ticket.get_absolute_url())
-    else:
-        form = EditTicketForm(instance=ticket)
+    form = EditTicketForm(request.POST or None, instance=ticket)
+    if form.is_valid():
+        ticket = form.save()
+        return redirect(ticket)
 
     return render(request, 'helpdesk/edit_ticket.html', {'form': form, 'ticket': ticket})
 


Test patch: