示例#1
0
    def test_get_publication_datetime(self):
        """Verify get_publication_datetime
        """
        manager = IVersionManager(self.root.test.get_editable())
        self.assertEqual(manager.get_publication_datetime(), None)

        now = DateTime()
        self.root.test.set_unapproved_version_publication_datetime(now)
        self.assertEqual(manager.get_publication_datetime(), now)

        # Published version already have a publication date since they
        # are published.
        manager = IVersionManager(self.root.test.get_viewable())
        self.assertNotEqual(manager.get_publication_datetime(), None)
示例#2
0
class PublicationStatusInfo(grok.Adapter):
    grok.context(IVersion)
    grok.provides(IPublicationStatusInfo)

    def __init__(self, context):
        self.context = context
        self.manager = IVersionManager(self.context)

    @property
    def id(self):
        return self.context.getId()

    @property
    def modification_time(self):
        dt = self.manager.get_modification_datetime()
        if dt is not None:
            return dt.asdatetime()

    @property
    def publication_time(self):
        dt = self.manager.get_publication_datetime()
        if dt is not None:
            return dt.asdatetime()

    @property
    def expiration_time(self):
        dt = self.manager.get_expiration_datetime()
        if dt is not None:
            return dt.asdatetime()

    @property
    def last_author(self):
        author = self.manager.get_last_author()
        if author is not None:
            return author.fullname()

    @property
    def version_status(self):
        return self.manager.get_status()

    def delete(self):
        return self.manager.delete()

    def copy_for_editing(self):
        return self.manager.make_editable()
示例#3
0
def copy_version(source, target, ensure=False):
    """Copy version document from source to target.
    """
    # Move text
    move_text(source, target)
    # Copy metadata content
    copy_annotation(source, target)
    # Publication datetime
    info = IVersionManager(source)
    publication_datetime = info.get_publication_datetime()
    if publication_datetime is None and ensure:
        publication_datetime = DateTime()
    target.set_unapproved_version_publication_datetime(publication_datetime)
    target.set_unapproved_version_expiration_datetime(
        info.get_expiration_datetime())
    # Copy last author information
    user = aq_base(source.get_last_author_info())
    if not isinstance(user, NoneMember):
        target._last_author_userid = user.id
        target._last_author_info = aq_base(user)
    # Copy creator information
    target._owner = getattr(aq_base(source), '_owner', None)
def copy_version(source, target, ensure=False):
    """Copy version document from source to target.
    """
    # Move text
    move_text(source, target)
    # Copy metadata content
    copy_annotation(source, target)
    # Publication datetime
    info = IVersionManager(source)
    publication_datetime = info.get_publication_datetime()
    if publication_datetime is None and ensure:
        publication_datetime = DateTime()
    target.set_unapproved_version_publication_datetime(
        publication_datetime)
    target.set_unapproved_version_expiration_datetime(
        info.get_expiration_datetime())
    # Copy last author information
    user = aq_base(source.get_last_author_info())
    if not isinstance(user, NoneMember):
        target._last_author_userid = user.id
        target._last_author_info = aq_base(user)
    # Copy creator information
    target._owner = getattr(aq_base(source), '_owner', None)
示例#5
0
 def date_published(self):
     manager = IVersionManager(self.context)
     return manager.get_publication_datetime()