From a520e380f026a5e1e0ca6ca9311f56785596dd9f Mon Sep 17 00:00:00 2001 From: Stefano Brentegani Date: Fri, 11 May 2012 17:15:46 +0200 Subject: [PATCH] fix ticket list (sorting and status querystring) --- helpdesk/lib.py | 6 +++--- helpdesk/views/staff.py | 10 ++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/helpdesk/lib.py b/helpdesk/lib.py index b7972633..6587d8a1 100644 --- a/helpdesk/lib.py +++ b/helpdesk/lib.py @@ -153,7 +153,7 @@ def query_to_dict(results, descriptions): def apply_query(queryset, params): """ - Apply a dict-based set of filters & paramaters to a queryset. + Apply a dict-based set of filters & parameters to a queryset. queryset is a Django queryset, eg MyModel.objects.all() or MyModel.objects.filter(user=request.user) @@ -174,7 +174,7 @@ def apply_query(queryset, params): queryset = queryset.filter(params['other_filter']) sorting = params.get('sorting', None) - if not sorting: + if sorting: sortreverse = params.get('sortreverse', None) if sortreverse: sorting = "-%s" % sorting @@ -186,7 +186,7 @@ def apply_query(queryset, params): def safe_template_context(ticket): """ Return a dictionary that can be used as a template context to render - comments and other details with ticket or queue paramaters. Note that + comments and other details with ticket or queue parameters. Note that we don't just provide the Ticket & Queue objects to the template as they could reveal confidential information. Just imagine these two options: * {{ ticket.queue.email_box_password }} diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 697c01a3..f021b5ff 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -564,7 +564,7 @@ mass_update = staff_member_required(mass_update) def ticket_list(request): context = {} - # Query_params will hold a dictionary of paramaters relating to + # Query_params will hold a dictionary of parameters relating to # a query, to be saved if needed: query_params = { 'filtering': {}, @@ -734,10 +734,8 @@ def ticket_list(request): user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True)) - query_string = [] - for get_key, get_value in request.GET.iteritems(): - if get_key != "page": - query_string.append("%s=%s" % (get_key, get_value)) + querydict = request.GET.copy() + querydict.pop('page', 1) tag_choices = [] if HAS_TAG_SUPPORT: @@ -747,7 +745,7 @@ def ticket_list(request): return render_to_response('helpdesk/ticket_list.html', RequestContext(request, dict( context, - query_string="&".join(query_string), + query_string=querydict.urlencode(), tickets=tickets, user_choices=User.objects.filter(is_active=True), queue_choices=Queue.objects.all(),