index 2d8ea77b64ca40273cc99cfa8316644057c3d6b1..3cb9780c909f94bb833018cce663673f09ec2971 100644 (file)
from roundup import i18n
from roundup.i18n import _
+from KeywordsExpr import render_keywords_expression_editor
+
try:
import cPickle as pickle
except ImportError:
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)
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
"request" takes precedence over the other three arguments.
"""
+ security = self._db.security
+ userid = self._client.userid
if request is not None:
+ # for a request we asume it has already been
+ # security-filtered
filterspec = request.filterspec
sort = request.sort
group = request.group
+ else:
+ cn = self.classname
+ filterspec = security.filterFilterspec(userid, cn, filterspec)
+ sort = security.filterSortspec(userid, cn, sort)
+ group = security.filterSortspec(userid, cn, group)
- check = self._db.security.hasPermission
- userid = self._client.userid
+ check = security.hasPermission
if not check('Web Access', userid):
return []
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]))
HTMLInputMixin.__init__(self)
def __repr__(self):
- return '<HTMLProperty(0x%x) %s %r %r>'%(id(self), self._formname,
- self._prop, self._value)
+ classname = self.__class__.__name__
+ return '<%s(0x%x) %s %r %r>'%(classname, id(self), self._formname,
+ self._prop, self._value)
def __str__(self):
return self.plain()
def __cmp__(self, other):
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.
**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
(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 <select>
+ "translate" indicates if we should do translation of labels
+ using gettext -- this is often desired (e.g. for status
+ labels) but sometimes not.
The remaining keyword arguments are used as conditions for
filtering the items in the list - they're passed as the
lab = lab + ' (%s)'%', '.join(m)
# and generate
- lab = cgi.escape(self._(lab))
+ tr = str
+ if translate:
+ tr = self._
+ lab = cgi.escape(tr(lab))
l.append('<option %svalue="%s">%s</option>'%(s, optionid, lab))
l.append('</select>')
return '\n'.join(l)
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 <select> list for this property.
"size" is used to limit the length of the list labels
lab = lab + ' (%s)'%', '.join(m)
# and generate
- lab = cgi.escape(self._(lab))
+ tr = str
+ if translate:
+ tr = self._
+ lab = cgi.escape(tr(lab))
l.append('<option %svalue="%s">%s</option>'%(s, optionid,
lab))
l.append('</select>')
self.columns = handleListCGIValue(self.form[name])
break
self.show = support.TruthDict(self.columns)
+ security = self._client.db.security
+ userid = self._client.userid
# sorting and grouping
self.sort = []
self.group = []
self._parse_sort(self.sort, 'sort')
self._parse_sort(self.group, 'group')
+ self.sort = security.filterSortspec(userid, self.classname, self.sort)
+ self.group = security.filterSortspec(userid, self.classname, self.group)
# filtering
self.filter = []
self.filterspec[name] = handleListCGIValue(fv)
else:
self.filterspec[name] = fv.value
+ self.filterspec = security.filterFilterspec(userid, self.classname,
+ self.filterspec)
# full-text search argument
self.search_text = None
</script>
"""%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
# 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,
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.