def _activities_statuses(self): if not self.show_microblog: return [] container = PLONESOCIAL.microblog # show_microblog yet no container can happen on microblog uninstall if not container: return [] try: if self.users: # support plonesocial.network integration return container.user_values(self.users, limit=self.count, tag=self.tag) else: # default implementation microblog_context = get_microblog_context(self.context) if microblog_context: return container.context_values(microblog_context, limit=self.count, tag=self.tag) else: return container.values(limit=self.count, tag=self.tag, ) except Unauthorized: return []
def _activities_brains(self): if not self.show_content and not self.show_discussion: return [] catalog = getToolByName(self.context, 'portal_catalog') # fetch more than we need because of later filtering contentfilter = dict(sort_on='Date', sort_order='reverse', sort_limit=self.count * 10) microblog_context = get_microblog_context(self.context) if microblog_context: contentfilter['path'] = '/'.join(microblog_context.getPhysicalPath()) if self.tag: contentfilter["Subject"] = self.tag if self.users: contentfilter["Creator"] = self.users return catalog.searchResults(**contentfilter)
def handleComment(self, action): # Validation form data, errors = self.extractData() if errors: return container = queryUtility(IMicroblogTool) microblog_context = get_microblog_context(self.context) status = StatusUpdate(data['text'], context=microblog_context) # debugging only # container.clear() # save the status update container.add(status) # Redirect to portal home self.request.response.redirect(self.action)
def handleComment(self, action): # Validation form data, errors = self.extractData() if errors: return container = queryUtility(IMicroblogTool) microblog_context = get_microblog_context(self.context) if hasattr(self.context, 'thread_id') and self.context.thread_id: thread_id = self.context.thread_id # threaded elif self.context.__class__.__name__ == 'StatusUpdate': thread_id = self.context.id # first reply else: thread_id = None # new status = StatusUpdate(data['text'], context=microblog_context, thread_id=thread_id) file_upload = self.request.get('form.widgets.attachments') attachments_supported = (IAttachmentStoragable is not None and IAttachmentStoragable.providedBy(status)) if attachments_supported and file_upload: token = self.request.get('attachment-form-token') extract_and_add_attachments(file_upload, status, workspace=self.context, token=token) # debugging only # container.clear() # save the status update container.add(status) # Redirect to portal home self.request.response.redirect(self.action)
def handleComment(self, action): # Validation form data, errors = self.extractData() if errors: return container = queryUtility(IMicroblogTool) microblog_context = get_microblog_context(self.context) if hasattr(self.context, 'thread_id') and self.context.thread_id: thread_id = self.context.thread_id # threaded elif self.context.__class__.__name__ == 'StatusUpdate': thread_id = self.context.id # first reply else: thread_id = None # new status = StatusUpdate(data['text'], context=microblog_context, thread_id=thread_id) file_upload = self.request.get('form.widgets.attachments') attachments_supported = ( IAttachmentStoragable is not None and IAttachmentStoragable.providedBy(status)) if attachments_supported and file_upload: token = self.request.get('attachment-form-token') extract_and_add_attachments( file_upload, status, workspace=self.context, token=token) # debugging only # container.clear() # save the status update container.add(status) # Redirect to portal home self.request.response.redirect(self.action)
def context(self, context): if HAVE_PLONESOCIAL_MICROBLOG: return get_microblog_context(context) else: return None
def post_context(self): """ The context of this microblog post (the portal, a workspace, and so on...) """ return get_microblog_context(self.context)