def afterSetUp(self):
        addNyFolder(self.portal, 'myfolder', contributor='admin', submitted=1)
        start_date = (date.today() - timedelta(days=1)).strftime('%d/%m/%Y')
        end_date = (date.today() + timedelta(days=10)).strftime('%d/%m/%Y')
        addNyTalkBackConsultation(self.portal.myfolder,
                                  title="Test consultation",
                                  start_date=start_date,
                                  end_date=end_date,
                                  contributor='admin',
                                  submitted=1)
        consultation = self.portal.myfolder['test-consultation']

        consultation.addSection(
            id='test-section',
            title='Test section',
            body='<p>First paragraph</p><p>Second paragraph</p>')

        consultation.invitations._send_invitation(
            name='The Invitee',
            email='*****@*****.**',
            organization='Thinkle University',
            notes='Knows his shit',
            inviter_userid='contributor',
            inviter_name='Contributor Test',
            message='')
        self.invite_key = consultation.invitations._invites.values()[0].key

        comments = []
        paragraph_000 = consultation['test-section']['000']
        # comment 0
        id0 = addComment(paragraph_000,
                         contributor='contributor',
                         message=u'comment by contributor (0)')
        comments.append(paragraph_000[id0])

        # comment 1
        id1 = addComment(consultation['test-section']['000'],
                         contributor='invite:' + self.invite_key,
                         message=u'invitee comment (1)',
                         approved=False)
        comments.append(paragraph_000[id1])

        transaction.commit()

        self.comments = comments
        self.consultation = self.portal.myfolder['test-consultation']
        self.diverted_mail = divert_mail()
        self.cons_url = 'http://localhost/portal/myfolder/test-consultation'
Beispiel #2
0
    def test_approve(self):
        comment_id = addComment(self.consultation['test-section']['000'],
                                contributor='invite:' + self.invite_key,
                                message=u'invitee comment',
                                approved=False)
        transaction.commit()
        paragraph_url = self.cons_url + '/test-section/000'
        approve_url = paragraph_url + '/' + comment_id + '/approve'

        comment = self.consultation['test-section']['000'][comment_id]
        self.assertFalse(comment.approved)

        self.browser_do_login('contributor', 'contributor')

        self.browser.go(paragraph_url)
        for form in self.browser._browser.forms():
            if form.action == approve_url:
                break
        else:
            self.fail('Could not find approve form')
        self.browser.clicked(form, form.controls[0])
        self.browser.submit()

        self.assertTrue(comment.approved)
        self.assertEqual(self.browser.get_url(), paragraph_url)

        self.browser.go(paragraph_url)
        for form in self.browser._browser.forms():
            if form.action == approve_url:
                self.fail('no comments should be awaiting approval')

        self.browser_do_logout()
Beispiel #3
0
    def test_hide_unapproved(self):
        comment_id = addComment(self.consultation['test-section']['000'],
                                contributor='invite:' + self.invite_key,
                                message=u'invitee comment',
                                approved=False)
        transaction.commit()

        self.browser.go(self.cons_url + '/test-section/000')
        html = self.browser.get_html()
        self.assertFalse('The Invitee (invited by Contributor Test)' in html)
        self.assertFalse('invitee comment' in html)
        self.assertFalse('This comment is awaiting approval' in html)

        self.browser.go(self.cons_url + '/invitations/welcome?key=' +
                        self.invite_key)
        self.browser.go(self.cons_url + '/test-section/000')
        html = self.browser.get_html()
        self.assertTrue('The Invitee (invited by Contributor Test)' in html)
        self.assertTrue('invitee comment' in html)
        self.assertTrue('This comment is awaiting approval' in html)

        comment = self.consultation['test-section']['000'][comment_id]
        comment.approved = True
        transaction.commit()

        self.browser.go(self.cons_url + '/test-section/000')
        html = self.browser.get_html()
        self.assertTrue('The Invitee (invited by Contributor Test)' in html)
        self.assertTrue('invitee comment' in html)
        self.assertFalse('This comment is awaiting approval' in html)
Beispiel #4
0
    def test_approve(self):
        comment_id = addComment(self.consultation['test-section']['000'],
                                contributor='invite:' + self.invite_key,
                                message=u'invitee comment',
                                approved=False)
        transaction.commit()
        paragraph_url = self.cons_url + '/test-section/000'
        approve_url = paragraph_url + '/' + comment_id + '/approve'

        comment = self.consultation['test-section']['000'][comment_id]
        self.assertFalse(comment.approved)

        self.browser_do_login('contributor', 'contributor')

        self.browser.go(paragraph_url)
        for form in self.browser._browser.forms():
            if form.action == approve_url:
                break
        else:
            self.fail('Could not find approve form')
        self.browser.clicked(form, form.controls[0])
        self.browser.submit()

        self.assertTrue(comment.approved)
        self.assertEqual(self.browser.get_url(), paragraph_url)

        self.browser.go(paragraph_url)
        for form in self.browser._browser.forms():
            if form.action == approve_url:
                self.fail('no comments should be awaiting approval')

        self.browser_do_logout()
