def test_convert_to_publication(self):
        """Test convertion of a Ghost Folder to a Publication.
        """
        factory = self.root.target.manage_addProduct['Silva']
        factory.manage_addGhostFolder('ghost', None, haunted=self.root.folder)

        ghost = self.root.target.ghost
        self.assertFalse(IPublication.providedBy(ghost))
        self.assertTrue(verifyObject(IGhostFolder, ghost))
        self.assertEqual(self.root.target.objectValues('Silva Ghost Folder'),
                         [ghost])
        self.assertEqual(self.root.target.objectValues('Silva Publication'),
                         [])

        ghost.to_publication()

        ghost = self.root.target.ghost
        self.assertTrue(verifyObject(IPublication, ghost))
        self.assertFalse(IGhostFolder.providedBy(ghost))
        self.assertEqual(self.root.target.objectValues('Silva Ghost Folder'),
                         [])
        self.assertEqual(self.root.target.objectValues('Silva Publication'),
                         [ghost])

        # Content is still there
        self.assertEqual(ghost.objectIds(),
                         ['document', 'folder', 'index', 'publication'])

        # And there are still ghosts
        self.assertTrue(verifyObject(IGhostFolder, ghost.folder))
        self.assertTrue(verifyObject(IGhostFolder, ghost.publication))
        self.assertTrue(verifyObject(IGhost, ghost.index))
        self.assertTrue(verifyObject(IGhost, ghost.document))
Exemplo n.º 2
0
 def top_menu_items(self):
     for content in self.root.get_ordered_publishables():
         if not IPublication.providedBy(content):
             continue
         yield {'title': content.get_title_or_id(),
                'css': content in self.request.PARENTS and 'active' or '',
                'url': absoluteURL(content, self.request)}
Exemplo n.º 3
0
 def description(self):
     if IGhostFolder.providedBy(self.context):
         return _(u'This Ghost Folder can be converted '
                  u'to a normal Publication or Folder. All ghosted content '
                  u'will be duplicated and can then be edited.')
     elif IPublication.providedBy(self.context):
         if self.manager.is_site():
             return _(u"This Silva Publication is a local site. You need to "
                      u"remove any local service, and the local site before "
                      u"you can convert it to a Silva Folder.")
         return _(u'This Silva Publication can be converted '
                  u'to a Silva Folder, or can become a local site.')
     return _(u'This Silva Folder can be converted '
              u'to a Publication.')
    def test_publication_to_folder(self):
        """Test Silva Publication to Silva Folder conversion.
        """
        factory = self.root.manage_addProduct["Silva"]
        factory.manage_addPublication("publication", "Publication")
        factory = self.root.publication.manage_addProduct["Silva"]
        factory.manage_addAutoTOC("index", "Index")

        self.assertTrue("publication" in self.get_listing("Silva Publication"))
        self.assertTrue(verifyObject(IPublication, self.root.publication))
        publication_id = self.get_id(self.root.publication)

        with assertTriggersEvents("ObjectModifiedEvent"):
            self.root.publication.to_folder()

        self.assertFalse("publication" in self.get_listing("Silva Publication"))
        self.assertTrue("publication" in self.get_listing("Silva Folder"))
        self.assertTrue(verifyObject(IFolder, self.root.publication))
        self.assertFalse(IPublication.providedBy(self.root.publication))
        self.assertTrue("index" in self.root.publication.objectIds())
        self.assertEqual(publication_id, self.get_id(self.root.publication))
Exemplo n.º 5
0
    def test_publication_to_folder(self):
        """Test Silva Publication to Silva Folder conversion.
        """
        factory = self.root.manage_addProduct['Silva']
        factory.manage_addPublication('publication', 'Publication')
        factory = self.root.publication.manage_addProduct['Silva']
        factory.manage_addAutoTOC('index', 'Index')

        self.assertTrue('publication' in self.get_listing('Silva Publication'))
        self.assertTrue(verifyObject(IPublication, self.root.publication))
        publication_id = self.get_id(self.root.publication)

        with assertTriggersEvents('ObjectModifiedEvent'):
            self.root.publication.to_folder()

        self.assertFalse('publication' in self.get_listing('Silva Publication'))
        self.assertTrue('publication' in self.get_listing('Silva Folder'))
        self.assertTrue(verifyObject(IFolder, self.root.publication))
        self.assertFalse(IPublication.providedBy(self.root.publication))
        self.assertTrue('index' in self.root.publication.objectIds())
        self.assertEqual(publication_id, self.get_id(self.root.publication))
Exemplo n.º 6
0
    def test_convert_to_publication(self):
        """Test convertion of a Ghost Folder to a Publication.
        """
        factory = self.root.target.manage_addProduct['Silva']
        factory.manage_addGhostFolder('ghost', None, haunted=self.root.folder)

        ghost = self.root.target.ghost
        self.assertFalse(IPublication.providedBy(ghost))
        self.assertTrue(verifyObject(IGhostFolder, ghost))
        self.assertEqual(
            self.root.target.objectValues('Silva Ghost Folder'),
            [ghost])
        self.assertEqual(
            self.root.target.objectValues('Silva Publication'),
            [])

        ghost.to_publication()

        ghost = self.root.target.ghost
        self.assertTrue(verifyObject(IPublication, ghost))
        self.assertFalse(IGhostFolder.providedBy(ghost))
        self.assertEqual(
            self.root.target.objectValues('Silva Ghost Folder'),
            [])
        self.assertEqual(
            self.root.target.objectValues('Silva Publication'),
            [ghost])

        # Content is still there
        self.assertEqual(
            ghost.objectIds(),
            ['document', 'folder', 'index', 'publication'])

        # And there are still ghosts
        self.assertTrue(verifyObject(IGhostFolder, ghost.folder))
        self.assertTrue(verifyObject(IGhostFolder, ghost.publication))
        self.assertTrue(verifyObject(IGhost, ghost.index))
        self.assertTrue(verifyObject(IGhost, ghost.document))
