Esempio n. 1
0
 def versionTitle(self, version):
     version_name = self.versionName(version)
     
     return translate(
         _(u"version ${version}",
           mapping=dict(version=version_name)),
         context=self.request
     )
Esempio n. 2
0
def revert(context, version):
    pr = getToolByName(context, "portal_repository")
    pr.revert(context, version)

    title = context.title_or_id()
    if not isinstance(title, str):
        title = str(title, "utf-8", "ignore")

    if pr.supportsPolicy(context, "version_on_revert"):
        try:
            commit_msg = context.translate(
                _("Reverted to revision ${version}",
                  mapping={"version": version}))
            pr.save(obj=context, comment=commit_msg)
        except FileTooLargeToVersionError:
            error_msg = ("The most current revision of the file could not " +
                         "be saved before reverting because the file is " +
                         "too large.")
            raise BadRequest({"errors": error_msg})

    msg = f"{title} has been reverted to revision {version}."
    return {"message": msg}
Esempio n. 3
0
def revert(context, version):
    pr = getToolByName(context, 'portal_repository')
    pr.revert(context, version)

    title = context.title_or_id()
    if not isinstance(title, unicode):
        title = unicode(title, 'utf-8', 'ignore')

    if pr.supportsPolicy(context, 'version_on_revert'):
        try:
            commit_msg = context.translate(
                _(u'Reverted to revision ${version}',
                  mapping={'version': version}))
            pr.save(obj=context, comment=commit_msg)
        except FileTooLargeToVersionError:
            error_msg = 'The most current revision of the file could not ' + \
                        'be saved before reverting because the file is ' + \
                        'too large.'
            raise BadRequest({
                'errors': error_msg,
            })

    msg = u'{} has been reverted to revision {}.'.format(title, version)
    return {'message': msg}
Esempio n. 4
0
def webdavObjectEdited(obj, event):
    return webdavObjectEventHandler(obj, event, comment=_('Edited (WebDAV)'))
RESPONSE = context.REQUEST.RESPONSE
putils = container.plone_utils
pr = container.portal_repository
pr.revert(context, version_id)

obj_type_view_url = context.getTypeInfo().getActionInfo('object/view')['url']
if obj_type_view_url != '/':
    view_url = '%s/%s' % (context.absolute_url(), obj_type_view_url)
else:
    view_url = context.absolute_url()

title = safe_unicode(context.title_or_id())
msg = _(u'${title} has been reverted to revision ${version}.',
        mapping={
            'title': title,
            'version': version_id
        })

if pr.supportsPolicy(context, 'version_on_revert'):
    try:
        commit_msg = context.translate(
            _(u'Reverted to revision ${version}',
              mapping={'version': version_id}))
        pr.save(obj=context, comment=commit_msg)
    except FileTooLargeToVersionError:
        putils.addPortalMessage(_(
            u'The most current revision of the file could not be saved before reverting '
            'because the file is too large.'),
                                type='warn')

RESPONSE = context.REQUEST.RESPONSE
putils = container.plone_utils
pr = container.portal_repository
pr.revert(context, version_id)

obj_type_view_url = context.getTypeInfo().getActionInfo('object/view')['url']
if obj_type_view_url != '/':
    view_url = '%s/%s' % (context.absolute_url(), obj_type_view_url)
else:
    view_url = context.absolute_url()

title = safe_unicode(context.title_or_id())
msg = _(u'${title} has been reverted to revision ${version}.',
        mapping={'title': title,
                 'version': version_id})

if pr.supportsPolicy(context, 'version_on_revert'):
    try:
        commit_msg = context.translate(_(u'Reverted to revision ${version}',
                                       mapping={'version': version_id}))
        pr.save(obj=context, comment=commit_msg)
    except FileTooLargeToVersionError:
        putils.addPortalMessage(
  _(u'The most current revision of the file could not be saved before reverting '
    'because the file is too large.'),
       type='warn'
       )

context.plone_utils.addPortalMessage(msg)
Esempio n. 7
0
def webdavObjectEdited(obj, event):
    return webdavObjectEventHandler(obj, event, comment=_('Edited (WebDAV)'))
Esempio n. 8
0
def objectInitialized(obj, event):
    comment = _getVersionComment(event.object) or _('Initial revision')
    return webdavObjectEventHandler(obj, event, comment=comment)
Esempio n. 9
0
 def versionTitle(self, version):
     return translate(
         _(u"version ${version}",
           mapping=dict(version=version)),
         context=self.request
     )
Esempio n. 10
0
def webdavObjectInitialized(obj, event):
    return webdavObjectEventHandler(obj,
                                    event,
                                    comment=_('Initial revision (WebDAV)'))
