def create_statusmessages( self, moved_items, failed_objects, failed_resource_locked_objects ): """ Create statusmessages with errors and infos af the move-process """ if moved_items: msg = _(u'${moved_items} Elements were moved successfully', mapping=dict(moved_items=moved_items)) IStatusMessage(self.request).addStatusMessage( msg, type='info') if failed_objects: msg = _(u'Failed to move following objects: ${failed_objects}', mapping=dict(failed_objects=',<br>'.join(failed_objects))) IStatusMessage(self.request).addStatusMessage( msg, type='error') if failed_resource_locked_objects: msg = _( u'''Failed to move following objects: ''' + '''${failed_objects}. Locked via WebDAV''', mapping=dict(failed_objects=',<br>'.join( failed_resource_locked_objects))) IStatusMessage(self.request).addStatusMessage( msg, type='error')
def get_render_arguments(self): return { 'title': translate(_(u'latex_files_title'), context=self.request), 'date': translate(_(u'latex_files_effective'), context=self.request), 'modified': translate(_(u'latex_files_modified'), context=self.request), 'creator': translate(_(u'latex_files_creator'), context=self.request), 'items': self.get_items() }
def get_render_arguments(self): labels = { 'pageLabel': _(u'latex_page', default=u'Page'), 'printedLabel': _(u'latex_printed', default=u'Printed'), } for key, value in labels.items(): labels[key] = translate(value, context=self.request) return labels
def get_header(context): return [ context.translate( _(u'export_heading_user_id', default=u'User ID')), context.translate( _(u'export_heading_full_name', default=u'Full name')), context.translate( _(u'export_heading_email', default=u'E-Mail')), context.translate( _(u'export_heading_roles', default=u'Roles')), ]
def get_labels(self): labels = { 'labelWorkspace': _(u'latex_label_workspace', u'Workspace'), 'labelTitle': _(u'latex_label_title', u'Title'), 'labelOwner': _(u'latex_label_owner', u'Owner'), 'labelDescription': _(u'latex_label_description', u'Description'), } for key, value in labels.items(): labels[key] = translate(value, context=self.request) return labels
def get_files(self, path_prefix=u"", recursive=True, toplevel=True): """ Returns a list of two-value-tuples having the following values: - a relative path under which the file should show up in the zip - the data as either a file or a stream """ filename = '{0}.pdf'.format(self.context.getId()) assembler = getMultiAdapter((self.context, self.request), IPDFAssembler) yield (u'{0}/{1}'.format(safe_unicode(path_prefix), safe_unicode(filename)), StringIO(assembler.build_pdf())) header = get_header(self.context) data = get_data(self.context) xlsx = create_xlsx(header, data) filename = translate( _(u'participants_export_filename', default=u'participants.xlsx'), context=self.request ) yield (u'{0}/{1}'.format(safe_unicode(path_prefix), safe_unicode(filename)), xlsx) # Recursively export folder contents. folder_contents = super(WorkspaceZipRepresentation, self).get_files( path_prefix, recursive, toplevel) for item in folder_contents: yield item
def validate(self, value): super(DestinationValidator, self).validate(value) # Allowed contenttypes for destination-folder allowed_types = [t.getId() for t in value.allowedContentTypes()] # Paths to source object source = self.view.widgets['request_paths'].value.split(';;') # Get source-brains portal_catalog = getToolByName(self.context, 'portal_catalog') src_brains = portal_catalog(path={'query': source, 'depth': 0}) failed_objects = [] # Look for invalid contenttype for src_brain in src_brains: if not src_brain.portal_type in allowed_types: failed_objects.append(src_brain.Title.decode('utf8')) # If we found one or more invalid contenttypes, we raise an error if failed_objects: raise NotInContentTypes( _(u"error_NotInContentTypes ${failed_objects}", default=u"It isn't allowed to add such items there: " + "${failed_objects}", mapping=dict( failed_objects=',<br>'.join(failed_objects))))
def columns(self): # default implementation date_column = {'column': 'effective', 'column_title': _(u'column_date', default=u'date'), 'transform': helper.readable_date_text, 'width': 100} # ftw.file implementation if has_ftwfile(self.context): date_column['column'] = 'documentDate' date_column['column_title'] = fileMF(u'label_document_date', default=u'Document date') columns = ( {'column': '', 'column_title': '', 'transform': helper.path_checkbox, 'sortable': False, 'width': 30}, {'column': 'getIcon', 'sort_index': 'getContentType', 'column_title': _(u'column_type', default=u'Type'), 'transform': workspace_helper.icon_or_sprite, 'width': 35}, {'column': 'Title', 'column_title': _(u'column_title', default=u'Title'), 'sort_index': 'sortable_title', 'transform': helper.link(icon=False, tooltip=True)}, ) + (date_column,) + ( # Add variable date column {'column': 'Creator', 'column_title': _(u'column_creator', default=u'Creator'), 'sort_index': 'sortable_creator', 'transform': helper.readable_author}, {'column': 'modified', 'column_title': _(u'column_modified', default=u'modified'), 'transform': helper.readable_date_text, 'width': 80}, ) return columns
def generate_date(self, datetimestring, now=None): if now is None: now = datetime.datetime.now() today = now.day yesterday = (now - datetime.timedelta(1)).day this_month = now.month this_year = now.year modified = DateTime(datetimestring) if modified.month() == this_month and modified.year() == this_year: if modified.day() == today: return _(u'label_today', default=u'Today, ${time}', mapping={'time': modified.strftime('%H:%M')}) elif modified.day() == yesterday: return _(u'label_yesterday', u'Yesterday, ${time}', mapping={'time': modified.strftime('%H:%M')}) else: return modified.strftime('%d.%m.%Y') else: return modified.strftime('%d.%m.%Y')
def render(self): if not self.request.get('paths') and not \ self.form_instance.widgets['request_paths'].value: msg = _(u'You have not selected any items') IStatusMessage(self.request).addStatusMessage( msg, type='error') # redirect to the right tabbedview_tab if self.request.form.get('orig_template'): return self.request.RESPONSE.redirect( self.request.form.get('orig_template')) # fallback documents tab else: return self.request.RESPONSE.redirect( '%s#documents' % self.context.absolute_url()) return super(MoveItemsFormView, self).render()
def get_title(self): return translate(_(u'latex_label_files', u'Files'), context=self.request)
def preview(self): return '<img height="200px" src="{0}" alt={1} title={1}/>'.format( self.full_url(), _(u"text_no_preview", default=u"No Preview") )
from zope.interface import implements WorkspaceSchema = folder.ATFolderSchema.copy() + atapi.Schema(( atapi.TextField( 'text', searchable=True, required=False, allowable_content_types=('text/html', ), default_content_type='text/html', validators=('isTidyHtmlWithCleanup', ), default_output_type='text/x-html-safe', default_input_type='text/html', storage=atapi.AnnotationStorage(), widget=atapi.RichWidget( label=_(u"label_text", default=u"Text"), rows=15, allow_file_upload=False, allow_buttons=TinyMCEAllowedButtonsConfigurator(), ), ), )) finalizeWorkspaceSchema(WorkspaceSchema, folderish=True, moveDiscussion=False) @adapter(IWorkspace, IObjectInitializedEvent) def workspace_added(workspace, event):