diff roundup/cgi/templating.py @ 5082:c1f1465d5303

issue2550683 Allow indexargs_form filter variable exclusion. Patch generated by Bruce Tulloch (bruce). Applied and docstring for indexargs_form updated by John Rouillard. Full patch description is in CHANGES.txt file. I added the use case description. Code should be backwards compatible. There are not existing tests of indexargs_form that I can adopt to test, but it didn't cause tests/test_cgi tests/test_template to fail and the demo tracker ran properly.
author John Rouillard <rouilj@ieee.org>
date Sat, 11 Jun 2016 19:17:49 -0400
parents e424987d294a
children 39af8a0f3446
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Sat Jun 11 18:06:18 2016 -0400
+++ b/roundup/cgi/templating.py	Sat Jun 11 19:17:49 2016 -0400
@@ -2681,8 +2681,15 @@
 """%d
 
     def indexargs_form(self, columns=1, sort=1, group=1, filter=1,
-            filterspec=1, search_text=1):
-        """ return the current index args as form elements """
+            filterspec=1, search_text=1, exclude=[]):
+        """ return the current index args as form elements
+
+            This routine generates an html form with hidden elements.
+            If you want to have visible form elements in your tal/jinja
+            generated templates use the exclude aray to list the names for
+            these elements. This wll prevent the function from creating
+            these elements in its output.
+        """
         l = []
         sc = self.special_char
         def add(k, v):
@@ -2710,6 +2717,8 @@
         if self.classname and filterspec:
             cls = self.client.db.getclass(self.classname)
             for k,v in self.filterspec.items():
+                if k in exclude:
+                    continue
                 if type(v) == type([]):
                     if isinstance(cls.get_transitive_prop(k), hyperdb.String):
                         add(k, ' '.join(v))

Roundup Issue Tracker: http://roundup-tracker.org/