X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=roundup%2Fcgi%2Ftemplating.py;h=3cb9780c909f94bb833018cce663673f09ec2971;hb=e26c0e6a8f9dca8e604bae291509feec1e492354;hp=510aa6148acf8845636528303770108f4cfe08d7;hpb=983a58fd8c0e768cd27f7f381afe08dbefba82c2;p=roundup.git diff --git a/roundup/cgi/templating.py b/roundup/cgi/templating.py index 510aa61..3cb9780 100644 --- a/roundup/cgi/templating.py +++ b/roundup/cgi/templating.py @@ -27,6 +27,8 @@ from roundup import hyperdb, date, support from roundup import i18n from roundup.i18n import _ +from KeywordsExpr import render_keywords_expression_editor + try: import cPickle as pickle except ImportError: @@ -565,10 +567,7 @@ class HTMLClass(HTMLInputMixin, HTMLPermissions): for klass, htmlklass in propclasses: if not isinstance(prop, klass): continue - if isinstance(prop, hyperdb.Multilink): - value = [] - else: - value = None + value = prop.get_default_value() return htmlklass(self._client, self._classname, None, prop, item, value, self._anonymous) @@ -601,13 +600,10 @@ class HTMLClass(HTMLInputMixin, HTMLPermissions): l = [] for name, prop in self._props.items(): for klass, htmlklass in propclasses: - if isinstance(prop, hyperdb.Multilink): - value = [] - else: - value = None if isinstance(prop, klass): + value = prop.get_default_value() l.append(htmlklass(self._client, self._classname, '', - prop, name, value, self._anonymous)) + prop, name, value, self._anonymous)) if sort: l.sort(lambda a,b:cmp(a._name, b._name)) return l @@ -1112,6 +1108,13 @@ class _HTMLItem(HTMLInputMixin, HTMLPermissions): cell[-1] += ' -> %s'%current[k] current[k] = val + elif isinstance(prop, hyperdb.Password) and args[k] is not None: + val = args[k].dummystr() + cell.append('%s: %s'%(self._(k), val)) + if current.has_key(k): + cell[-1] += ' -> %s'%current[k] + current[k] = val + elif not args[k]: if current.has_key(k): cell.append('%s: %s'%(self._(k), current[k])) @@ -1565,7 +1568,10 @@ class PasswordHTMLProperty(HTMLProperty): if self._value is None: return '' - return self._('*encrypted*') + value = self._value.dummystr() + if escape: + value = cgi.escape(value) + return value def field(self, size=30, **kwargs): """ Render a form edit field for the property. @@ -1967,7 +1973,7 @@ class LinkHTMLProperty(HTMLProperty): **kwargs) def menu(self, size=None, height=None, showid=0, additional=[], value=None, - sort_on=None, html_kwargs = {}, **conditions): + sort_on=None, html_kwargs={}, translate=True, **conditions): """ Render a form select list for this property "size" is used to limit the length of the list labels @@ -1980,6 +1986,11 @@ class LinkHTMLProperty(HTMLProperty): (direction, property) where direction is '+' or '-'. A single string with the direction prepended may be used. For example: ('-', 'order'), '+name'. + "html_kwargs" specified additional html args for the + generated html ') return '\n'.join(l) @@ -2192,7 +2206,8 @@ class MultilinkHTMLProperty(HTMLProperty): return self.input(name=self._formname, size=size, **kwargs) def menu(self, size=None, height=None, showid=0, additional=[], - value=None, sort_on=None, html_kwargs = {}, **conditions): + value=None, sort_on=None, html_kwargs={}, translate=True, + **conditions): """ Render a form ') @@ -2712,7 +2730,7 @@ function help_window(helpurl, width, height) { """%self.base - def batch(self): + def batch(self, permission='View'): """ Return a batch object for results from the "current search" """ check = self._client.db.security.hasPermission @@ -2738,7 +2756,7 @@ function help_window(helpurl, width, height) { # filter for visibility l = [id for id in klass.filter(matches, filterspec, sort, group) - if check('View', userid, self.classname, itemid=id)] + if check(permission, userid, self.classname, itemid=id)] # return the batch object, using IDs only return Batch(self.client, l, self.pagesize, self.startwith, @@ -2863,6 +2881,9 @@ class TemplatingUtils: raise AttributeError, name return self.client.instance.templating_utils[name] + def keywords_expressions(self, request): + return render_keywords_expression_editor(request) + def html_calendar(self, request): """Generate a HTML calendar.