forked from extern/django-helpdesk
Merge pull request #137 from brente/master
Fix for ticket list sorting and pagination
This commit is contained in:
commit
f33f683259
@ -153,7 +153,7 @@ def query_to_dict(results, descriptions):
|
|||||||
|
|
||||||
def apply_query(queryset, params):
|
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
|
queryset is a Django queryset, eg MyModel.objects.all() or
|
||||||
MyModel.objects.filter(user=request.user)
|
MyModel.objects.filter(user=request.user)
|
||||||
@ -174,7 +174,7 @@ def apply_query(queryset, params):
|
|||||||
queryset = queryset.filter(params['other_filter'])
|
queryset = queryset.filter(params['other_filter'])
|
||||||
|
|
||||||
sorting = params.get('sorting', None)
|
sorting = params.get('sorting', None)
|
||||||
if not sorting:
|
if sorting:
|
||||||
sortreverse = params.get('sortreverse', None)
|
sortreverse = params.get('sortreverse', None)
|
||||||
if sortreverse:
|
if sortreverse:
|
||||||
sorting = "-%s" % sorting
|
sorting = "-%s" % sorting
|
||||||
@ -186,7 +186,7 @@ def apply_query(queryset, params):
|
|||||||
def safe_template_context(ticket):
|
def safe_template_context(ticket):
|
||||||
"""
|
"""
|
||||||
Return a dictionary that can be used as a template context to render
|
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
|
we don't just provide the Ticket & Queue objects to the template as
|
||||||
they could reveal confidential information. Just imagine these two options:
|
they could reveal confidential information. Just imagine these two options:
|
||||||
* {{ ticket.queue.email_box_password }}
|
* {{ ticket.queue.email_box_password }}
|
||||||
|
@ -564,7 +564,7 @@ mass_update = staff_member_required(mass_update)
|
|||||||
def ticket_list(request):
|
def ticket_list(request):
|
||||||
context = {}
|
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:
|
# a query, to be saved if needed:
|
||||||
query_params = {
|
query_params = {
|
||||||
'filtering': {},
|
'filtering': {},
|
||||||
@ -734,10 +734,8 @@ def ticket_list(request):
|
|||||||
|
|
||||||
user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True))
|
user_saved_queries = SavedSearch.objects.filter(Q(user=request.user) | Q(shared__exact=True))
|
||||||
|
|
||||||
query_string = []
|
querydict = request.GET.copy()
|
||||||
for get_key, get_value in request.GET.iteritems():
|
querydict.pop('page', 1)
|
||||||
if get_key != "page":
|
|
||||||
query_string.append("%s=%s" % (get_key, get_value))
|
|
||||||
|
|
||||||
tag_choices = []
|
tag_choices = []
|
||||||
if HAS_TAG_SUPPORT:
|
if HAS_TAG_SUPPORT:
|
||||||
@ -747,7 +745,7 @@ def ticket_list(request):
|
|||||||
return render_to_response('helpdesk/ticket_list.html',
|
return render_to_response('helpdesk/ticket_list.html',
|
||||||
RequestContext(request, dict(
|
RequestContext(request, dict(
|
||||||
context,
|
context,
|
||||||
query_string="&".join(query_string),
|
query_string=querydict.urlencode(),
|
||||||
tickets=tickets,
|
tickets=tickets,
|
||||||
user_choices=User.objects.filter(is_active=True),
|
user_choices=User.objects.filter(is_active=True),
|
||||||
queue_choices=Queue.objects.all(),
|
queue_choices=Queue.objects.all(),
|
||||||
|
Loading…
Reference in New Issue
Block a user