def __call__(self): context = aq_inner(self.context) if self.request.form.get('%s.row.add' % context.UID(), None) is not None and \ self.can_add: position = self.request.form.get('%s.row.position' % context.UID(), None) typestool = getToolByName(context, 'portal_types') added, failed = 0, 0 for row in self.request.form.get('%s.rows' % context.UID(), []): try: title = row.get('title', 'row') id = self._create_id(title, context) typestool.constructContent(type_name='Row', container=context, id=id) object = context[id] object.update(**dict(row)) if position is not None: context.moveObjectToPosition(id, int(position)+added) object.reindexObject() added += 1 except: failed += 1 if position is not None and added > 0: getToolByName(context, 'plone_utils').reindexOnReorder(context) statusmessage = IStatusMessage(self.request) if added == 1: statusmessage.addStatusMessage(_(u'Successfully added new row'), 'info') if added > 1: statusmessage.addStatusMessage(_(u'Successfully added ${number} rows', mapping=dict(number=added)), 'info') if failed == 1: statusmessage.addStatusMessage(_(u'Adding one new row failed'), 'error') if failed > 1: statusmessage.addStatusMessage(_(u'Adding ${number} rows failed', mapping=dict(number=failed)), 'error') self.request.form['%s.row.add' % context.UID()] = None return self.template()
def getFields(self): fields = [ ExtensionBooleanField('hideLeftPortletslot', required = False, languageIndependent = True, schemata = 'settings', widget = BooleanWidget( description=_(u'description_hide_left_portletslot', default=u'If selected, the left portlet slot is hidden'), label = _(u'label_hide_left_portletslot', default=u'Hide left portlet slot'), visible={'view' : 'hidden', 'edit' : 'visible'}, ), ), ExtensionBooleanField('hideRightPortletslot', required = False, languageIndependent = True, schemata = 'settings', widget = BooleanWidget( description=_(u'description_hide_right_portletslot', default=u'If selected, the right portlet slot is hidden'), label = _(u'label_hide_right_portletslot', default=u'Hide right portlet slot'), visible={'view' : 'hidden', 'edit' : 'visible'}, ), ), ] return fields
def setProperties(self): context = aq_inner(self.context) new = self.request.form.get('new_definition', None) columns = self.request.form.get('new_definition_columns', []) error = 0 if new and new['name']: try: self._definitions.addDefinition(new['name'], new['style'], self._formatColumns(columns)) except: transaction.abort() error = _(u'Unable to parse the columns field of the definition to be added') modify = self.request.form.get('definitions', [])[:] for definition in modify: if definition.has_key('delete'): self._definitions.removeDefinition(definition['id']) if definition.has_key('delete'): continue try: columns = self.request.form.get('definition_columns_%s' % definition['origname'], []) self._definitions.addDefinition(definition['name'], definition['style'], self._formatColumns(columns), definition['id']) except: transaction.abort() error = _(u'Unable to parse the columns field of one of the definitions to be modified') statusmessage = IStatusMessage(self.request) if error: statusmessage.addStatusMessage(error, 'error') else: statusmessage.addStatusMessage(_p(u'Changes saved.'), 'info')
def __call__(self): if self.request.get('form.submitted', False) or self.request.get('form.view', False): statusmessage = IStatusMessage(self.request) if self._save(): statusmessage.addStatusMessage(_(u'Components saved successfully'), u'info') else: statusmessage.addStatusMessage(_(u'Saving components failed'), u'error') if self.request.get('form.view', False): return self.request.RESPONSE.redirect(self.context.absolute_url()) return self.template()
class Component(object): """ Component which lists the related items of an article """ interface.implements(interfaces.IComponent) component.adapts(interfaces.IArticle) title = _(u'Related content') description = _(u'List of related content of the article.') image = '++resource++related.gif' interface = IRelated viewlet = 'raptus.article.related' def __init__(self, context): self.context = context
def __call__(self): """Handles StatusMessages and redirect logic. :returns: component.pt template or redirects to Article's absolute URL :rtype: Five template or response redirect """ if self.request.get('form.submitted', False) or self.request.get('form.view', False): statusmessage = IStatusMessage(self.request) if self._save(): statusmessage.addStatusMessage(_(u'Components saved successfully'), u'info') else: statusmessage.addStatusMessage(_(u'Saving components failed'), u'error') if self.request.get('form.view', False): return self.request.RESPONSE.redirect(self.context.absolute_url()) return self.template()
def __call__(self, manager=None): self.manager = manager self.action = '%s/@@components' % self.context.absolute_url() if manager is not None: self.action += '?manager=%s' % manager if self.request.get('form.submitted', False) or self.request.get('form.view', False): statusmessage = IStatusMessage(self.request) if self._save(): statusmessage.addStatusMessage(_(u'Components saved successfully'), u'info') else: statusmessage.addStatusMessage(_(u'Saving components failed'), u'error') if self.request.get('ajax_load', 0): return '1' if self.request.get('form.view', False): return self.context.absolute_url() or self.request.RESPONSE.redirect(self.context.absolute_url()) return self.template()
def media(self): manageable = interfaces.IManageable(self.context) mship = getToolByName(self.context, 'portal_membership') catalog = getToolByName(self.context, 'portal_catalog') args = {} if not interfaces.IArticleEditView.providedBy(self.view) or not mship.checkPermission(MANAGE_PERMISSION, self.context): args['component'] = self.component types = [IATImage.__identifier__] if TEASER: types.append(interfaces.IArticle.__identifier__) if MEDIA: types.extend([IVideo.__identifier__, IVideoEmbed.__identifier__]) items = catalog(object_provides=types, path={'query': '/'.join(self.context.getPhysicalPath()), 'depth': 1}, sort_on='getObjPositionInParent', **args) items = manageable.getList(items, self.component) groups = [] main = None for item in items: if interfaces.IArticle.providedBy(item['obj']): item.update({'title': item['brain'].Title, 'description': item['brain'].Description, 'childs': []}) teaser = ITeaser(item['obj']) item['image'] = teaser.getTeaser(self.thumb_size + 'group') childs = catalog(object_provides=[IATImage.__identifier__, IVideo.__identifier__, IVideoEmbed.__identifier__], path={'query': '/'.join(item['obj'].getPhysicalPath()), 'depth': 1}, sort_on='getObjPositionInParent', **args) if not len(childs): continue childs = manageable.getList(childs, self.component) for child in childs: self._data(child) item['childs'].append(child) groups.append(item) else: self._data(item) if main is None: ptypes = getToolByName(self.context, 'portal_types') context = self.context while interfaces.IArticle.providedBy(context) and not context.Schema()['detail'].get(context): context = aq_parent(context) type = ptypes.getTypeInfo(context).Title() main = {'title': _(u'Media of this ${type}', mapping={'type': translate(type, context=self.request)}), 'description': None, 'childs': []} groups.append(main) main['childs'].append(item) return groups
def __call__(self, request): definition = request.form.get('definition', None) columns = request.form.get('columns', []) if not definition and not columns: return dict(columns=_(u"Please select a table definition or type your own in this field.")) # everything right :-) return None
def __call__(self, manager=None): self.manager = manager self.action = '%s/@@components' % self.context.absolute_url() if manager is not None: self.action += '?manager=%s' % manager if self.request.get('form.submitted', False) or self.request.get( 'form.view', False): statusmessage = IStatusMessage(self.request) if self._save(): statusmessage.addStatusMessage( _(u'Components saved successfully'), u'info') else: statusmessage.addStatusMessage(_(u'Saving components failed'), u'error') if self.request.get('ajax_load', 0): return '1' if self.request.get('form.view', False): return self.context.absolute_url( ) or self.request.RESPONSE.redirect(self.context.absolute_url()) return self.template()
except: pass VideoSchema = file.ATFileSchema.copy() + atapi.Schema(( FileField('file', required=True, primary=True, searchable=False, languageIndependent=False, storage = atapi.AnnotationStorage(migrate=True), validators = (('isNonEmptyFile', V_REQUIRED), ('checkFileMaxSize', V_REQUIRED), ContentTypeValidator(valid_types)), widget = atapi.FileWidget( description = '', label=_(u'label_video', default=u'Video file'), show_content_type = False,), ), ImageField('image', required=False, languageIndependent=False, storage = atapi.AnnotationStorage(migrate=True), swallowResizeExceptions = zconf.swallowImageResizeExceptions.enable, pil_quality = zconf.pil_config.quality, pil_resize_algo = zconf.pil_config.resize_algo, max_size = zconf.ATImage.max_image_dimension, sizes= {'large' : (768, 768), 'preview' : (400, 400), 'mini' : (200, 200), 'thumb' : (128, 128), 'tile' : (64, 64),
def _data(self, item, i, l): super(Viewlet, self)._data(item, i, l) if 'url' in item and item['url']: if not 'wysiwyg' in item: item['wysiwyg'] = '' item['wysiwyg'] += renderElement('p', contents=renderElement('a', href=item['url'], cssClass='button read-more', contents=translate(_(u'Read more'), context=self.request))) item['url'] = None
description='', label=_at(u'label_body_text', default=u'Body Text'), rows=25, allow_file_upload=zconf.ATDocument.allow_document_upload ), ), atapi.BooleanField('hideTitle', required=False, languageIndependent=True, default=False, storage=atapi.AnnotationStorage(), schemata='settings', accessor='HideTitle', widget=atapi.BooleanWidget( description='', label=_(u'label_hide_title', default=u'Hide title'), visible={'view': 'hidden', 'edit': 'visible'}, ), ), atapi.BooleanField('hideDescription', required=False, languageIndependent=True, default=False, storage=atapi.AnnotationStorage(), schemata='settings', accessor='HideDescription', widget=atapi.BooleanWidget( description='', label=_(u'label_hide_description', default=u'Hide description'),
from raptus.article.maps.interfaces import IMap from raptus.article.maps.config import PROJECTNAME from raptus.article.core import RaptusArticleMessageFactory as _ from raptus.article.core.componentselection import ComponentSelectionWidget MapSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema(( atapi.StringField('geocode', required=True, searchable=False, languageIndependent=True, storage = atapi.AnnotationStorage(), widget = atapi.StringWidget( description = '', label=_(u'label_street_zip_city', default=u'Street no., ZIP city') ), ), atapi.FloatField('latitude', required=True, searchable=False, languageIndependent=True, storage = atapi.AnnotationStorage(), widget = atapi.StringWidget( description = '', label=_(u'label_latitude', default=u'Latitude') ), ), atapi.FloatField('longitude', required=True, searchable=False,
description='', label=_at(u'label_body_text', default=u'Body Text'), rows=25, allow_file_upload=zconf.ATDocument.allow_document_upload), ), atapi.BooleanField( 'hideTitle', required=False, languageIndependent=True, default=False, storage=atapi.AnnotationStorage(), schemata='settings', accessor='HideTitle', widget=atapi.BooleanWidget( description='', label=_(u'label_hide_title', default=u'Hide title'), visible={ 'view': 'hidden', 'edit': 'visible' }, ), ), atapi.BooleanField( 'hideDescription', required=False, languageIndependent=True, default=False, storage=atapi.AnnotationStorage(), schemata='settings', accessor='HideDescription', widget=atapi.BooleanWidget(
from raptus.article.core.componentselection import ComponentSelectionWidget AliasSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema(( atapi.ReferenceField('reference', relationship = 'aliasTo', allowed_types_method = 'getAllowedTypes', multiValued = False, required = True, keepReferencesOnCopy = True, widget = ReferenceBrowserWidget( allow_search = True, allow_browse = True, show_indexes = False, force_close_on_insert = True, label = _(u'label_reference', default=u'Reference'), description = '', visible = {'edit' : 'visible', 'view' : 'invisible' } ) ), atapi.LinesField('components', enforceVocabulary = True, vocabulary_factory = 'componentselectionvocabulary', storage = atapi.AnnotationStorage(), schemata = 'settings', widget = ComponentSelectionWidget( description = _(u'description_component_selection_alias', default=u'Select the components in which the referenced object should be displayed.'), label= _(u'label_component_selection', default=u'Component selection'), ) ), ))
from Products.ATContentTypes.content import base from raptus.article.maps.interfaces import IMarker from raptus.article.maps.config import PROJECTNAME from raptus.article.core import RaptusArticleMessageFactory as _ from raptus.article.core.componentselection import ComponentSelectionWidget MarkerSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema(( atapi.StringField('geocode', required=True, searchable=False, languageIndependent=True, storage = atapi.AnnotationStorage(), widget = atapi.StringWidget( description = '', label=_(u'label_street_zip_city', default=u'Street no., ZIP city') ), ), atapi.FloatField('latitude', required=True, searchable=False, languageIndependent=True, storage = atapi.AnnotationStorage(), widget = atapi.StringWidget( description = '', label=_(u'label_latitude', default=u'Latitude') ), ), atapi.FloatField('longitude', required=True, searchable=False,
from raptus.article.media.config import PROJECTNAME from raptus.article.core import RaptusArticleMessageFactory as _ AudioSchema = file.ATFileSchema.copy() + atapi.Schema(( FileField('file', required=True, primary=True, searchable=False, languageIndependent=False, storage = atapi.AnnotationStorage(migrate=True), validators = (('isNonEmptyFile', V_REQUIRED), ('checkFileMaxSize', V_REQUIRED), ContentTypeValidator(('audio/mpeg', 'audio/x-mp3', 'audio/x-mpeg', 'audio/mp3',))), widget = atapi.FileWidget( description = '', label=_(u'label_audio', default=u'Audio file'), show_content_type = False,), ), )) AudioSchema['title'].storage = atapi.AnnotationStorage() AudioSchema['description'].storage = atapi.AnnotationStorage() for field in ('creators','allowDiscussion','contributors','location','language', 'nextPreviousEnabled', 'rights' ): if AudioSchema.has_key(field): AudioSchema[field].widget.visible = {'edit': 'invisible', 'view': 'invisible'} schemata.finalizeATCTSchema(AudioSchema, folderish=False, moveDiscussion=True) class Audio(file.ATFile): """An audio file"""
from raptus.article.table.field import TableColumnsField from raptus.article.table.widget import TableColumnsWidget from raptus.article.table.interfaces import ITable from raptus.article.table.config import PROJECTNAME, OVERRIDE_DEFINITION from raptus.article.core import RaptusArticleMessageFactory as _ from raptus.article.core.componentselection import ComponentSelectionWidget TableSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema(( atapi.StringField('definition', languageIndependent=True, schemata = 'settings', vocabulary_factory = 'raptus.article.table.definitions', storage = atapi.AnnotationStorage(), widget = atapi.SelectionWidget( description = _(u'description_definition', default=u'Select from predefined table definitions'), label=_(u'label_definition', default=u'Table definition') ), ), atapi.StringField('style', vocabulary_factory = 'raptus.article.table.styles', languageIndependent=True, schemata = 'settings', write_permission = OVERRIDE_DEFINITION, storage = atapi.AnnotationStorage(), widget = atapi.SelectionWidget( description = _(u'description_style_override', default=u'Define the style of the table. This will override the style defined by the table definition if one is selected.'), label=_(u'label_style', default=u'Table style') ), ), TableColumnsField('columns',