def update(self): """ When updating we may want to process the form data and, if needed, create a post """ if self.is_posting and self.post_text: self.post = self.create_post() # BBB We're using the ActivityProvider from ps.activitystream # here for rendering the (singular) status post that was just # created. While this enables posting by 1) placing the post into # the post-container and 2) returning the rendered post so that it # can be injected into the page without a reload, fetching this # adapter is overly complex. # Therefore this will be replaced by a browser view that renders # both the form for posting a status update and, conditionally, # the new post itself. self.activity_providers = [ getMultiAdapter((IStatusActivity( self.post), self.request, self.__parent__.view), IActivityProvider) ] self.activity_provider = self.activity_providers[0] else: self.post = None self.activity_providers = [] self.activity_provider = None
def parent_provider(self): container = PLONESOCIAL.microblog if not container: return parent = container.get(self.context.thread_id) return getMultiAdapter( (IStatusActivity(parent), self.request, self.view), IActivityProvider)
def activities(self): container = PLONESOCIAL.microblog if not container: return [] return [ IStatusActivity(item) for item in container.thread_values(self.thread_id) ]
def _activity_visible(self, activity): if IStatusActivity.providedBy(activity) and self.show_microblog: return True elif IContentActivity.providedBy(activity) and self.show_content: return True elif IDiscussionActivity.providedBy(activity) and self.show_discussion: return True return False
def can_view(self, activity): """Returns true if current user has the 'View' permission. """ sm = getSecurityManager() if IStatusActivity.providedBy(activity): permission = "Plone Social: View Microblog Status Update" return sm.checkPermission(permission, self.context) elif IDiscussionActivity.providedBy(activity): # check both the activity itself and it's page context return sm.checkPermission( 'View', aq_inner(activity.context)) \ and sm.checkPermission( 'View', aq_inner(activity.context).__parent__.__parent__) elif IContentActivity.providedBy(activity): return sm.checkPermission('View', aq_inner(activity.context))