def afterSetUp(self):
        notif_tool = self.portal.getNotificationTool()
        self._notif_config = dict(notif_tool.config)
        self._notifications = []
        self._subscriptions_to_remove = []
        self.patches = []
        self.object_timestamps = []

        divert_notifications(True, save_to=self._notifications)
        addNyFolder(self.portal, 'fol1', contributor='contributor')
        addNyFolder(self.portal, 'fol2', contributor='contributor')

        def get_modified_objects(site, when_start, when_end):
            for ob_path, modif_datetime in self.object_timestamps:
                if when_start < modif_datetime < when_end:
                    yield ('', site.unrestrictedTraverse(ob_path))

        self.patches.append(mock.patch(
            'Products.NaayaCore.NotificationTool.utils.get_modified_objects',
            get_modified_objects))

        transaction.commit()

        for patch in self.patches:  # Apply patches
            patch.start()
    def afterSetUp(self):
        notif_tool = self.portal.getNotificationTool()
        self._notif_config = dict(notif_tool.config)
        self._notifications = []
        self._subscriptions_to_remove = []
        self.patches = []
        self.object_timestamps = []

        divert_notifications(True, save_to=self._notifications)
        addNyFolder(self.portal, 'fol1', contributor='contributor')
        addNyFolder(self.portal, 'fol2', contributor='contributor')

        def get_modified_objects(site, when_start, when_end):
            for ob_path, modif_datetime in self.object_timestamps:
                if when_start < modif_datetime < when_end:
                    yield ('', site.unrestrictedTraverse(ob_path))

        self.patches.append(
            mock.patch(
                'Products.NaayaCore.NotificationTool.utils.get_modified_objects',
                get_modified_objects))

        transaction.commit()

        for patch in self.patches:  # Apply patches
            patch.start()
 def beforeTearDown(self):
     _notif = self.portal.portal_notification
     _notif.config.clear()
     _notif.config.update(self._original_config)
     _notif.config.update(self._original_config)
     self.portal.manage_delObjects(['notifol'])
     divert_notifications(False)
     transaction.commit()
 def beforeTearDown(self):
     _notif = self.portal.portal_notification
     _notif.config.clear()
     _notif.config.update(self._original_config)
     _notif.config.update(self._original_config)
     self.portal.manage_delObjects(['notifol'])
     divert_notifications(False)
     transaction.commit()
    def beforeTearDown(self):
        notif_tool = self.portal.getNotificationTool()
        notif_tool.config["enable_instant"] = False
        notif_tool.config["enable_weekly"] = False
        notif_tool.remove_account_subscription("contributor", "tforum", "instant", "en")
        notif_tool.remove_account_subscription("contributor", "tforum", "weekly", "en")
        self.portal.manage_delObjects(["tforum"])
        transaction.commit()

        divert_notifications(False)
    def beforeTearDown(self):
        notif_tool = self.portal.getNotificationTool()
        for args in self._subscriptions_to_remove:
            notif_tool.remove_account_subscription(*args)
        self.portal.manage_delObjects(['fol1', 'fol2'])
        notif_tool.config.update(self._notif_config)
        divert_notifications(False)

        for patch in self.patches: #Remove patches
            patch.stop()

        transaction.commit()
    def beforeTearDown(self):
        notif_tool = self.portal.getNotificationTool()
        for args in self._subscriptions_to_remove:
            notif_tool.remove_account_subscription(*args)
        self.portal.manage_delObjects(['fol1', 'fol2'])
        notif_tool.config.update(self._notif_config)
        divert_notifications(False)

        for patch in self.patches:  # Remove patches
            patch.stop()

        transaction.commit()
