def __call__(self, context): context = getattr(context, 'context', context) portal = getToolByName(context, 'portal_url').getPortalObject() items = [ SimpleTerm( 'auto', 'auto', context.translate(_( 'label_default_portaltype_configuration', default=u'Default configuration (Content Type Registry).')) ) ] flt = [ _infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, 'file') ] ilt = [ _infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, 'image') ] items.extend([ SimpleTerm( t['portal_type'], t['portal_type'], t['type_ui_info'] ) for t in flt ]) file_types = [t['portal_type'] for t in flt] items.extend([ SimpleTerm( t['portal_type'], t['portal_type'], t['type_ui_info'] ) for t in ilt if t['portal_type'] not in file_types ]) return SimpleVocabulary(items)
def __call__(self, context): context = getattr(context, 'context', context) portal = getToolByName(context, 'portal_url').getPortalObject() items = [ SimpleTerm( 'auto', 'auto', context.translate( _('label_default_portaltype_configuration', default=u'Default configuration (Content Type Registry).' ))) ] flt = [ _infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, 'file') ] ilt = [ _infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, 'image') ] items.extend([ SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info']) for t in flt ]) file_types = [t['portal_type'] for t in flt] items.extend([ SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info']) for t in ilt if t['portal_type'] not in file_types ]) return SimpleVocabulary(items)
def __call__(self, context): context = getattr(context, 'context', context) portal = getToolByName(context, 'portal_url').getPortalObject() items = [SimpleTerm('auto', 'auto', context.translate(_('label_default_portaltype_configuration', default=u'Default configuration (Content Type Registry).')))] archetype_tool = getToolByName(context, 'archetype_tool', None) if archetype_tool: flt = [_infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IFileContent)] ilt = [_infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IImageContent)] items.extend([SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info']) for t in flt]) file_types = [t['portal_type'] for t in flt] items.extend([SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info']) for t in ilt if t['portal_type'] not in file_types]) for fti in portal.portal_types.objectValues(): if HAS_DEXTERITY and IDexterityFTI.providedBy(fti): try: schema = fti.lookupSchema() except ImportError: # this dexterity type was changed/removed in an improper way # no need to punish, just fail gracefully continue fields = getFieldsInOrder(schema) for fieldname, field in fields: if INamedFileField.providedBy(field) or INamedImageField.providedBy(field): items.append(SimpleTerm(fti.getId(), fti.getId(), fti.Title())) break return SimpleVocabulary(items)
def __call__(self, context): context = getattr(context, 'context', context) portal = getToolByName(context, 'portal_url').getPortalObject() flt = [_infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IFileContent)] ilt = [_infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IImageContent)] items = [SimpleTerm('auto', 'auto', context.translate('label_default_portaltype_configuration', default=u'Default configuration (Content Type Registry).', domain='collective.quickupload')),] all_portal_types = [] for t in flt+ilt: portal_type = t['portal_type'] if portal_type not in all_portal_types: items.append(SimpleTerm(portal_type, portal_type, t['type_ui_info'])) all_portal_types.append(portal_type) for fti in portal.portal_types.objectValues(): if HAS_DEXTERITY and IDexterityFTI.providedBy(fti): fields = getFieldsInOrder(fti.lookupSchema()) for fieldname, field in fields: if INamedFileField.providedBy(field) or INamedImageField.providedBy(field): items.append(SimpleTerm(fti.getId(), fti.getId(), fti.Title())) break return SimpleVocabulary(items)
def __call__(self, context): context = getattr(context, 'context', context) portal = getToolByName(context, 'portal_url').getPortalObject() flt = [ _infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IFileContent) ] ilt = [ _infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IImageContent) ] items = [ SimpleTerm( 'auto', 'auto', context.translate( _('label_default_portaltype_configuration', default=u'Default configuration (Content Type Registry).' ))) ] items.extend([ SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info']) for t in flt ]) file_types = [t['portal_type'] for t in flt] items.extend([ SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info']) for t in ilt if t['portal_type'] not in file_types ]) for fti in portal.portal_types.objectValues(): if HAS_DEXTERITY and IDexterityFTI.providedBy(fti): fields = getFieldsInOrder(fti.lookupSchema()) for fieldname, field in fields: if INamedFileField.providedBy( field) or INamedImageField.providedBy(field): items.append( SimpleTerm(fti.getId(), fti.getId(), fti.Title())) break return SimpleVocabulary(items)
def upload_settings(self): context = aq_inner(self.context) request = self.request try: session = request.get('SESSION', {}) mediaupload = session.get('mediaupload', request.get('mediaupload', '')) typeupload = session.get('typeupload', request.get('typeupload', '')) except SessionDataManagerErr: logger.debug('Error occurred getting session data. Falling back to ' 'request.') mediaupload = request.get('mediaupload', '') typeupload = request.get('typeupload', '') portal_url = getToolByName(context, 'portal_url')() settings = dict( portal_url = portal_url, typeupload = '', context_url = context.absolute_url(), physical_path = "/".join(context.getPhysicalPath()), ul_id = self.uploader_id, ul_fill_titles = self.qup_prefs.fill_titles and 'true' or 'false', ul_fill_descriptions = self.qup_prefs.fill_descriptions and 'true' or 'false', ul_auto_upload = self.qup_prefs.auto_upload and 'true' or 'false', ul_size_limit = self.qup_prefs.size_limit and str(self.qup_prefs.size_limit*1024) or '', ul_xhr_size_limit = self.qup_prefs.size_limit and str(self.qup_prefs.size_limit*1024) or '0', ul_sim_upload_limit = str(self.qup_prefs.sim_upload_limit), ul_button_text = self._translate(_(u'Browse')), ul_draganddrop_text = self._translate(_(u'Drag and drop files to upload')), ul_msg_all_sucess = self._translate(_(u'All files uploaded with success.')), ul_msg_some_sucess = self._translate(_(u' files uploaded with success, ')), ul_msg_some_errors = self._translate(_(u" uploads return an error.")), ul_msg_failed = self._translate(_(u"Failed")), ul_error_try_again_wo = self._translate(_(u"please select files again without it.")), ul_error_try_again = self._translate(_(u"please try again.")), ul_error_empty_file = self._translate(_(u"Selected elements contain an empty file or a folder:")), ul_error_empty_extension = self._translate(_(u"This file has no extension:")), ul_error_file_large = self._translate(_(u"This file is too large:")), ul_error_maxsize_is = self._translate(_(u"maximum file size is:")), ul_error_bad_ext = self._translate(_(u"This file has invalid extension:")), ul_error_onlyallowed = self._translate(_(u"Only allowed:")), ul_error_no_permission = self._translate(_(u"You don't have permission to add this content in this place.")), ul_error_disallowed_type = self._translate(_(u"This type of element is not allowed in this folder.",)), ul_error_already_exists = self._translate(_(u"This file already exists with the same name on server:")), ul_error_zodb_conflict = self._translate(_(u"A data base conflict error happened when uploading this file:")), ul_error_server = self._translate(_(u"Server error, please contact support and/or try again.")), ul_browse_files = self._translate(_('Browse files')), ) settings['typeupload'] = typeupload if typeupload : imageTypes = _listTypesForInterface(context, IImageContent) if typeupload in imageTypes : ul_content_types_infos = self.ul_content_types_infos('image') else : ul_content_types_infos = self.ul_content_types_infos(mediaupload) else : ul_content_types_infos = self.ul_content_types_infos(mediaupload) settings['ul_file_extensions'] = ul_content_types_infos[0] settings['ul_file_extensions_list'] = str(ul_content_types_infos[1]) settings['ul_file_description'] = ul_content_types_infos[2] return settings