class IOpenLinkInNewWindow(form.Schema): """Add open in new window field to link content """ form.order_after(open_link_in_new_window='remoteUrl') open_link_in_new_window = schema.Bool( title=_(u"open_link_in_new_window"), description=_(u"help_open_link_in_new_window"), required=False, default=False )
def render(self): context = aq_inner(self.context) is_important = IImportant(context).is_important if is_important: IImportant(context).is_important = False confirm = _(u"L'element s'ha desmarcat com important") else: IImportant(context).is_important = True confirm = _(u"L'element s'ha marcat com important") IStatusMessage(self.request).addStatusMessage(confirm, type='info') self.request.response.redirect(self.context.absolute_url())
def render(self): context = aq_inner(self.context) is_inapp = IShowInApp(context).is_inapp if is_inapp: IShowInApp(context).is_inapp = False confirm = _(u'L\'element no es mostra a la App') else: IShowInApp(context).is_inapp = True confirm = _(u'L\'element es mostra a la App') IStatusMessage(self.request).addStatusMessage(confirm, type='info') self.request.response.redirect(self.context.absolute_url())
def render(self): context = aq_inner(self.context) is_outoflist = IOutOfList(context).is_outoflist if is_outoflist: IOutOfList(context).is_outoflist = False confirm = _(u'L\'element s\'ha desmarcat de la blacklist') else: IOutOfList(context).is_outoflist = True confirm = _(u'L\'element s\'ha marcat com a blacklist') IStatusMessage(self.request).addStatusMessage(confirm, type='info') self.request.response.redirect(self.context.absolute_url())
def render(self): context = aq_inner(self.context) is_flash = IFlash(context).is_flash if is_flash: IFlash(context).is_flash = False confirm = _(u'L\'element s\'ha desmarcat com flash') else: IFlash(context).is_flash = True confirm = _(u'L\'element s\'ha marcat com flash') IStatusMessage(self.request).addStatusMessage(confirm, type='info') self.request.response.redirect(self.context.absolute_url())
def render(self): context = aq_inner(self.context) is_important = IImportant(context).is_important if is_important: IImportant(context).is_important = False confirm = _(u'L\'element s\'ha desmarcat com important') else: IImportant(context).is_important = True confirm = _(u'L\'element s\'ha marcat com important') IStatusMessage(self.request).addStatusMessage(confirm, type='info') self.request.response.redirect(self.context.absolute_url())
def lang_published(self): # show if the selected lang is published or not in language selector lang = dict(getToolByName(self, 'portal_languages').listAvailableLanguages()) published_lang = genweb_config().idiomes_publicats params_lang = self.context.REQUEST.form.get('set_language') cookie_lang = getToolByName(self, 'portal_languages').getPreferredLanguage() if params_lang: if params_lang not in lang: return _(u"not a valid language", default=u"${results} not a valid language", mapping={ u"results" : params_lang}) if params_lang not in published_lang: return _(u"Not published") else: if cookie_lang not in published_lang: return _(u"Not published")
def lang_published(self): # show if the selected lang is published or not in language selector lang = dict(getToolByName(self, 'portal_languages').listAvailableLanguages()) published_lang = genweb_config().idiomes_publicats params_lang = self.context.REQUEST.form.get('set_language') cookie_lang = getToolByName(self, 'portal_languages').getPreferredLanguage() if params_lang: if params_lang not in lang: return _(u'not a valid language', default=u'${results} not a valid language', mapping={u'results': params_lang}) if params_lang not in published_lang: return _(u'Not published') else: if cookie_lang not in published_lang: return _(u'Not published')
class ServeisTICControlPanelSettingsForm(controlpanel.RegistryEditForm): schema = IServeisTICControlPanelSettings id = 'ServeisTICControlPanelSettingsForm' label = _(u'Genweb ServeisTIC settings') description = _(u'help_serveistic_settings_editform', default=u'ServeisTIC configuration.') def updateFields(self): super(ServeisTICControlPanelSettingsForm, self).updateFields() def updateWidgets(self): super(ServeisTICControlPanelSettingsForm, self).updateWidgets() def fix_password_fields(self, data): """ Keep the stored value for the password fields not updated in the current request, i.e. those containing a None value. This method is needed since the password fields are not filled with their stored value when the edit form is loaded. """ if not data['ws_problemes_login_password']: data['ws_problemes_login_password'] = \ self.getContent().ws_problemes_login_password if not data['ws_indicadors_key']: data['ws_indicadors_key'] = \ self.getContent().ws_indicadors_key @button.buttonAndHandler(_('Save'), name=None) def handleSave(self, action): data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return self.fix_password_fields(data) self.applyChanges(data) IStatusMessage(self.request).addStatusMessage(_(u'Changes saved'), 'info') self.context.REQUEST.RESPONSE.redirect('@@serveistic-controlpanel') @button.buttonAndHandler(_('Cancel'), name='cancel') def handleCancel(self, action): IStatusMessage(self.request).addStatusMessage(_(u'Edit cancelled'), 'info') self.request.response.redirect( '%s/%s' % (self.context.absolute_url(), self.control_panel_view))
class IFlash(Interface): """ An object which can be marked as flash """ is_flash = schema.Bool( title=_(u"Tells if an object is marked as flash"), default=False )
def handleSave(self, action): data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return self.fix_password_fields(data) self.applyChanges(data) IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"), "info") self.context.REQUEST.RESPONSE.redirect("@@serveistic-controlpanel")
def handleSave(self, action): data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return self.fix_password_fields(data) self.applyChanges(data) IStatusMessage(self.request).addStatusMessage(_(u'Changes saved'), 'info') self.context.REQUEST.RESPONSE.redirect('@@serveistic-controlpanel')
def handleSave(self, action): data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return self.applyChanges(data) es = getUtility(IElasticSearch) es.create_new_connection() IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"), "info") self.context.REQUEST.RESPONSE.redirect("@@genweb-core-controlpanel")
def handleCancel(self, action): IStatusMessage(self.request).addStatusMessage(_(u'Edit cancelled'), 'info') self.request.response.redirect( '%s/%s' % (self.context.absolute_url(), self.control_panel_view))
def handleCancel(self, action): IStatusMessage(self.request).addStatusMessage(_(u"Modifications not saved"), "info") self.request.response.redirect("%s/%s" % (self.context.absolute_url(), self.control_panel_view))
class gwDisplaySubMenuItem(DisplaySubMenuItem): title = _(u'label_choose_template', default=u'Display')
class gwFactoriesSubMenuItem(FactoriesSubMenuItem): title = _(u'label_add_new_item', default=u'Add new\u2026')
from plone.app.portlets.portlets import base from plone.memoize.instance import memoize from plone.portlets.interfaces import IPortletDataProvider from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from genweb.core import GenwebMessageFactory as _ from Products.CMFCore.utils import getToolByName from genweb.core.interfaces import INewsFolder from genweb.core.utils import pref_lang from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm viewVocabulary = SimpleVocabulary([ SimpleTerm(value="id_normal", title=_(u'Normal view')), SimpleTerm(value="id_full", title=_(u'Full view')), SimpleTerm(value="id_full_2cols", title=_(u'Full2cols view'))]) countVocabulary = SimpleVocabulary.fromValues(range(1, 15)) class IFullNewsPortlet(IPortletDataProvider): """A portlet which can render a list of news. """ view_type = schema.Choice( title=_(u'Tipus de vista'), description=_(u'Escull com es mostraran les noticies'), required=True, vocabulary=viewVocabulary, default='id_normal'
def title(self): return _(u"Full News")
class IShowInApp(Interface): """ An object which can be marked as inapp """ is_inapp = schema.Bool(title=_(u"Tells if an object is shown in App"), default=False)
class IOutOfList(Interface): """ An object which can be marked as outoflist """ is_outoflist = schema.Bool( title=_(u"Tells if an object is marked as outoflist"), default=False)
class ITableFacetes(form.Schema): faceta = schema.Choice(title=_(u'Faceta'), vocabulary='genweb.serveistic.vocabularies.facets', required=False) valor = schema.TextLine(title=_(u'Valor'), required=False)
class IImportant(Interface): """ An object which can be marked as important """ is_important = schema.Bool( title=_(u"Tells if an object is marked as important"), default=False)
class IServeisTICControlPanelSettings(model.Schema): """ Global Genweb settings. This describes records stored in the configuration registry and obtainable via plone.registry. """ model.fieldset('General', _(u'General'), fields=['url_info_serveistic', 'show_filters']) url_info_serveistic = schema.TextLine( title=_(u"URL d'informació de Serveis TIC"), description=_(u"URL on enllaça la i de la barra superior del lloc " u"web de Serveis TIC"), required=False) show_filters = schema.Bool( title=_(u"Desplegar filtres de cerca"), description=_(u"Desplega el filtres de cerca que trobem a la pàgina " u"principal"), required=False) model.fieldset('Servei Web Problemes', _(u'Servei Web Problemes'), fields=[ 'ws_problemes_endpoint', 'ws_problemes_login_username', 'ws_problemes_login_password' ]) ws_problemes_endpoint = schema.TextLine(title=_(u'URL'), required=False) ws_problemes_login_username = schema.TextLine(title=_(u'Usuari'), required=False) ws_problemes_login_password = schema.Password(title=_(u'Contrasenya'), required=False) model.fieldset('Servei Web Indicadors', _(u'Servei Web Indicadors'), fields=[ 'ws_indicadors_service_id', 'ws_indicadors_endpoint', 'ws_indicadors_key' ]) ws_indicadors_service_id = schema.TextLine( title=_(u"Identificador al servei web d'Indicadors"), description=_(u"Identificador de Serveis TIC al servei web"), required=False) ws_indicadors_endpoint = schema.TextLine(title=_(u'URL'), required=False) ws_indicadors_key = schema.Password(title=_(u'API key'), required=False) model.fieldset('Actualitzacio Indicadors', _(u"Actualització d'Indicadors"), fields=['update_indicadors_passphrase']) update_indicadors_passphrase = schema.TextLine( title=_(u"Contrasenya"), description=_(u"Contrasenya necessària per a fer servir la vista " u"d'actualització (valor del paràmetre 'passphrase')"), required=False) model.fieldset('Google Analytics', _(u"Google Analytics"), fields=['ga_key_json', 'ga_view_id']) ga_key_json = schema.Text( title=_(u"Clau de la API"), description=_(u"Contingut JSON de la clau de la API"), required=False) ga_view_id = schema.TextLine( title=_(u"Id de visualització"), description=_( u"Identificador de la visualització de serveistic.upc.edu"), required=False) model.fieldset('Facetes', _(u'Facetes'), fields=['facetes_table']) form.widget(facetes_table=DataGridFieldFactory) facetes_table = schema.List( title=_(u'Facetes'), description=_(u'help_facetes_table', default=u'Afegir els valors per facetes de cerca'), value_type=DictRow(title=_(u'help_facetes_table'), schema=ITableFacetes), required=False)