Fix resolved link class URL mangling when the keep_query argument is used.
Fixes source navigation on the document upload wizard. Thanks to Nick Douma (LordGaav) for the report and diagnostic information. GitLab issue #436. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
==================
|
||||
- Fix task manager queue list view. Thanks to LeVon Smoker for
|
||||
the report.
|
||||
- Fix resolved link class URL mangling when the keep_query argument is
|
||||
used. Thanks to Nick Douma (LordGaav) for the report and diagnostic
|
||||
information. Fixes source navigation on the document upload wizard.
|
||||
|
||||
2.7.2 (2017-09-06)
|
||||
==================
|
||||
|
||||
@@ -9,6 +9,10 @@ What's new
|
||||
|
||||
- Fix task manager queue list view. Thanks to LeVon Smoker for
|
||||
the report.
|
||||
- Fix resolved link class URL mangling when the keep_query argument is
|
||||
used. Fixes source navigation on the document upload wizard. Thanks to
|
||||
Nick Douma (LordGaav) for the report and diagnostic information. GitLab
|
||||
issue #436.
|
||||
|
||||
Removals
|
||||
--------
|
||||
@@ -64,5 +68,7 @@ Bugs fixed or issues closed
|
||||
===========================
|
||||
|
||||
* `GitLab issue #431 <https://gitlab.com/mayan-edms/mayan-edms/issues/431>`_ can't create new mailer
|
||||
* `GitLab issue #436 <https://gitlab.com/mayan-edms/mayan-edms/issues/436>`_ New document source menu does not contain source_ids
|
||||
|
||||
|
||||
.. _PyPI: https://pypi.python.org/pypi/mayan-edms/
|
||||
|
||||
@@ -363,7 +363,10 @@ class Link(object):
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
resolved_link.url = parsed_url.url
|
||||
# Use the link's URL but with the previous URL querystring
|
||||
new_url = furl(resolved_link.url)
|
||||
new_url.args = parsed_url.querystr
|
||||
resolved_link.url = new_url.url
|
||||
|
||||
resolved_link.context = context
|
||||
return resolved_link
|
||||
|
||||
@@ -7,5 +7,8 @@ TEST_PERMISSION_NAME = 'test permission name'
|
||||
TEST_PERMISSION_LABEL = 'test permission label'
|
||||
TEST_LINK_TEXT = 'test link text'
|
||||
TEST_MENU_NAME = 'menu test'
|
||||
TEST_QUERYSTRING_ONE_KEY = 'key1=value1'
|
||||
TEST_QUERYSTRING_TWO_KEYS = 'key1=value1&key2=value2'
|
||||
TEST_SUBMENU_NAME = 'submenu test'
|
||||
TEST_UNICODE_STRING = 'úñí©óðé'
|
||||
TEST_URL = 'test-URL'
|
||||
|
||||
@@ -15,7 +15,8 @@ from ..classes import Link, Menu
|
||||
from .literals import (
|
||||
TEST_PERMISSION_NAMESPACE_NAME, TEST_PERMISSION_NAMESPACE_TEXT,
|
||||
TEST_PERMISSION_NAME, TEST_PERMISSION_LABEL, TEST_LINK_TEXT,
|
||||
TEST_MENU_NAME, TEST_SUBMENU_NAME, TEST_UNICODE_STRING
|
||||
TEST_MENU_NAME, TEST_QUERYSTRING_ONE_KEY, TEST_QUERYSTRING_TWO_KEYS,
|
||||
TEST_SUBMENU_NAME, TEST_UNICODE_STRING, TEST_URL
|
||||
)
|
||||
|
||||
|
||||
@@ -115,6 +116,43 @@ class LinkClassTestCase(GenericViewTestCase):
|
||||
self.assertEqual(resolved_link.url, url.url)
|
||||
|
||||
|
||||
def test_link_with_querystring_preservation(self):
|
||||
previous_url = '{}?{}'.format(
|
||||
reverse(TEST_VIEW_NAME), TEST_QUERYSTRING_TWO_KEYS
|
||||
)
|
||||
self.link.keep_query = True
|
||||
self.link.url = TEST_URL
|
||||
self.link.view = None
|
||||
response = self.get(path=previous_url)
|
||||
|
||||
context = Context({'request': response.wsgi_request})
|
||||
|
||||
resolved_link = self.link.resolve(context=context)
|
||||
|
||||
self.assertEqual(
|
||||
resolved_link.url,
|
||||
'{}?{}'.format(TEST_URL, TEST_QUERYSTRING_TWO_KEYS)
|
||||
)
|
||||
|
||||
def test_link_with_querystring_preservation_with_key_removal(self):
|
||||
previous_url = '{}?{}'.format(
|
||||
reverse(TEST_VIEW_NAME), TEST_QUERYSTRING_TWO_KEYS
|
||||
)
|
||||
self.link.keep_query = True
|
||||
self.link.url = TEST_URL
|
||||
self.link.view = None
|
||||
self.link.remove_from_query = ['key2']
|
||||
response = self.get(path=previous_url)
|
||||
|
||||
context = Context({'request': response.wsgi_request})
|
||||
|
||||
resolved_link = self.link.resolve(context=context)
|
||||
self.assertEqual(
|
||||
resolved_link.url,
|
||||
'{}?{}'.format(TEST_URL, TEST_QUERYSTRING_ONE_KEY)
|
||||
)
|
||||
|
||||
|
||||
class MenuClassTestCase(GenericViewTestCase):
|
||||
def setUp(self):
|
||||
super(MenuClassTestCase, self).setUp()
|
||||
|
||||
Reference in New Issue
Block a user