diff --git a/table/columns/linkcolumn.py b/table/columns/linkcolumn.py index 81ab249..6cb2d1d 100644 --- a/table/columns/linkcolumn.py +++ b/table/columns/linkcolumn.py @@ -25,7 +25,7 @@ class Link(object): Represents a html tag. """ def __init__(self, text=None, viewname=None, args=None, kwargs=None, urlconf=None, - current_app=None, attrs=None): + current_app=None, attrs=None, query_strings={}): self.basetext = text self.viewname = viewname self.args = args or [] @@ -33,6 +33,7 @@ def __init__(self, text=None, viewname=None, args=None, kwargs=None, urlconf=Non self.urlconf = urlconf self.current_app = current_app self.base_attrs = attrs or {} + self.query_strings = query_strings @property def text(self): @@ -68,6 +69,16 @@ def url(self): if isinstance(self.current_app, Accessor) else self.current_app) + if self.query_strings: + for k, v in self.query_strings.items(): + if self.query_strings.itervalues().next() == v: + query_strings = "?%s=%s" % (k, v.resolve(self.obj) + if isinstance(v, Accessor) else v) + else: + query_strings += "&%s=%s" % (k, v.resolve(self.obj) + if isinstance(v, Accessor) else v) + return reverse(self.viewname, **params) + query_strings + return reverse(self.viewname, **params) @property