mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2025-02-05 13:00:54 +01:00
multiple things regarding ticketcc
- generate ticketcc_string in view_ticket() and followup_edit(), and not in ticket_desc_table.html - added 'subscribe' button to ticket_desc_table.html, which allows user to subscribe him/herself to the ticket whilst viewing it. - added 'HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE' option, to automatically cc the current user if (s)he responds to a ticket.
This commit is contained in:
parent
a2a5b10b2d
commit
4bf79ccf46
@ -66,6 +66,9 @@ HELPDESK_FOLLOWUP_MOD = getattr(settings, 'HELPDESK_FOLLOWUP_MOD', False)
|
|||||||
# show custom welcome message in dashboard?
|
# show custom welcome message in dashboard?
|
||||||
HELPDESK_CUSTOM_WELCOME = getattr(settings, 'HELPDESK_CUSTOM_WELCOME', False)
|
HELPDESK_CUSTOM_WELCOME = getattr(settings, 'HELPDESK_CUSTOM_WELCOME', False)
|
||||||
|
|
||||||
|
# auto-subscribe user to ticket if (s)he responds to a ticket?
|
||||||
|
HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE = getattr(settings, 'HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE', False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
''' options for public pages '''
|
''' options for public pages '''
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<tr class='{% cycle rowcolors %}'>
|
<tr class='{% cycle rowcolors %}'>
|
||||||
<th>{% trans "Copies To" %}</th>
|
<th>{% trans "Copies To" %}</th>
|
||||||
<td>{% for ticketcc in ticket.ticketcc_set.all %}{{ ticketcc.display }}{% if not forloop.last %}, {% endif %}{% endfor %} <strong><a class='tooltip' href='{% url helpdesk_ticket_cc ticket.id %}'>{% trans "Manage" %}<span>{% trans "Click here to add / remove people who should receive an e-mail whenever this ticket is updated." %}</span></a></strong></td>
|
<td>{{ ticketcc_string }} <strong><a class='tooltip' href='{% url helpdesk_ticket_cc ticket.id %}'>{% trans "Manage" %}<span>{% trans "Click here to add / remove people who should receive an e-mail whenever this ticket is updated." %}</span></a></strong>{% if SHOW_SUBSCRIBE %}, <strong><a class='tooltip' href='?subscribe'>{% trans "Subscribe" %}<span>{% trans "Click here to subscribe yourself to this ticket, if you want to receive an e-mail whenever this ticket is updated." %}</span></a></strong>{% endif %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% if tags_enabled %}
|
{% if tags_enabled %}
|
||||||
|
@ -151,12 +151,13 @@ def followup_edit(request, ticket_id, followup_id):
|
|||||||
'public': followup.public,
|
'public': followup.public,
|
||||||
'new_status': followup.new_status,
|
'new_status': followup.new_status,
|
||||||
})
|
})
|
||||||
|
ticketcc_string, SHOW_SUBSCRIBE = return_ticketccstring_and_show_subscribe(request.user, ticket)
|
||||||
return render_to_response('helpdesk/followup_edit.html',
|
return render_to_response('helpdesk/followup_edit.html',
|
||||||
RequestContext(request, {
|
RequestContext(request, {
|
||||||
'followup': followup,
|
'followup': followup,
|
||||||
'ticket': ticket,
|
'ticket': ticket,
|
||||||
'form': form,
|
'form': form,
|
||||||
|
'ticketcc_string': ticketcc_string,
|
||||||
}))
|
}))
|
||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
form = EditFollowUpForm(request.POST)
|
form = EditFollowUpForm(request.POST)
|
||||||
@ -211,6 +212,13 @@ def view_ticket(request, ticket_id):
|
|||||||
}
|
}
|
||||||
return update_ticket(request, ticket_id)
|
return update_ticket(request, ticket_id)
|
||||||
|
|
||||||
|
if request.GET.has_key('subscribe'):
|
||||||
|
# Allow the user to subscribe him/herself to the ticket whilst viewing it.
|
||||||
|
ticketcc_string, SHOW_SUBSCRIBE = return_ticketccstring_and_show_subscribe(request.user, ticket)
|
||||||
|
if SHOW_SUBSCRIBE:
|
||||||
|
subscribe_staff_member_to_ticket(ticket, request.user)
|
||||||
|
return HttpResponseRedirect(reverse('helpdesk_view', args=[ticket.id]))
|
||||||
|
|
||||||
if request.GET.has_key('close') and ticket.status == Ticket.RESOLVED_STATUS:
|
if request.GET.has_key('close') and ticket.status == Ticket.RESOLVED_STATUS:
|
||||||
if not ticket.assigned_to:
|
if not ticket.assigned_to:
|
||||||
owner = 0
|
owner = 0
|
||||||
@ -229,6 +237,8 @@ def view_ticket(request, ticket_id):
|
|||||||
|
|
||||||
return update_ticket(request, ticket_id)
|
return update_ticket(request, ticket_id)
|
||||||
|
|
||||||
|
|
||||||
|
ticketcc_string, SHOW_SUBSCRIBE = return_ticketccstring_and_show_subscribe(request.user, ticket)
|
||||||
return render_to_response('helpdesk/ticket.html',
|
return render_to_response('helpdesk/ticket.html',
|
||||||
RequestContext(request, {
|
RequestContext(request, {
|
||||||
'ticket': ticket,
|
'ticket': ticket,
|
||||||
@ -236,10 +246,56 @@ def view_ticket(request, ticket_id):
|
|||||||
'priorities': Ticket.PRIORITY_CHOICES,
|
'priorities': Ticket.PRIORITY_CHOICES,
|
||||||
'preset_replies': PreSetReply.objects.filter(Q(queues=ticket.queue) | Q(queues__isnull=True)),
|
'preset_replies': PreSetReply.objects.filter(Q(queues=ticket.queue) | Q(queues__isnull=True)),
|
||||||
'tags_enabled': HAS_TAG_SUPPORT,
|
'tags_enabled': HAS_TAG_SUPPORT,
|
||||||
|
'ticketcc_string': ticketcc_string,
|
||||||
|
'SHOW_SUBSCRIBE': SHOW_SUBSCRIBE,
|
||||||
}))
|
}))
|
||||||
view_ticket = staff_member_required(view_ticket)
|
view_ticket = staff_member_required(view_ticket)
|
||||||
|
|
||||||
|
|
||||||
|
def return_ticketccstring_and_show_subscribe(user, ticket):
|
||||||
|
''' used in view_ticket() and followup_edit()'''
|
||||||
|
# create the ticketcc_string and check whether current user is already
|
||||||
|
# subscribed
|
||||||
|
username = user.username.upper()
|
||||||
|
useremail = user.email.upper()
|
||||||
|
strings_to_check = list()
|
||||||
|
strings_to_check.append(username)
|
||||||
|
strings_to_check.append(useremail)
|
||||||
|
|
||||||
|
ticketcc_string = ''
|
||||||
|
all_ticketcc = ticket.ticketcc_set.all()
|
||||||
|
counter_all_ticketcc = len(all_ticketcc) - 1
|
||||||
|
SHOW_SUBSCRIBE = True
|
||||||
|
for i, ticketcc in enumerate(all_ticketcc):
|
||||||
|
ticketcc_this_entry = str(ticketcc.display)
|
||||||
|
ticketcc_string = ticketcc_string + ticketcc_this_entry
|
||||||
|
if i < counter_all_ticketcc:
|
||||||
|
ticketcc_string = ticketcc_string + ', '
|
||||||
|
if strings_to_check.__contains__(ticketcc_this_entry.upper()):
|
||||||
|
SHOW_SUBSCRIBE = False
|
||||||
|
|
||||||
|
# check whether current user is a submitter or assigned to ticket
|
||||||
|
assignedto_username = str(ticket.assigned_to).upper()
|
||||||
|
submitter_email = ticket.submitter_email.upper()
|
||||||
|
strings_to_check = list()
|
||||||
|
strings_to_check.append(assignedto_username)
|
||||||
|
strings_to_check.append(submitter_email)
|
||||||
|
if strings_to_check.__contains__(username) or strings_to_check.__contains__(useremail):
|
||||||
|
SHOW_SUBSCRIBE = False
|
||||||
|
|
||||||
|
return ticketcc_string, SHOW_SUBSCRIBE
|
||||||
|
|
||||||
|
|
||||||
|
def subscribe_staff_member_to_ticket(ticket, user):
|
||||||
|
''' used in view_ticket() and update_ticket() '''
|
||||||
|
ticketcc = TicketCC()
|
||||||
|
ticketcc.ticket = ticket
|
||||||
|
ticketcc.user = user
|
||||||
|
ticketcc.can_view = True
|
||||||
|
ticketcc.can_update = True
|
||||||
|
ticketcc.save()
|
||||||
|
|
||||||
|
|
||||||
def update_ticket(request, ticket_id, public=False):
|
def update_ticket(request, ticket_id, public=False):
|
||||||
if not (public or (request.user.is_authenticated() and request.user.is_active and (request.user.is_staff or helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE))):
|
if not (public or (request.user.is_authenticated() and request.user.is_active and (request.user.is_staff or helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE))):
|
||||||
return HttpResponseForbidden(_('Sorry, you need to login to do that.'))
|
return HttpResponseForbidden(_('Sorry, you need to login to do that.'))
|
||||||
@ -468,6 +524,12 @@ def update_ticket(request, ticket_id, public=False):
|
|||||||
|
|
||||||
ticket.save()
|
ticket.save()
|
||||||
|
|
||||||
|
# auto subscribe user if enabled
|
||||||
|
if helpdesk_settings.HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE:
|
||||||
|
ticketcc_string, SHOW_SUBSCRIBE = return_ticketccstring_and_show_subscribe(request.user, ticket)
|
||||||
|
if SHOW_SUBSCRIBE:
|
||||||
|
subscribe_staff_member_to_ticket(ticket, request.user)
|
||||||
|
|
||||||
return return_to_ticket(request.user, helpdesk_settings, ticket)
|
return return_to_ticket(request.user, helpdesk_settings, ticket)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user