Beispiel #5
0
    def test_hide_unapproved(self):
        comment_id = addComment(self.consultation['test-section']['000'],
                                contributor='invite:' + self.invite_key,
                                message=u'invitee comment',
                                approved=False)
        transaction.commit()

        self.browser.go(self.cons_url + '/test-section/000')
        html = self.browser.get_html()
        self.assertFalse('The Invitee (invited by Contributor Test)' in html)
        self.assertFalse('invitee comment' in html)
        self.assertFalse('This comment is awaiting approval' in html)

        self.browser.go(self.cons_url + '/invitations/welcome?key=' + self.invite_key)
        self.browser.go(self.cons_url + '/test-section/000')
        html = self.browser.get_html()
        self.assertTrue('The Invitee (invited by Contributor Test)' in html)
        self.assertTrue('invitee comment' in html)
        self.assertTrue('This comment is awaiting approval' in html)

        comment = self.consultation['test-section']['000'][comment_id]
        comment.approved = True
        transaction.commit()

        self.browser.go(self.cons_url + '/test-section/000')
        html = self.browser.get_html()
        self.assertTrue('The Invitee (invited by Contributor Test)' in html)
        self.assertTrue('invitee comment' in html)
        self.assertFalse('This comment is awaiting approval' in html)
Beispiel #6
0
    def afterSetUp(self):
        addNyFolder(self.portal, 'myfolder', contributor='admin', submitted=1)
        start_date = (date.today() - timedelta(days=1)).strftime('%d/%m/%Y')
        end_date = (date.today() + timedelta(days=10)).strftime('%d/%m/%Y')
        addNyTalkBackConsultation(self.portal.myfolder, title="Test consultation",
            start_date=start_date, end_date=end_date,
            contributor='admin', submitted=1)
        consultation = self.portal.myfolder['test-consultation']

        consultation.addSection(
            id='test-section', title='Test section',
            body='<p>First paragraph</p><p>Second paragraph</p>')

        consultation.invitations._send_invitation(
            name='The Invitee', email='*****@*****.**',
            organization='Thinkle University', notes='Knows his shit',
            inviter_userid='contributor', inviter_name='Contributor Test', message='')
        self.invite_key = consultation.invitations._invites.values()[0].key

        comments = []
        paragraph_000 = consultation['test-section']['000']
        # comment 0
        id0 = addComment(paragraph_000,
                         contributor='contributor',
                         message=u'comment by contributor (0)')
        comments.append(paragraph_000[id0])

        # comment 1
        id1 = addComment(consultation['test-section']['000'],
                         contributor='invite:' + self.invite_key,
                         message=u'invitee comment (1)', approved=False)
        comments.append(paragraph_000[id1])

        transaction.commit()

        self.comments = comments
        self.consultation = self.portal.myfolder['test-consultation']
        self.diverted_mail = divert_mail()
        self.cons_url = 'http://localhost/portal/myfolder/test-consultation'
Beispiel #7
0
    def test_edit_comment(self):
        comment_id = addComment(self.section['000'],
            contributor='contributor', message='original comment')
        transaction.commit()

        self.browser_do_login('admin', '')

        self.browser.go('%s/000/%s/edit_html' % (self.section_url, comment_id))
        form = self.browser.get_form('frmEdit')
        self.assertEqual(form['message:utf8:ustring'], 'original comment')
        form['message:utf8:ustring'] = 'modified comment'
        self.browser.clicked(form, form.find_control('message:utf8:ustring'))
        self.browser.submit()

        self.assertEqual(self.section['000'][comment_id].message, 'modified comment')

        self.browser_do_logout()
Beispiel #8
0
    def test_edit_comment(self):
        comment_id = addComment(self.section['000'],
                                contributor='contributor',
                                message='original comment')
        transaction.commit()

        self.browser_do_login('admin', '')

        self.browser.go('%s/000/%s/edit_html' % (self.section_url, comment_id))
        form = self.browser.get_form('frmEdit')
        self.assertEqual(form['message:utf8:ustring'], 'original comment')
        form['message:utf8:ustring'] = 'modified comment'
        self.browser.clicked(form, form.find_control('message:utf8:ustring'))
        self.browser.submit()

        self.assertEqual(self.section['000'][comment_id].message,
                         'modified comment')

        self.browser_do_logout()
