mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-13 02:10:49 +01:00
Fixes three issues:
#65: When submitter clicks 'Accept' to accept a resolution, nothing happens. #74: issues when updating ticket via views.staff.update_ticket (which is also used by the public views) relating to invalid template context and inconsistent variable naming. #82: Add an option for users to control the number of tickets per page. Thank you to J. Beigel and Christian Klein for these suggestions.
This commit is contained in:
parent
df30fe9e2a
commit
c7b45a8edc
8
forms.py
8
forms.py
@ -329,6 +329,14 @@ class UserSettingsForm(forms.Form):
|
||||
required=False,
|
||||
)
|
||||
|
||||
tickets_per_page = forms.IntegerField(
|
||||
label=_('Number of tickets to show per page'),
|
||||
help_text=_('How many tickets do you want to see on the Ticket List page?'),
|
||||
required=False,
|
||||
min_value=1,
|
||||
max_value=1000,
|
||||
)
|
||||
|
||||
class EmailIgnoreForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = IgnoreEmail
|
||||
|
@ -30,7 +30,7 @@
|
||||
</tr>
|
||||
|
||||
{% if ticket.resolution %}<tr class='row_even'>
|
||||
<th colspan='2'>{% trans "Resolution" %}{% ifequal ticket.get_status_display "Resolved" %} <a href='?close'><img src='{{ MEDIA_URL }}/helpdesk/buttons/accept.png' alt='{% trans "Accept" %}' title='{% trans "Accept and Close" %}' width='60' height='15' /></a>{% endifequal %}</th>
|
||||
<th colspan='2'>{% trans "Resolution" %}{% ifequal ticket.get_status_display "Resolved" %} <a href='{{ request.get_full_path }}&close'><img src='{{ MEDIA_URL }}/helpdesk/buttons/accept.png' alt='{% trans "Accept" %}' title='{% trans "Accept and Close" %}' width='60' height='15' /></a>{% endifequal %}</th>
|
||||
</tr>
|
||||
<tr class='row_odd'>
|
||||
<td colspan='2'>{{ ticket.resolution }}</td>
|
||||
|
@ -59,22 +59,22 @@ def homepage(request):
|
||||
|
||||
|
||||
def view_ticket(request):
|
||||
ticket = request.GET.get('ticket', '')
|
||||
ticket_req = request.GET.get('ticket', '')
|
||||
email = request.GET.get('email', '')
|
||||
error_message = ''
|
||||
|
||||
if ticket and email:
|
||||
parts = ticket.split('-')
|
||||
if ticket_req and email:
|
||||
parts = ticket_req.split('-')
|
||||
queue = '-'.join(parts[0:-1])
|
||||
ticket_id = parts[-1]
|
||||
|
||||
try:
|
||||
t = Ticket.objects.get(id=ticket_id, queue__slug__iexact=queue, submitter_email__iexact=email)
|
||||
ticket = Ticket.objects.get(id=ticket_id, queue__slug__iexact=queue, submitter_email__iexact=email)
|
||||
except:
|
||||
t = False
|
||||
ticket = False
|
||||
error_message = _('Invalid ticket ID or e-mail address. Please try again.')
|
||||
|
||||
if t:
|
||||
if ticket:
|
||||
|
||||
if request.GET.has_key('close') and ticket.status == Ticket.RESOLVED_STATUS:
|
||||
from helpdesk.views.staff import update_ticket
|
||||
@ -83,18 +83,17 @@ def view_ticket(request):
|
||||
request.POST = {
|
||||
'new_status': Ticket.CLOSED_STATUS,
|
||||
'public': 1,
|
||||
'owner': ticket.assigned_to,
|
||||
'owner': ticket.assigned_to.id,
|
||||
'title': ticket.title,
|
||||
'comment': _('Submitter accepted resolution and closed ticket'),
|
||||
}
|
||||
request.FILES = {}
|
||||
request.GET = {}
|
||||
|
||||
return update_ticket(request, ticket_id)
|
||||
return update_ticket(request, ticket_id, public=True)
|
||||
|
||||
return render_to_response('helpdesk/public_view_ticket.html',
|
||||
RequestContext(request, {
|
||||
'ticket': t,
|
||||
'ticket': ticket,
|
||||
}))
|
||||
|
||||
return render_to_response('helpdesk/public_view_form.html',
|
||||
|
@ -17,7 +17,7 @@ from django.core.urlresolvers import reverse
|
||||
from django.core.paginator import Paginator
|
||||
from django.db import connection
|
||||
from django.db.models import Q
|
||||
from django.http import HttpResponseRedirect, Http404, HttpResponse
|
||||
from django.http import HttpResponseRedirect, Http404, HttpResponse, HttpResponseForbidden
|
||||
from django.shortcuts import render_to_response, get_object_or_404
|
||||
from django.template import loader, Context, RequestContext
|
||||
from django.utils.translation import ugettext as _
|
||||
@ -130,7 +130,10 @@ def view_ticket(request, ticket_id):
|
||||
view_ticket = staff_member_required(view_ticket)
|
||||
|
||||
|
||||
def update_ticket(request, ticket_id):
|
||||
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)):
|
||||
return HttpResponseForbidden(_('Sorry, you need to login to do that.'))
|
||||
|
||||
ticket = get_object_or_404(Ticket, id=ticket_id)
|
||||
|
||||
comment = request.POST.get('comment', '')
|
||||
@ -143,8 +146,8 @@ def update_ticket(request, ticket_id):
|
||||
# We need to allow the 'ticket' and 'queue' contexts to be applied to the
|
||||
# comment.
|
||||
from django.template import loader, Context
|
||||
context = Context(safe_template_context(ticket))
|
||||
comment = loader.get_template_from_string(comment).render(context)
|
||||
context = safe_template_context(ticket)
|
||||
comment = loader.get_template_from_string(comment).render(Context(context))
|
||||
|
||||
if not owner and ticket.assigned_to:
|
||||
owner = ticket.assigned_to.id
|
||||
@ -231,12 +234,10 @@ def update_ticket(request, ticket_id):
|
||||
ticket.resolution = comment
|
||||
|
||||
if ticket.submitter_email and public and (f.comment or (f.new_status in (Ticket.RESOLVED_STATUS, Ticket.CLOSED_STATUS))):
|
||||
context = {
|
||||
'ticket': ticket,
|
||||
'queue': ticket.queue,
|
||||
'resolution': ticket.resolution,
|
||||
'comment': f.comment,
|
||||
}
|
||||
context.update(
|
||||
resolution=ticket.resolution,
|
||||
comment=f.comment,
|
||||
)
|
||||
|
||||
if f.new_status == Ticket.RESOLVED_STATUS:
|
||||
template = 'resolved_submitter'
|
||||
@ -256,7 +257,8 @@ def update_ticket(request, ticket_id):
|
||||
|
||||
if ticket.assigned_to and request.user != ticket.assigned_to and ticket.assigned_to.email:
|
||||
# We only send e-mails to staff members if the ticket is updated by
|
||||
# another user.
|
||||
# another user. The actual template varies, depending on what has been
|
||||
# changed.
|
||||
if reassigned:
|
||||
template_staff = 'assigned_owner'
|
||||
elif f.new_status == Ticket.RESOLVED_STATUS:
|
||||
@ -266,7 +268,7 @@ def update_ticket(request, ticket_id):
|
||||
else:
|
||||
template_staff = 'updated_owner'
|
||||
|
||||
if (not reassigned or ( reassigned and getattr(ticket.assigned_to.usersettings.settings, 'email_on_ticket_assign', False))) or (not reassigned and getattr(ticket.assigned_to.usersettings.settings, 'email_on_ticket_change', False)):
|
||||
if (not reassigned or ( reassigned and ticket.assigned_to.usersettings.settings.get('email_on_ticket_assign', False))) or (not reassigned and ticket.assigned_to.usersettings.settings.get('email_on_ticket_change', False)):
|
||||
send_templated_mail(
|
||||
template_staff,
|
||||
context,
|
||||
@ -301,7 +303,6 @@ def update_ticket(request, ticket_id):
|
||||
return HttpResponseRedirect(ticket.get_absolute_url())
|
||||
else:
|
||||
return HttpResponseRedirect(ticket.ticket_url)
|
||||
update_ticket = staff_member_required(update_ticket)
|
||||
|
||||
|
||||
def mass_update(request):
|
||||
@ -495,7 +496,7 @@ def ticket_list(request):
|
||||
query_params['sortreverse'] = sortreverse
|
||||
|
||||
ticket_qs = apply_query(Ticket.objects.select_related(), query_params)
|
||||
paginator = Paginator(ticket_qs, 20)
|
||||
paginator = Paginator(ticket_qs, request.user.usersettings.settings.get('tickets_per_page', 20))
|
||||
try:
|
||||
page = int(request.GET.get('page', '1'))
|
||||
except ValueError:
|
||||
|
Loading…
Reference in New Issue
Block a user