Esempio n. 11
0
def webdavObjectInitialized(obj, event):
    return webdavObjectEventHandler(obj, event, comment=_('Initial revision (WebDAV)'))
Esempio n. 12
0
 def versionName(self, version):
     """
     Translate the version name. This is needed to allow translation when `version` is the
     string 'current'.
     """ 
     return _(version)
Esempio n. 13
0
 def versionName(self, version):
     """
     Translate the version name. This is needed to allow translation when `version` is the
     string 'current'.
     """
     return _(version)
Esempio n. 14
0
    def versionTitle(self, version):
        version_name = self.versionName(version)

        return translate(_(u"version ${version}",
                           mapping=dict(version=version_name)),
                         context=self.request)
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=id1, id2
##title=Compute object differences
##

from Products.CMFCore.utils import getToolByName
from Products.CMFEditions import CMFEditionsMessageFactory as _

retrieve = context.portal_repository.retrieve

if id1 == 'current':
    ob1 = context
else:
    ob1 = retrieve(context, int(id1)).object

ob2 = retrieve(context, int(id2)).object
base_id = ob1.getId()
portal_diff = getToolByName(context, 'portal_diff')

# Translate the revision IDs to enable translation of the string "current".
diff = portal_diff.createChangeSet(
    ob2,
    ob1,
    id1=ob2.getId() + ' (rev. %s)' % context.translate(_(id2)),
    id2=ob1.getId() + ' (rev. %s)' % context.translate(_(id1)))
return diff
Esempio n. 16
0
## Script (Python) "onEditChangeSet"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=id1, id2
##title=Compute object differences
##

from Products.CMFCore.utils import getToolByName
from Products.CMFEditions import CMFEditionsMessageFactory as _

retrieve = context.portal_repository.retrieve

if id1 == 'current':
    ob1 = context
else:
    ob1 = retrieve(context, int(id1)).object

ob2 = retrieve(context, int(id2)).object
base_id = ob1.getId()
portal_diff = getToolByName(context, 'portal_diff')

# Translate the revision IDs to enable translation of the string "current".
diff = portal_diff.createChangeSet(ob2, ob1,
                                   id1=ob2.getId()+' (rev. %s)'% context.translate(_(id2)),
                                   id2=ob1.getId()+' (rev. %s)'% context.translate(_(id1)))
return diff
Esempio n. 17
0
pr.revert(context, version_id)

obj_type_view_url = context.getTypeInfo().getActionInfo('object/view')['url']
if obj_type_view_url != '/':
    view_url = '%s/%s' % (context.absolute_url(),
                          obj_type_view_url
                         )
else:
    view_url = context.absolute_url()

title = context.title_or_id()
if not isinstance(title, unicode):
    title = unicode(title, 'utf-8', 'ignore')

msg = _(u'${title} has been reverted to revision ${version}.',
        mapping={'title': context.title_or_id(),
                 'version': version_id})

if pr.supportsPolicy(context, 'version_on_revert'):
    try:
        pr.save(obj=context, comment=_(u'Reverted to revision ${version}',
                                       mapping={'version': version_id}))
    except FileTooLargeToVersionError:
        putils.addPortalMessage(
  _(u'The most current revision of the file could not be saved before reverting '
    'because the file is too large.'),
       type='warn'
       )

context.plone_utils.addPortalMessage(msg)
return RESPONSE.redirect(view_url)
Esempio n. 18
0
def objectInitialized(obj, event):
    comment = _getVersionComment(event.object) or _('Initial revision')
    return webdavObjectEventHandler(obj, event, comment=comment)
Esempio n. 19
0
pr.revert(context, version_id)

obj_type_view_url = context.getTypeInfo().getActionInfo('object/view')['url']
if obj_type_view_url != '/':
    view_url = '%s/%s' % (context.absolute_url(),
                          obj_type_view_url
                         )
else:
    view_url = context.absolute_url()

title = context.title_or_id()
if not isinstance(title, six.text_type):
    title = six.text_type(title, 'utf-8', 'ignore')

msg = _(u'${title} has been reverted to revision ${version}.',
        mapping={'title': title,
                 'version': version_id})

if pr.supportsPolicy(context, 'version_on_revert'):
    try:
        commit_msg = context.translate(_(u'Reverted to revision ${version}',
                                       mapping={'version': version_id}))
        pr.save(obj=context, comment=commit_msg)
    except FileTooLargeToVersionError:
        putils.addPortalMessage(
  _(u'The most current revision of the file could not be saved before reverting '
    'because the file is too large.'),
       type='warn'
       )

context.plone_utils.addPortalMessage(msg)