Beispiel #9
0
    def test_threaded_comments(self):
        comment1_id = addComment(self.section['000'],
                                 contributor='contributor',
                                 message='original comment')
        transaction.commit()

        self.browser_do_login('contributor', 'contributor')

        self.browser.go('%s/000?reply_to=%s' % (self.section_url, comment1_id))
        form = self.browser.get_form('frmAdd')
        self.assertEqual(form['reply_to'], comment1_id)
        self.assertEqual(
            form['message:utf8:ustring'],
            '<p></p><blockquote>original comment</blockquote><p></p>')
        form['message:utf8:ustring'] = (
            '<p>\n&nbsp;\n</p>\n'
            '<blockquote>original comment</blockquote>\n'
            '<p>\n&nbsp;\n</p>')
        self.browser.clicked(form, form.find_control('message:utf8:ustring'))
        self.browser.submit()

        comment2_id = (set(self.section['000'].objectIds()) -
                       set([comment1_id])).pop()
        comment2 = self.section['000'][comment2_id]
        self.assertEqual(comment2.reply_to, comment1_id)
        self.assertEqual(comment2.message,
                         '<blockquote>original comment</blockquote>')

        # make sure we can't add a reply to a non-existent comment
        self.browser.go('%s/000?reply_to=%s' % (self.section_url, comment1_id))
        self.section['000'].manage_delObjects([comment1_id])
        transaction.commit()
        form = self.browser.get_form('frmAdd')
        self.browser.clicked(form, form.find_control('message:utf8:ustring'))
        self.browser.submit()

        self.assertEqual(
            len(self.section['000'].objectIds()), 1,
            'Should not have created comment with bogus '
            '`reply_to` value')

        self.browser_do_logout()
Beispiel #10
0
    def test_invited_comments_admin(self):
        comment_id = addComment(self.consultation['test-section']['000'],
                                contributor='invite:' + self.invite_key,
                                message=u'invitee comment')
        transaction.commit()

        self.browser_do_login('contributor', 'contributor')

        edit_url = '%s/test-section/000/%s/edit_html' % (self.cons_url, comment_id)
        self.browser.go('%s/test-section/000' % self.cons_url)
        self.assertTrue(edit_url in self.browser.get_html())

        self.browser.go(edit_url)
        self.assertRedirectUnauthorizedPage(False)

        form = self.browser.get_form('frmEdit')
        form['message:utf8:ustring'] = 'edited'
        self.browser.clicked(form, form.find_control('message:utf8:ustring'))
        self.browser.submit()
        self.assertRedirectUnauthorizedPage(False)

        self.browser_do_logout()
Beispiel #11
0
    def test_threaded_comments(self):
        comment1_id = addComment(self.section['000'],
            contributor='contributor', message='original comment')
        transaction.commit()

        self.browser_do_login('contributor', 'contributor')

        self.browser.go('%s/000?reply_to=%s' % (self.section_url, comment1_id))
        form = self.browser.get_form('frmAdd')
        self.assertEqual(form['reply_to'], comment1_id)
        self.assertEqual(form['message:utf8:ustring'],
                         '<p></p><blockquote>original comment</blockquote><p></p>')
        form['message:utf8:ustring'] = ('<p>\n&nbsp;\n</p>\n'
                                        '<blockquote>original comment</blockquote>\n'
                                        '<p>\n&nbsp;\n</p>')
        self.browser.clicked(form, form.find_control('message:utf8:ustring'))
        self.browser.submit()

        comment2_id = ( set(self.section['000'].objectIds()) -
                        set([comment1_id])
                      ).pop()
        comment2 = self.section['000'][comment2_id]
        self.assertEqual(comment2.reply_to, comment1_id)
        self.assertEqual(comment2.message, '<blockquote>original comment</blockquote>')

        # make sure we can't add a reply to a non-existent comment
        self.browser.go('%s/000?reply_to=%s' % (self.section_url, comment1_id))
        self.section['000'].manage_delObjects([comment1_id])
        transaction.commit()
        form = self.browser.get_form('frmAdd')
        self.browser.clicked(form, form.find_control('message:utf8:ustring'))
        self.browser.submit()

        self.assertEqual(len(self.section['000'].objectIds()), 1,
                         'Should not have created comment with bogus '
                         '`reply_to` value')

        self.browser_do_logout()
Beispiel #12
0
    def test_invited_comments_admin(self):
        comment_id = addComment(self.consultation['test-section']['000'],
                                contributor='invite:' + self.invite_key,
                                message=u'invitee comment')
        transaction.commit()

        self.browser_do_login('contributor', 'contributor')

        edit_url = '%s/test-section/000/%s/edit_html' % (self.cons_url,
                                                         comment_id)
        self.browser.go('%s/test-section/000' % self.cons_url)
        self.assertTrue(edit_url in self.browser.get_html())

        self.browser.go(edit_url)
        self.assertRedirectUnauthorizedPage(False)

        form = self.browser.get_form('frmEdit')
        form['message:utf8:ustring'] = 'edited'
        self.browser.clicked(form, form.find_control('message:utf8:ustring'))
        self.browser.submit()
        self.assertRedirectUnauthorizedPage(False)

        self.browser_do_logout()