Commits

Hajime Yamasaki  committed 8467fe6

Renamed insert_param to overload_param

  • Participants
  • Parent commits 9a1c72b

Comments (0)

Files changed (4)

File tests/test_insert_params.py

-from __future__ import absolute_import, unicode_literals
-
-from unittest import TestCase
-
-from url_tools.templatetags.urls import insert_params 
-from url_tools.helper import UrlHelper
-
-
-class InsertParamsTestCase(TestCase):
-    def test_insert_params_basic(self):
-        self.assertEqual(
-            insert_params('/search/?q=something&selected_facets=second%3Abar',
-                           selected_facets='first:foo'),
-            '/search/?q=something&selected_facets=second%3Abar&selected_facets=first%3Afoo'
-        )    
-    def test_insert_params_duplicate(self):
-        self.assertEqual(
-            insert_params('/search/?q=something&selected_facets=second%3Abar&selected_facets=first%3Afoo',
-                           selected_facets='first:foo'),
-            '/search/?q=something&selected_facets=second%3Abar&selected_facets=first%3Afoo'
-        )

File tests/test_overload_params.py

+from __future__ import absolute_import, unicode_literals
+
+from unittest import TestCase
+
+from url_tools.templatetags.urls import overload_params
+
+
+class overloadParamsTestCase(TestCase):
+    def test_overload_params_basic(self):
+        self.assertEqual(
+            overload_params('/search/?q=something&selected_facets=second%3Abar',
+                           selected_facets='first:foo'),
+            '/search/?q=something&selected_facets=second%3Abar&selected_facets=first%3Afoo'
+        )
+
+    def test_overload_params_duplicate(self):
+        self.assertEqual(
+            overload_params('/search/?q=something&selected_facets=second%3Abar&selected_facets=first%3Afoo',
+                           selected_facets='first:foo'),
+            '/search/?q=something&selected_facets=second%3Abar&selected_facets=first%3Afoo'
+        )

File url_tools/helper.py

     def get_full_quoted_path(self, **kwargs):
         return urllib.quote_plus(self.get_full_path(**kwargs), safe='/')
 
-    def insert_params(self, **kwargs):
+    def overload_params(self, **kwargs):
         for key, val in kwargs.iteritems():
             uniques = set(self.query_dict.getlist(key))
             uniques.add(val)

File url_tools/templatetags/urls.py

 
 @register.simple_tag
 def add_params(url, **kwargs):
-    if type(url) == UrlHelper:
-        url = url.get_full_path()
     url = UrlHelper(url)
     try:
         url.update_query_data(**kwargs)
 
 @register.simple_tag
 def del_params(url, *args):
-    if type(url) == UrlHelper:
-        url = url.get_full_path()
     url = UrlHelper(url)
     try:
         url.del_params(*args)
         return url.get_full_path()
     except:
         return ''
-    
+
+
 @register.filter
 def suppr_param(url, arg):
     return del_params(url, arg)
-    
-    
+
     
 @register.simple_tag
-def insert_params(url, **kwargs):
-    if type(url) == UrlHelper:
-        url = url.get_full_path()
+def overload_params(url, **kwargs):
     url = UrlHelper(url)
     try:
-        url.insert_params(**kwargs)
+        url.overload_params(**kwargs)
         return url.get_full_path()
     except:
         return ''
 
 @register.simple_tag
 def remove_params(url, **kwargs):
-    if type(url) == UrlHelper:
-        url = url.get_full_path()
     url = UrlHelper(url)
     try:
         url.remove_params(**kwargs)
     except:
         return ''
 
+
 @register.assignment_tag
 def url_params(url, **kwargs):
     u = UrlHelper(url)