示例#8
0
    def beforeTearDown(self):
        notif_tool = self.portal.getNotificationTool()
        notif_tool.config['enable_instant'] = False
        notif_tool.config['enable_weekly'] = False
        notif_tool.remove_account_subscription('contributor', 'tforum',
                                               'instant', 'en')
        notif_tool.remove_account_subscription('contributor', 'tforum',
                                               'weekly', 'en')
        self.portal.manage_delObjects(['tforum'])
        transaction.commit()

        divert_notifications(False)
    def afterSetUp(self):
        notif_tool = self.portal.getNotificationTool()
        self._notif_config = dict(notif_tool.config)
        self._notifications = []
        self._subscriptions_to_remove = []
        self.patches = []
        self.object_timestamps = []

        divert_notifications(True, save_to=self._notifications)
        addNyFolder(self.portal, 'fol1', contributor='contributor')
        addNyFolder(self.portal, 'fol2', contributor='contributor')

        def _get_template(self, template_name):
            """ Replacement for _get_template """
            def single_tmpl(ob, person, portal, **kwargs):
                return {'subject': 'notifications',
                        'body_text': 'instant [%s] %s' %
                            (path_in_site(ob), portal.title_or_id())}

            def group_tmpl(portal, objs, **kwargs):
                keyer = lambda item: path_in_site(item['ob'])
                sorted_items = sorted(objs, key=keyer)
                items_str = ''.join('[%s]' % path_in_site(item['ob']) for
                                    item in sorted_items)
                body = '%s %s %s' % (template_name, items_str,
                                     portal.title_or_id())
                return {'subject': 'notifications', 'body_text': body}

            if template_name == 'instant':
                return single_tmpl
            else:
                return group_tmpl

        self.patches.append(mock.patch(
            'Products.NaayaCore.NotificationTool.NotificationTool.'
            'NotificationTool._get_template', _get_template))


        def get_modified_objects(site, when_start, when_end):
            for ob_path, modif_datetime in self.object_timestamps:
                if when_start < modif_datetime < when_end:
                    yield site.unrestrictedTraverse(ob_path)

        self.patches.append(mock.patch(
            'Products.NaayaCore.NotificationTool.utils.get_modified_objects',
            get_modified_objects))

        transaction.commit()

        for patch in self.patches: #Apply patches
            patch.start()
    def afterSetUp(self):
        notif_tool = self.portal.getNotificationTool()
        self._notif_config = dict(notif_tool.config)
        self._notifications = []
        self._subscriptions_to_remove = []
        self.patches = []
        self.object_timestamps = []

        divert_notifications(True, save_to=self._notifications)
        addNyFolder(self.portal, 'fol1', contributor='contributor')
        addNyFolder(self.portal, 'fol2', contributor='contributor')

        #def _get_template(self, template_name):
        #    """ Replacement for _get_template """
        #    def single_tmpl(ob, person, portal, **kwargs):
        #        return {'subject': 'notifications',
        #                'body_text': 'instant [%s] %s' %
        #                    (path_in_site(ob), portal.title_or_id())}

        #    def group_tmpl(portal, objs, **kwargs):
        #        keyer = lambda item: path_in_site(item['ob'])
        #        sorted_items = sorted(objs, key=keyer)
        #        items_str = ''.join('[%s]' % path_in_site(item['ob']) for
        #                            item in sorted_items)
        #        body = '%s %s %s' % (template_name, items_str,
        #                             portal.title_or_id())
        #        return {'subject': 'notifications', 'body_text': body}

        #    if template_name == 'instant':
        #        return single_tmpl
        #    else:
        #        return group_tmpl

        #self.patches.append(mock.patch(
        #    'Products.NaayaCore.NotificationTool.NotificationTool.'
        #    'NotificationTool._get_template', _get_template))


        def get_modified_objects(site, when_start, when_end):
            for ob_path, modif_datetime in self.object_timestamps:
                if when_start < modif_datetime < when_end:
                    yield ('', site.unrestrictedTraverse(ob_path))

        self.patches.append(mock.patch(
            'Products.NaayaCore.NotificationTool.utils.get_modified_objects',
            get_modified_objects))

        transaction.commit()

        for patch in self.patches: #Apply patches
            patch.start()
    def afterSetUp(self):
        self._notifications = []
        divert_notifications(True, self._notifications)

        addNyForum(self.portal, id="tforum", title="My Forum")
        tforum = self.portal["tforum"]
        addNyForumTopic(tforum, id="ttopic", title="My Topic")
        addNyForumMessage(tforum["ttopic"], id="tmessage", title="My Message")
        notif_tool = self.portal.getNotificationTool()
        notif_tool.config["enable_instant"] = True
        notif_tool.config["enable_weekly"] = True
        notif_tool.add_account_subscription("contributor", "tforum", "instant", "en")
        notif_tool.add_account_subscription("contributor", "tforum", "weekly", "en")
        transaction.commit()
    def afterSetUp(self):
        self._notifications = []
        divert_notifications(True, save_to=self._notifications)
        addNyFolder(self.portal, 'notifol', contributor='contributor', submitted=1)
        addNyDocument(self.portal.notifol, id='notidoc',
            title='Notifying document', submitted=1, contributor='contributor')
        self.portal.notifol.notidoc.approved = True # Approve this document

        _notif = self.portal.getNotificationTool()
        self._original_config = dict(_notif.config)
        _notif.config['enable_instant'] = True
        _notif.config['enable_daily'] = True
        _notif.config['enable_weekly'] = True
        _notif.config['enable_monthly'] = True
        transaction.commit()
