Mercurial > p > roundup > code
diff roundup/cgi/templating.py @ 5094:92d33d3125a0
Validate properties specified for sorting and grouping in index
views. Original patch from martin.v.loewis via:
https://hg.python.org/tracker/roundup/rev/439bd3060df2
Applied by John Rouillard with some modification to properly
identify if the bad property is a sort or grouping property. Tests
added. Ideally we would never get bad sort/group properties but...
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 21 Jun 2016 21:45:24 -0400 |
| parents | 39af8a0f3446 |
| children | d3ba0b254dbb |
line wrap: on
line diff
--- a/roundup/cgi/templating.py Mon Jun 20 22:04:32 2016 -0400 +++ b/roundup/cgi/templating.py Tue Jun 21 21:45:24 2016 -0400 @@ -2517,13 +2517,18 @@ dirs.append(self.form.getfirst(dirkey)) if fields: # only try other special char if nothing found break + cls = self.client.db.getclass(self.classname) for f, d in map(None, fields, dirs): if f.startswith('-'): - var.append(('-', f[1:])) + dir, propname = '-', f[1:] elif d: - var.append(('-', f)) + dir, propname = '-', f else: - var.append(('+', f)) + dir, propname = '+', f + if cls.get_transitive_prop(propname) is None: + self.client.add_error_message("Unknown %s property %s"%(name, propname)) + else: + var.append((dir, propname)) def _form_has_key(self, name): try:
