Example #1
0
 def enabled(self, view):
     if view and not IViewView.providedBy(view):
         return False
     if view and IFolderContentsView.providedBy(view):
         return False
     enabled_portal_types = self.enabled_portal_types()
     return self.context.portal_type in enabled_portal_types
    def available(self):
        if not (IViewView.providedBy(self.view)
                or IFolderContentsView.providedBy(self.view)):
            return False

        # Context could be a default page.  We want the canonical object
        # instead.
        context = aq_inner(self.context)
        pcs = getMultiAdapter(
            (context, self.request), name='plone_context_state')
        canonical = pcs.canonical_object()
        if not IQuickUploadCapable.providedBy(canonical):
            return False
        elif IQuickUploadNotCapable.providedBy(canonical):
            return False
        elif not self.pm.checkPermission('Add portal content', canonical):
            return False
        elif isTemporary(canonical):
            return False

        upload_portal_type = self.data.upload_portal_type
        if (upload_portal_type and upload_portal_type != 'auto'
                and upload_portal_type not in [
                    t.id for t in canonical.getAllowedTypes()
                ]):
            return False
        else:
            return True
    def available(self):
        if not (IViewView.providedBy(self.view)
                or IFolderContentsView.providedBy(self.view)):
            return False

        # Context could be a default page.  We want the canonical object
        # instead.
        context = aq_inner(self.context)
        pcs = getMultiAdapter(
            (context, self.request), name='plone_context_state')
        canonical = pcs.canonical_object()
        if not IQuickUploadCapable.providedBy(canonical):
            return False
        elif IQuickUploadNotCapable.providedBy(canonical):
            return False
        elif not self.pm.checkPermission('Add portal content', canonical):
            return False
        elif isTemporary(canonical):
            return False

        upload_portal_type = self.data.upload_portal_type
        if (upload_portal_type and upload_portal_type != 'auto'
                and upload_portal_type not in [
                    t.id for t in canonical.getAllowedTypes()
                ]):
            return False
        else:
            return True
 def show_history(self):
     if not _checkPermission('CMFEditions: Access previous versions', self.context):
         return False
     if IViewView.providedBy(self.__parent__):
         return True
     if IFolderContentsView.providedBy(self.__parent__):
         return True
     return False
Example #5
0
 def show_history(self):
     if not _checkPermission('CMFEditions: Access previous versions', self.context):
         return False
     if IViewView.providedBy(self.__parent__):
         return True
     if IFolderContentsView.providedBy(self.__parent__):
         return True
     return False
 def disabled(self):
     # From: plone.app.contentmenu.menu.DisplayMenuSubMenuItem.disabled:
     if IFolderContentsView.providedBy(self.request):
         return True
     context = self.context
     if not getattr(context, 'isPrincipiaFolderish', False):
         return False
     elif 'index_html' not in context.objectIds():
         return False
     else:
         return True
 def disabled(self):
     # From: plone.app.contentmenu.menu.DisplayMenuSubMenuItem.disabled:
     if IFolderContentsView.providedBy(self.request):
         return True
     context = self.context
     if not getattr(context, 'isPrincipiaFolderish', False):
         return False
     elif 'index_html' not in context.objectIds():
         return False
     else:
         return True
Example #8
0
    def enabled(self):
        """Show the viewlet just in folder_contents view if enabled."""
        if not IFolderContentsView.providedBy(self.view):
            return False

        try:
            return api.portal.get_registry_record(
                interface=IUploadSettings, name='show_widget')
        except (InvalidParameterError, KeyError):
            # avoid breaking page rendering if record is not present
            # this could happen on upgrades or accidental deletions
            return False
 def enabled(self, view):
     if view and not IViewView.providedBy(view):
         return False
     if view and IFolderContentsView.providedBy(view):
         return False
     folderish_templates = self.folderish_templates()
     template = self.view_template_id()
     if IFolderish.providedBy(self.context) and \
             template in folderish_templates:
         return True
     enabled_portal_types = self.enabled_portal_types()
     return self.context.portal_type in enabled_portal_types
 def structure_updater(self):
     """Generate the options for the structure updater pattern.
     If we're not in folder contents view, do not expose these options.
     """
     data = {}
     view = self.request.get('PUBLISHED', None)
     if IFolderContentsView.providedBy(view):
         data = {
             'data-pat-structureupdater': json.dumps({
                 'titleSelector': '.documentFirstHeading',
                 'descriptionSelector': '.documentDescription'
             })
         }
     return data
Example #11
0
 def structure_updater(self):
     """Generate the options for the structure updater pattern.
     If we're not in folder contents view, do not expose these options.
     """
     data = {}
     view = self.request.get('PUBLISHED', None)
     if IFolderContentsView.providedBy(view):
         data = {
             'data-pat-structureupdater': json.dumps({
                 'titleSelector': '.documentFirstHeading',
                 'descriptionSelector': '.documentDescription'
             })
         }
     return data
 def add_context(self):
     context = self.context
     context_state = getMultiAdapter((context, self.request),
                                     name='plone_context_state')
     context = aq_inner(context)
     try:
         published = self.request.PUBLISHED
     except AttributeError:
         published = context
     if context_state.is_structural_folder():
         if context_state.is_default_page():
             if IFolderContentsView.providedBy(published) or self == published:
                 # on the folder_contents view and factories view,
                 # show the actual context object's addable types
                 return context
             else:
                 return aq_parent(context)
         else:
             return context
     else:
         return aq_parent(context)
    def available(self):
        if not (IViewView.providedBy(self.view) \
             or IFolderContentsView.providedBy(self.view)):
            return False

        context = aq_inner(self.context)

        if not IQuickUploadCapable.providedBy(context):
            return False
        elif IQuickUploadNotCapable.providedBy(context):
            return False
        elif not self.pm.checkPermission('Add portal content', context):
            return False
        elif isTemporary(context):
            return False

        upload_portal_type = self.data.upload_portal_type
        if (upload_portal_type and upload_portal_type != 'auto'
                and upload_portal_type not in [t.id for t
                        in self.context.getAllowedTypes()]):
            return False
        else:
            return True
Example #14
0
 def add_context(self):
     context = self.context
     context_state = getMultiAdapter((context, self.request),
                                     name='plone_context_state')
     context = aq_inner(context)
     try:
         published = self.request.PUBLISHED
     except AttributeError:
         published = context
     if context_state.is_structural_folder():
         if context_state.is_default_page():
             is_folder_contents_view = \
                 IFolderContentsView.providedBy(published)
             if is_folder_contents_view or self == published:
                 # on the folder_contents view and factories view,
                 # show the actual context object's addable types
                 return context
             else:
                 return aq_parent(context)
         else:
             return context
     else:
         return aq_parent(context)
    def available(self):
        if not (IViewView.providedBy(self.view) \
             or IFolderContentsView.providedBy(self.view)):
            return False

        context = aq_inner(self.context)

        if not IQuickUploadCapable.providedBy(context):
            return False
        elif IQuickUploadNotCapable.providedBy(context):
            return False
        elif not self.pm.checkPermission('Add portal content', context):
            return False
        elif isTemporary(context):
            return False

        upload_portal_type = self.data.upload_portal_type
        if (upload_portal_type and upload_portal_type != 'auto'
                and upload_portal_type
                not in [t.id for t in self.context.getAllowedTypes()]):
            return False
        else:
            return True
Example #16
0
    def enabled(self):
        """Show the viewlet just in folder_contents view if enabled."""
        if not IFolderContentsView.providedBy(self.view):
            return False

        return self.settings.show_widget