def send_notifications_for_event(event, subscriber_data_default, template): """Send notifications to site maintainers and subscribers. Create event handler must be supressed when this action is run. """ folder = event.context portal = folder.getSite() notification_tool = portal.getNotificationTool() action_logger = portal.getActionLogger() subscribers_data = {} maintainers_data = {} #Get maintainers maintainers = portal.getMaintainersEmails(folder) for email in maintainers: data = dict(subscriber_data_default) data.update({ 'ob': folder, 'here': notification_tool, }) maintainers_data[email] = data #Get subscribers if notification_tool.config['enable_instant'] is True: subscribers_data = utils.get_subscribers_data(notification_tool, folder, **subscriber_data_default) subscribers_data.update(maintainers_data) notification_tool._send_notifications(subscribers_data, template.render_email) #Create log entry action_logger.create(type=constants.LOG_TYPES['bulk_import'], path=path_in_site(folder))
def notify_administrative(self, ob, user_id, ob_edited=False): """ send administrative notifications because object `ob` was added or edited by the user `user_id` """ auth_tool = self.getSite().getAuthenticationTool() subscribers_data = utils.get_subscribers_data(self, ob, notif_type='administrative', **{ 'person': auth_tool.name_from_userid(user_id), 'ob_edited': ob_edited, 'approved': ob.approved, 'container_basket': '%s/basketofapprovals_html' % ob.aq_parent.absolute_url(), }) if len(subscribers_data.keys()) > 0: notif_logger.info('Administrative notifications on %r', ofs_path(ob)) template = self._get_template('administrative') self._send_notifications(subscribers_data, template)
def notify_comment_administrative(self, comment, parent, user_id): """ send administrative notifications because a comment was added to object `ob` by the user `user_id` """ auth_tool = self.getSite().getAuthenticationTool() subscribers_data = utils.get_subscribers_data(self, parent, notif_type='administrative', **{ 'comment': comment, 'parent': parent, 'here': self, 'person': auth_tool.name_from_userid(user_id), }) if len(subscribers_data.keys()) > 0: notif_logger.info('Administrative comment notifications on %r', ofs_path(parent)) template = self._get_template('administrative') self._send_notifications(subscribers_data, template)
def notify_instant(self, ob, user_id, ob_edited=False): """ send instant notifications because object `ob` was changed by the user `user_id` """ notif_logger.info('Instant notifications on %r', ofs_path(ob)) if not self.config['enable_instant']: return #Don't send notifications if the object is unapproved, but store them #into a queue to send them later when it becomes approved if not ob.approved: return subscribers_data = utils.get_subscribers_data(self, ob, **{ 'person': user_id, 'ob_edited': ob_edited, }) template = self._get_template('instant') self._send_notifications(subscribers_data, template)
def notify_instant(self, ob, user_id, ob_edited=False): """ send instant notifications because object `ob` was changed by the user `user_id` """ if not self.config['enable_instant']: return #Don't send notifications if the object is unapproved, but store them #into a queue to send them later when it becomes approved if not ob.approved: return auth_tool = self.getSite().getAuthenticationTool() subscribers_data = utils.get_subscribers_data(self, ob, **{ 'person': auth_tool.name_from_userid(user_id), 'ob_edited': ob_edited, }) if len(subscribers_data.keys()) > 0: notif_logger.info('Instant notifications on %r', ofs_path(ob)) template = self._get_template('instant') self._send_notifications(subscribers_data, template)
def notify_comment_instant(self, comment, parent, user_id): """ send instant notifications because a comment was added to object `ob` by the user `user_id` """ if not self.config['enable_instant']: return #Don't send notifications if the object is unapproved, but store them #into a queue to send them later when it becomes approved if not parent.approved: return auth_tool = self.getSite().getAuthenticationTool() subscribers_data = utils.get_subscribers_data(self, parent, **{ 'comment': comment, 'parent': parent, 'person': auth_tool.name_from_userid(user_id), }) if len(subscribers_data.keys()) > 0: notif_logger.info('Comment instant notifications on %r', ofs_path(parent)) template = self._get_template('instant') self._send_notifications(subscribers_data, template)