def description(self): if self.get_items(): return _(u'The following custom metadata schemas are available for ' u'your site.') else: return _(u'Click the "Add Schema" button to begin creating ' u' a new metadata schema.')
def description(self): if self.get_items(): return _( u'The following custom metadata schemas are available for ' u'your site.') else: return _(u'Click the "Add Schema" button to begin creating ' u' a new metadata schema.')
class PigeonholeSchemaAddForm(form.Form): label = _(u'Add Metadata Schema') fields = field.Fields(IPigeonholeSchemaSettings).select( 'title', 'name', 'types', 'condition') ignoreContext = True id = 'add-schema-form' @button.buttonAndHandler(u'Add Schema') def handleAdd(self, action): data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return name = data['name'] registry = getUtility(IRegistry) schemas = registry.collectionOfInterface(IPigeonholeSchemaSettings, prefix=REGISTRY_BASE_PREFIX) record = schemas.setdefault(name) for fname in ('name', 'title', 'types', 'condition'): setattr(record, fname, data[fname]) self.status = _(u"Schema added successfully.") self.request.response.redirect(self.context.absolute_url())
def __init__(self, context, request): super(PigeonholeControlPanel, self).__init__(context, request) # make sure that breadcrumbs will be correct self.id = None self.Title = lambda: _(u'Pigeonhole') # turn off green edit border for anything in the control panel request.set('disable_border', 1)
def handleAdd(self, action): data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return name = data['name'] registry = getUtility(IRegistry) schemas = registry.collectionOfInterface(IPigeonholeSchemaSettings, prefix=REGISTRY_BASE_PREFIX) record = schemas.setdefault(name) for fname in ('name', 'title', 'types', 'condition'): setattr(record, fname, data[fname]) self.status = _(u"Schema added successfully.") self.request.response.redirect(self.context.absolute_url())