コード例 #1
0
    def checkin_allowed(self):
        """ Check if a checkin is allowed.
            Conditions:
            - provides IIterateAware
            - is not baseline
            - is the working copy
            - is versionable
            - user should have ModifyPortalContent permission
        """
        context = aq_inner( self.context )

        if not interfaces.IIterateAware.providedBy( context ):
            return False

        if context == get_baseline( context ):
            return False

        if context != get_working_copy( context ):
            return False

        archiver = interfaces.IObjectArchiver(context)
        if not archiver.isVersionable():
            return False

        checkPermission = getSecurityManager().checkPermission
        if not checkPermission(ModifyPortalContent, context):
            return False

        return True
コード例 #2
0
    def render(self):
        print "WC: ", get_working_copy(self.context)
        print "Baseline: ", get_baseline(self.context)

        if not self.available():
            return ""
        return super(EditMenuViewlet, self).render()
コード例 #3
0
    def handle_edit(self):
        obj = get_working_copy(self.context)

        # TODO: use the stagingbehavior API to get the best object, in all cases
        print "WC: ", obj
        print "Baseline: ", get_baseline(self.context)

        if obj is None:
            obj = self.context

        state = get_state(obj)

        if state == 'private':
            url = '{0}/edit'.format(obj.absolute_url())
            return self.request.response.redirect(url)

        elif state == 'published':
            # create copy, go to it
            wc = self._checkout()
            url = '{0}/edit'.format(wc.absolute_url())
            return self.request.response.redirect(url)

        elif state == 'pending':
            # create copy, go to it
            transition(obj, to_state='private')
            url = '{0}/edit'.format(obj.absolute_url())
            return self.request.response.redirect(url)

        raise ValueError('unknown state')
コード例 #4
0
    def handle_edit(self):
        obj = get_working_copy(self.context)

        # TODO: use the stagingbehavior API to get the best object, in all cases
        print "WC: ", obj
        print "Baseline: ", get_baseline(self.context)

        if obj is None:
            obj = self.context

        state = get_state(obj)

        if state == "private":
            url = "{0}/edit".format(obj.absolute_url())
            return self.request.response.redirect(url)

        elif state == "published":
            # create copy, go to it
            wc = self._checkout()
            url = "{0}/edit".format(wc.absolute_url())
            return self.request.response.redirect(url)

        elif state == "pending":
            # create copy, go to it
            transition(obj, to_state="private")
            url = "{0}/edit".format(obj.absolute_url())
            return self.request.response.redirect(url)

        raise ValueError("unknown state")
コード例 #5
0
    def render(self):
        print "WC: ", get_working_copy(self.context)
        print "Baseline: ", get_baseline(self.context)

        if not self.available():
            return ""
        return super(EditMenuViewlet, self).render()
コード例 #6
0
 def __init__( self, context, request ):
     self.context = context
     self.request = request
     if IBaseline.providedBy( self.context ):
         self.baseline = context
         self.working_copy = get_working_copy(context)
     elif IWorkingCopy.providedBy( self.context ):
         self.working_copy = context
         self.baseline = get_baseline(context)
     else:
         raise AttributeError("Invalid Context")
コード例 #7
0
ファイル: diff.py プロジェクト: quintagroup/plone.app.iterate
 def __init__( self, context, request ):
     self.context = context
     self.request = request
     if HAS_STAGINGBEHAVIOR and IIterateAware.providedBy(context):
         if IBaseline.providedBy( self.context ):
             self.baseline = get_baseline(context)
             self.working_copy = get_working_copy(context)
         elif IWorkingCopy.providedBy( self.context ):
             self.working_copy = get_working_copy(context)
             self.baseline = get_baseline(context)
         else:
             raise AttributeError("Invalid Context")
     else:
         if IBaseline.providedBy( self.context ):
             self.baseline = context
             self.working_copy = context.getBackReferences( WorkingCopyRelation.relationship )[0]
         elif IWorkingCopy.providedBy( self.context ):
             self.working_copy = context
             self.baseline = context.getReferences( WorkingCopyRelation.relationship )[0]
         else:
             raise AttributeError("Invalid Context")
コード例 #8
0
    def cancel_allowed(self):
        """ Check to see if the user can cancel the checkout on the
            given working copy.
            Conditions:
            - this is a working copy
            - the baseline exists
        """
        context = aq_inner( self.context )

        if context != get_working_copy( context ):
            return False

        if not get_baseline( context ):
            return False

        return True
コード例 #9
0
 def working_copy(self):
     return get_working_copy(self.context)
コード例 #10
0
 def has_working_copy(self):
     return get_working_copy(self.context) is not None
コード例 #11
0
 def working_copy(self):
     return get_working_copy(self.context)
コード例 #12
0
 def has_working_copy(self):
     return get_working_copy(self.context) is not None