Commit 06abd5a7 authored by fred's avatar fred
Browse files

misc: remove python2 encoding in facets query string manipulations

parent 6aa2574c
...@@ -241,13 +241,13 @@ def replace ( string, args ): ...@@ -241,13 +241,13 @@ def replace ( string, args ):
def remove_facet(facet_id, url, facet): def remove_facet(facet_id, url, facet):
scheme, netloc, path, query, fragment = list(urlparse.urlsplit(str(url))) scheme, netloc, path, query, fragment = list(urlparse.urlsplit(str(url)))
facet = '%s_exact:%s' % (facet_id, facet.encode('utf-8')) facet = '%s_exact:%s' % (facet_id, facet)
query_string = urlparse.parse_qsl(query) query_string = urlparse.parse_qsl(query)
query_string = [x for x in query_string if not ( query_string = [x for x in query_string if not (
x[0] == 'selected_facets' and x[1] == facet)] x[0] == 'selected_facets' and x[1] == facet)]
query = '&'.join(['%s=%s' % x for x in query_string]) query = '&'.join(['%s=%s' % x for x in query_string])
url = urlparse.urlunsplit([scheme, netloc, path, query, None]) url = urlparse.urlunsplit([scheme, netloc, path, query, None])
return force_text(re.sub(r'&page=\d+', '', url), 'utf-8') return re.sub(r'&page=\d+', '', url)
@register.filter @register.filter
def remove_tag_facet(url, facet): def remove_tag_facet(url, facet):
...@@ -268,7 +268,7 @@ def remove_format_facet(url, facet): ...@@ -268,7 +268,7 @@ def remove_format_facet(url, facet):
def append_facet(facet_id, url, facet): def append_facet(facet_id, url, facet):
facet = quote(facet.encode('utf-8'), safe='') facet = quote(facet, safe='')
if not '?' in url: if not '?' in url:
url = url + '?' url = url + '?'
return re.sub(r'&page=\d+', '', url + '&selected_facets=%s_exact:%s' % (facet_id, facet)) return re.sub(r'&page=\d+', '', url + '&selected_facets=%s_exact:%s' % (facet_id, facet))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment