def _setUpEditWidgets(self): setUpWidgets(self, self.context.schema, IDisplayWidget, prefix=self.name, names=self.names, context=self.context)
def results(self, name): if not (name + '.search' in self.request): return None schema = self.context.schema setUpWidgets(self, schema, IInputWidget, prefix=name + '.field') data = getWidgetsData(self, schema) return self.context.search(data)
def update(self): if self.update_status is not None: # We've been called before. Just return the status we previously # computed. return self.update_status status = '' if Update in self.request: try: changed = applyWidgetsChanges(self, self.schema, target=self.data, names=self.fieldNames) except WidgetsError as errors: # pragma: no cover self.errors = errors status = _("An error occurred.") transaction.doom() else: if changed: status = self.setData(self.data) setUpWidgets(self, self.schema, IInputWidget, initial=self.data, ignoreStickyValues=True, names=self.fieldNames) self.update_status = status return status
def results(self, name): if not (name+'.search' in self.request): return None schema = self.context.schema setUpWidgets(self, schema, IInputWidget, prefix=name+'.field') data = getWidgetsData(self, schema) return self.context.search(data)
def _setUpWidgets(self): self.data = Data(self.getData()) setUpWidgets(self, self.schema, IInputWidget, initial=self.data, names=self.fieldNames)
def update(self): if self.update_status is not None: # We've been called before. Just return the status we previously # computed. return self.update_status status = '' if Update in self.request: try: changed = applyWidgetsChanges( self, self.schema, target=self.data, names=self.fieldNames) except WidgetsError, errors: self.errors = errors status = _("An error occurred.") transaction.doom() else: if changed: status = self.setData(self.data) setUpWidgets( self, self.schema, IInputWidget, initial=self.data, ignoreStickyValues=True, names=self.fieldNames)
def update(self): if 'REMOVE' in self.request: keys = utility.getWidgetsData(self, ICategoriesForm, names=['categories'])['categories'] if not keys: return for key in keys: del self.categories[key] self.message = _('Categories successfully deleted.') elif 'ADD' in self.request: value = utility.getWidgetsData(self, ICategoriesForm, names=['newCategory' ])['newCategory'] if not value: return name = unicode(value).encode('punycode') self.categories[name] = value self.message = _('Category successfully added.') elif 'CHANGE' in self.request: key = utility.getWidgetsData(self, ICategoriesForm, names=['defaultCategory' ])['defaultCategory'] self.categories.default_key = key self.message = _('Default category successfully changed.') utility.setUpWidgets(self, self.schema, IInputWidget, initial=self.getData(), ignoreStickyValues=True, names=self.fieldNames)
def _setUpWidgets(self): setUpWidgets(self, self.schema, IInputWidget, names=self.fieldNames)
def __init__(self, context, request): BrowserView.__init__(self, context, request) setUpWidgets(self, ISimpleContact, IInputWidget)
def _setUpWidgets(self): self.data = Data(self.getData()) setUpWidgets( self, self.schema, IInputWidget, initial=self.data, names=self.fieldNames)
def _setUpEditWidgets(self): setUpWidgets( self, self.context.schema, IDisplayWidget, prefix=self.name, names=self.names, context=self.context )
def render(self, name): schema = self.context.schema sourcename = getName(self.context) sourcepath = getPath(self.context) setUpWidgets(self, schema, IInputWidget, prefix=name + '.field') html = [] # add sub title for source search field html.append('<h4>%s</h4>' % sourcename) # start row for path display field html.append('<div class="row">') # for each source add path of source html.append(' <div class="label">') label = translate(source_label, context=self.request) title = translate(source_title, context=self.request) html.append(' <label for="%s" title="%s">' % (sourcename, title)) html.append(' %s' % label) html.append(' </label>') html.append(' </div>') html.append(' <div class="field">') html.append(' %s' % sourcepath) html.append(' </div>') html.append('</div>') # start row for search fields html.append('<div class="row">') for field_name, field in getFieldsInOrder(schema): widget = getattr(self, field_name + '_widget') # for each field add label... html.append(' <div class="label">') html.append(' <label for="%s" title="%s">' % (widget.name, widget.hint)) html.append(' %s' % widget.label) html.append(' </label>') html.append(' </div>') # ...and field widget html.append(' <div class="field">') html.append(' %s' % widget()) if widget.error(): html.append(' <div class="error">') html.append(' %s' % widget.error()) html.append(' </div>') html.append(' </div>') # end row html.append('</div>') # add search button for search fields html.append('<div class="row">') html.append(' <div class="field">') html.append( ' <input type="submit" name="%s" value="%s" />' % (name + '.search', translate(search_label, context=self.request))) html.append(' </div>') html.append('</div>') return '\n'.join(html)
def __init__(self, context, request): BrowserView.__init__(self, context, request) setUpWidgets(self, self.schema, IInputWidget)
def _setUpEditWidgets(self): # subwidgets need a new name setUpWidgets(self, self.context.schema, IInputWidget, prefix=self.name, names=self.names, context=self.context)
def render(self, name): schema = self.context.schema sourcename = getName(self.context) sourcepath = getPath(self.context) setUpWidgets(self, schema, IInputWidget, prefix=name+'.field') html = [] # add sub title for source search field html.append('<h4>%s</h4>' % sourcename) # start row for path display field html.append('<div class="row">') # for each source add path of source html.append(' <div class="label">') label = translate(source_label, context=self.request) title = translate(source_title, context=self.request) html.append(' <label for="%s" title="%s">' % (sourcename, title)) html.append(' %s' % label) html.append(' </label>') html.append(' </div>') html.append(' <div class="field">') html.append(' %s' % sourcepath) html.append(' </div>') html.append('</div>') # start row for search fields html.append('<div class="row">') for field_name, field in getFieldsInOrder(schema): widget = getattr(self, field_name+'_widget') # for each field add label... html.append(' <div class="label">') html.append(' <label for="%s" title="%s">' % (widget.name, widget.hint)) html.append(' %s' % widget.label) html.append(' </label>') html.append(' </div>') # ...and field widget html.append(' <div class="field">') html.append(' %s' % widget()) if widget.error(): html.append(' <div class="error">') html.append(' %s' % widget.error()) html.append(' </div>') html.append(' </div>') # end row html.append('</div>') # add search button for search fields html.append('<div class="row">') html.append(' <div class="field">') html.append(' <input type="submit" name="%s" value="%s" />' % (name+'.search', translate(search_label, context=self.request))) html.append(' </div>') html.append('</div>') return '\n'.join(html)