示例#13
0
    def afterSetUp(self):
        self._notifications = []
        divert_notifications(True, self._notifications)

        addNyForum(self.portal, id='tforum', title='My Forum')
        tforum = self.portal['tforum']
        addNyForumTopic(tforum, id='ttopic', title='My Topic')
        addNyForumMessage(tforum['ttopic'], id='tmessage', title='My Message')
        notif_tool = self.portal.getNotificationTool()
        notif_tool.config['enable_instant'] = True
        notif_tool.config['enable_weekly'] = True
        notif_tool.add_account_subscription('contributor', 'tforum', 'instant',
                                            'en')
        notif_tool.add_account_subscription('contributor', 'tforum', 'weekly',
                                            'en')
        transaction.commit()
    def afterSetUp(self):
        self._notifications = []
        divert_notifications(True, save_to=self._notifications)

        #Login with admin and set skip_notifications in administration
        self.browser_do_login('admin', '')
        self.browser.go('http://localhost/portal/portal_notification/admin_html')
        form = self.browser.get_form('skip_notifications')
        self.browser.clicked(form,
            self.browser.get_form_field(form, 'submit-button'))
        self.browser.submit()

        #create folders and other content in browser, so the skip_notification
        #flag will be respected (the REQUEST.SESSION is checked for it)
        self.browser.go('http://localhost/portal/folder_add_html')
        form = self.browser.get_form('frmAdd')
        self.browser.clicked(form,
            self.browser.get_form_field(form, 'title:utf8:ustring'))
        form['title:utf8:ustring'] = 'notifol'
        self.browser.submit()

        addNyDocument(self.portal.notifol, id='notidoc',
            title='Notifying document', submitted=1, contributor='contributor')
        self.portal.notifol.notidoc.approved = True # Approve this document

        _notif = self.portal.getNotificationTool()
        self._original_config = dict(_notif.config)
        _notif.config['enable_instant'] = True
        _notif.config['enable_daily'] = True
        _notif.config['enable_weekly'] = True
        _notif.config['enable_monthly'] = True
        transaction.commit()

        #Unset skip_notifications in administration
        self.browser.go('http://localhost/portal/portal_notification/admin_html')
        form = self.browser.get_form('skip_notifications')
        self.browser.clicked(form,
            self.browser.get_form_field(form, 'submit-button'))
        self.browser.submit()
        self.browser_do_logout()
示例#15
0
        header = ['User', 'Location', 'Notification type', 'Language']
        rows = []
        for s in self.admin_get_subscriptions():
            row = []
            row.append(s['user'])
            if (s['location']):
                row.append(s['location'])
            else:
                row.append('entire portal')
            row.append(s['notif_type'])
            row.append(s['lang'])
            rows.append(row)

        file_type = REQUEST.get('file_type', 'CSV')
        if file_type == 'CSV':
            RESPONSE.setHeader('Content-Type', 'text/csv')
            RESPONSE.setHeader('Content-Disposition',
                               'attachment; filename=subscriptions.csv')
            return generate_csv(header, rows)
        if file_type == 'Excel' and self.rstk['we_provide']('Excel export'):
            RESPONSE.setHeader('Content-Type', 'application/vnd.ms-excel')
            RESPONSE.setHeader('Content-Disposition',
                               'attachment; filename=subscriptions.xls')
            return generate_excel(header, rows)
        else:
            raise ValueError('unknown file format %r' % file_type)

InitializeClass(NotificationTool)
utils.divert_notifications(False)
示例#16
0
        header = ['User', 'Location', 'Notification type', 'Language']
        rows = []
        for s in self.admin_get_subscriptions():
            row = []
            row.append(s['user'])
            if (s['location']):
                row.append(s['location'])
            else:
                row.append('entire portal')
            row.append(s['notif_type'])
            row.append(s['lang'])
            rows.append(row)

        file_type = REQUEST.get('file_type', 'CSV')
        if file_type == 'CSV':
            RESPONSE.setHeader('Content-Type', 'text/csv')
            RESPONSE.setHeader('Content-Disposition',
                               'attachment; filename=subscriptions.csv')
            return generate_csv(header, rows)
        if file_type == 'Excel' and self.rstk['we_provide']('Excel export'):
            RESPONSE.setHeader('Content-Type', 'application/vnd.ms-excel')
            RESPONSE.setHeader('Content-Disposition',
                               'attachment; filename=subscriptions.xls')
            return generate_excel(header, rows)
        else:
            raise ValueError('unknown file format %r' % file_type)


InitializeClass(NotificationTool)
utils.divert_notifications(False)