Exemplo n.º 7
0
 def sax_contents(self):
     options = self.getOptions()
     self.startElement('content')
     if not options.only_container:
         default = self.context.get_default()
         if default is not None:
             self.startElement('default')
             self.subsax(default)
             self.endElement('default')
         for content in self.context.get_ordered_publishables():
             if (IPublication.providedBy(content) and
                 not options.include_publications):
                 continue
             self.subsax(content)
         for content in self.context.get_non_publishables():
             self.subsax(content)
         if options.other_contents:
             meta_types = meta_types_for_interface(
                 ISilvaXMLExportable,
                 excepts=[IPublishable, INonPublishable])
             for content in self.context.objectValues(meta_types):
                 self.subsax(content)
     self.endElement('content')
    def test_folder_to_publication_with_marker_past(self):
        """Test Silva Folder to Silva Publication conversion when the
        folder have been provided in the past with a marker.
        """
        factory = self.root.manage_addProduct["Silva"]
        factory.manage_addFolder("folder", "Folder")
        factory = self.root.folder.manage_addProduct["Silva"]
        factory.manage_addAutoTOC("index", "Index")

        folder_id = self.get_id(self.root.folder)
        alsoProvides(self.root.folder, IAdditionalMarker)
        noLongerProvides(self.root.folder, IAdditionalMarker)
        self.assertTrue("folder" in self.get_listing("Silva Folder"))
        self.assertTrue(verifyObject(IFolder, self.root.folder))
        self.assertFalse(IPublication.providedBy(self.root.folder))

        with assertTriggersEvents("ObjectModifiedEvent"):
            self.root.folder.to_publication()

        self.assertFalse("folder" in self.get_listing("Silva Folder"))
        self.assertTrue("folder" in self.get_listing("Silva Publication"))
        self.assertTrue(verifyObject(IPublication, self.root.folder))
        self.assertTrue("index" in self.root.folder.objectIds())
        self.assertEqual(folder_id, self.get_id(self.root.folder))
Exemplo n.º 9
0
    def test_folder_to_publication_with_marker_past(self):
        """Test Silva Folder to Silva Publication conversion when the
        folder have been provided in the past with a marker.
        """
        factory = self.root.manage_addProduct['Silva']
        factory.manage_addFolder('folder', 'Folder')
        factory = self.root.folder.manage_addProduct['Silva']
        factory.manage_addAutoTOC('index', 'Index')

        folder_id = self.get_id(self.root.folder)
        alsoProvides(self.root.folder, IAdditionalMarker)
        noLongerProvides(self.root.folder, IAdditionalMarker)
        self.assertTrue('folder' in self.get_listing('Silva Folder'))
        self.assertTrue(verifyObject(IFolder, self.root.folder))
        self.assertFalse(IPublication.providedBy(self.root.folder))

        with assertTriggersEvents('ObjectModifiedEvent'):
            self.root.folder.to_publication()

        self.assertFalse('folder' in self.get_listing('Silva Folder'))
        self.assertTrue('folder' in self.get_listing('Silva Publication'))
        self.assertTrue(verifyObject(IPublication, self.root.folder))
        self.assertTrue('index' in self.root.folder.objectIds())
        self.assertEqual(folder_id, self.get_id(self.root.folder))
Exemplo n.º 10
0
 def available(self, form):
     return (IGhostFolder.providedBy(form.context) or
             (IPublication.providedBy(form.context) and
              not form.manager.is_site()))
Exemplo n.º 11
0
 def get_publication(self):
     """returns self if haunted object is a publication"""
     content = self.get_haunted()
     if IPublication.providedBy(content):
         return self.aq_inner
     return aq_parent(self).get_publication()
Exemplo n.º 12
0
 def available(self, form):
     return not IPublication.providedBy(form.context)
Exemplo n.º 13
0
def set_quota(content, size_in_megabytes):
    if not IPublication.providedBy(content):
        raise ValueError('cannot set quota content on %r' % content)
    service = getUtility(IMetadataService)
    binding = service.getMetadata(content)
    binding.setValues('silva-quota', {'quota': size_in_megabytes})
Exemplo n.º 14
0
 def available(self, form):
     return (IPublication.providedBy(form.context) and
             form.manager.is_site())
Exemplo n.º 15
0
 def get_publication(self):
     """returns self if haunted object is a publication"""
     content = self.get_haunted()
     if IPublication.providedBy(content):
         return self.aq_inner
     return aq_parent(self).get_publication()
Exemplo n.º 16
0
def set_quota(content, size_in_megabytes):
    if not IPublication.providedBy(content):
        raise ValueError('cannot set quota content on %r' % content)
    service = getUtility(IMetadataService)
    binding = service.getMetadata(content)
    binding.setValues('silva-quota', {'quota': size_in_megabytes})
 def publishable(x):
     return x.is_published() and IPublication.providedBy(x)