Ejemplo n.º 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
Ejemplo n.º 2
0
    def checkin_allowed(self):
        """Check if a checkin is allowed
        """
        context = aq_inner(self.context)
        checkPermission = getSecurityManager().checkPermission

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

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

        if not IWorkingCopy.providedBy(context):
            return False

        policy = ICheckinCheckoutPolicy(context, None)
        if policy is None:
            return False

        original = policy.getBaseline()
        if original is None:
            return False

        can_modify = checkPermission(
            Products.CMFCore.permissions.ModifyPortalContent,
            original,
        )
        if not can_modify:
            return False

        return True
Ejemplo n.º 3
0
    def checkout_allowed(self):
        """Check if a checkout is allowed.
        """
        context = aq_inner(self.context)
        checkPermission = getSecurityManager().checkPermission

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

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

        policy = ICheckinCheckoutPolicy(context, None)
        if policy is None:
            return False

        if policy.getWorkingCopy() is not None:
            return False

        # check if its is a checkout
        if policy.getBaseline() is not None:
            return False

        can_check_out = checkPermission(permissions.CheckoutPermission,
                                        context)
        if not can_check_out:
            return False

        return True
Ejemplo n.º 4
0
    def checkout_allowed(self):
        """ Check if a checkout is allowed.
            Conditions:
            - provides IIterateAware
            - is versionable
            - there is no checkout
        """
        context = aq_inner( self.context )

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

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

        if get_checkout_relation( context ):
            return False

        return True
Ejemplo n.º 5
0
    def checkin_allowed(self):
        """Check if a checkin is allowed
        """
        context = aq_inner(self.context)
        checkPermission = getSecurityManager().checkPermission

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

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

        original = self.get_original(context)
        if original is None:
            return False

        if not checkPermission(permissions.CheckinPermission, original):
            return False

        return True
Ejemplo n.º 6
0
    def checkout_allowed(self):
        """Check if a checkout is allowed.
        """
        context = aq_inner(self.context)

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

        if not IReferenceable.providedBy(context):
            return False

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

        # check if there is an existing checkout
        if len(context.getBRefs(WorkingCopyRelation.relationship)) > 0:
            return False

        # check if its is a checkout
        if len(context.getRefs(WorkingCopyRelation.relationship)) > 0:
            return False

        return True
Ejemplo n.º 7
0
    def checkout_allowed(self):
        """Check if a checkout is allowed.
        """
        context = aq_inner(self.context)

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

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

        policy = ICheckinCheckoutPolicy(context, None)
        if policy is None:
            return False

        if policy.getWorkingCopy() is not None:
            return False

        # check if its is a checkout
        if policy.getBaseline() is not None:
            return False

        return True
Ejemplo n.º 8
0
def handleAfterCheckin(event):
    archiver = interfaces.IObjectArchiver(event.object)
    archiver.save(event.message)
Ejemplo n.º 9
0
def handleBeforeCheckout(event):
    archiver = interfaces.IObjectArchiver(event.object)
    if archiver.isModified() or not archiver.isVersioned():
        archiver.save("Baseline created")