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()
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
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')
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")
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")
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")
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
def baseline(self): return get_baseline(self.context)
def _getBaseline( self ): baseline = get_baseline( self.context ) if not baseline: raise iterate.interfaces.CheckinException( "Baseline has disappeared" ) return baseline
def _getBaseline(self): baseline = get_baseline(self.context) if not baseline: raise iterate.interfaces.CheckinException( "Baseline has disappeared") return baseline