def test_sort_invert_created(self): """ Test that created's link inverts order if already sorting by created. """ link = create_sort_link('Waiting Time', 'created', [('text_query', 'guybrush')], 'created', 'asc') assert 'sort=created' in link assert 'order=desc' in link assert 'text_query=guybrush' in link link = create_sort_link('Waiting Time', 'created', [], 'created', 'desc') assert 'order=asc' in link
def test_sort_asc_created(self): """ Test that name's link sorts by asc if already sorting by created. """ link = create_sort_link('Name', 'name', [('text_query', 'irrel')], 'created', 'desc') assert 'sort=name' in link assert 'order=asc' in link assert 'text_query=irrel' in link
def sort_link(context, pretty_name, sort_field): """Get table header sort links. pretty_name -- name displayed on table header sort_field -- name of get parameter, referenced to in views """ request = context["request"] sort, order = clean_sort_param(request) # Copy search/filter GET parameters. get_params = [ (k, v) for k, v in urlparse.parse_qsl(smart_str(request.META["QUERY_STRING"])) if k not in ("sort", "order") ] return create_sort_link(pretty_name, sort_field, get_params, sort, order)
def sort_link(context, pretty_name, sort_field): """Get table header sort links. pretty_name -- name displayed on table header sort_field -- name of get parameter, referenced to in views """ request = context['request'] sort, order = clean_sort_param(request) # Copy search/filter GET parameters. get_params = [(k, smart_str(v)) for k, v in request.GET.items() if k not in ('sort', 'order')] return create_sort_link(pretty_name, sort_field, get_params, sort, order)
def sort_link(context, pretty_name, sort_field): """Get table header sort links. pretty_name -- name displayed on table header sort_field -- name of get parameter, referenced to in views """ request = context['request'] sort, order = clean_sort_param(request) # Copy search/filter GET parameters. get_params = [(k, v) for k, v in urlparse.parse_qsl(smart_str(request.META['QUERY_STRING'])) if k not in ('sort', 'order')] return create_sort_link(pretty_name, sort_field, get_params, sort, order)
def test_unicode(self): link = create_sort_link('Name', 'name', [('text_query', 'Feliz Año')], 'created', 'desc') assert 'sort=name' in link assert 'order=asc' in link assert 'text_query=Feliz+A%C3%B1o' in link
def test_no_xss(self): link = create_sort_link('Waiting Time', 'created', [('script', '<script>alert("BIB");</script>')], 'created', 'asc') assert '<script>' not in link