def handleSave(self, action): """ Save form data """ data, errors = self.extractData() if errors: return False else: self.applyChanges(data) _redirect(self, _('Saved uberlisting configuration changes'))
def textListingOrIcon(data): """ :param data: form data passed on submit :return: error if both listTemplatesAsText and onlyTemplatesWithIcons is enabled """ if data.listTemplatesAsText and data.onlyTemplatesWithIcons: raise Invalid(_(u"'List templates as text' and 'List only " u"templates with icons' are mutually " u"exclusive"))
def disable(self): """ Disable uberlisting view by noLongerProviding IUberlistingView interface """ try: translations = self.context.getTranslations() for trans in translations.values(): # set as the layout the first available template trans[0].setLayout(trans[0].getAvailableLayouts()[0][0]) noLongerProvides(trans[0], IUberlistingView) trans[0].reindexObject(idxs='object_provides') except AttributeError: self.context.setLayout(self.context.getAvailableLayouts()[0][0]) noLongerProvides(self.context, IUberlistingView) self.context.reindexObject(idxs='object_provides') _redirect(self, _('UberlistingView disabled'))
def enable(self): """ Enable uberlisting view by providing IUberlistingView interface """ # enable this listing also for the translation of the context if # LinguaPlone is enabled and this context is translated try: translations = self.context.getTranslations() for trans in translations.values(): trans[0].setLayout('uberlisting_view') alsoProvides(trans[0], IUberlistingView) trans[0].reindexObject(idxs='object_provides') except AttributeError: self.context.setLayout('uberlisting_view') alsoProvides(self.context, IUberlistingView) self.context.reindexObject(idxs='object_provides') _redirect(self, _('UberlistingView enabled'))
def handleCancel(self, action): """ Cancel form edit """ _redirect(self, _('Canceled uberlisting configuration changes'))