Esempio n. 1
0
 def handle_add(self, action):
     data, errors = self.extractData()
     if not errors:
         phandler = IParticipationAware(self.context)
         part = phandler.create_participation(**data)
         phandler.append_participiation(part)
         status = IStatusMessage(self.request)
         msg = _(u'info_participation_create', u'Participation created.')
         status.addStatusMessage(msg, type='info')
         return self._redirect_to_participants_tab()
Esempio n. 2
0
 def handle_add(self, action):
     data, errors = self.extractData()
     if not errors:
         phandler = IParticipationAware(self.context)
         part = phandler.create_participation(**data)
         phandler.append_participiation(part)
         status = IStatusMessage(self.request)
         msg = _(u'info_participation_create',
                 u'Participation created.')
         status.addStatusMessage(msg, type='info')
         return self._redirect_to_participants_tab()
Esempio n. 3
0
    def test_participant_labels_are_displayed(self, browser):
        self.login(self.regular_user, browser=browser)

        handler = IParticipationAware(self.dossier)
        participation = handler.create_participation(contact='robert.ziegler',
                                                     roles=['regard'])
        handler.append_participiation(participation)

        browser.open(self.dossier, view='tabbedview_view-overview')
        self.assertEqual(
            ['Ziegler Robert (robert.ziegler)'],
            browser.css('#participantsBox li:not(.moreLink) a').text)
Esempio n. 4
0
    def test_participant_labels_are_displayed(self, browser):
        self.login(self.regular_user, browser=browser)

        handler = IParticipationAware(self.tested_dossier)
        participation = handler.create_participation(contact='kathi.barfuss',
                                                     roles=['regard'])
        handler.append_participiation(participation)

        browser.open(self.tested_dossier, view='tabbedview_view-overview')
        self.assertListEqual(
            self.participants,
            browser.css('#participantsBox li:not(.moreLink) a').text)
Esempio n. 5
0
    def test_participant_labels_are_displayed(self, browser):
        self.login(self.regular_user, browser=browser)

        handler = IParticipationAware(self.tested_dossier)
        participation = handler.create_participation(
            contact='kathi.barfuss', roles=['regard'])
        handler.append_participiation(participation)

        browser.open(self.tested_dossier,
                     view='tabbedview_view-overview')
        self.assertListEqual(
            self.participants,
            browser.css('#participantsBox li:not(.moreLink) a').text)
class TestDossierMigratorForParticipants(FunctionalTestCase):

    def setUp(self):
        super(TestDossierMigratorForParticipants, self).setUp()
        self.portal = self.layer['portal']

        create(Builder('ogds_user').id('old.participant'))
        create(Builder('ogds_user').id('new.participant'))

        self.dossier = create(Builder('dossier')
                              .titled(u'Testdossier'))

        self.phandler = IParticipationAware(self.dossier)
        p = self.phandler.create_participation('old.participant', ['regard'])
        self.phandler.append_participiation(p)

    def test_dossier_participation_gets_migrated(self):

        migrator = DossierMigrator(
            self.portal, {'old.participant': 'new.participant'}, 'move')
        migrator.migrate()

        self.assertEquals('new.participant',
                          self.phandler.get_participations()[0].contact)

    def test_contacts_dont_match_principal_mapping(self):
        # Create a contact with the same name as a mapped user in order to
        # verify the mapping doesn't match the contact.id
        contact = create(Builder('contact')
                         .having(firstname='contact',
                                 lastname='old'))

        # Create a participation using that contact
        p = self.phandler.create_participation(contact.contactid(), ['regard'])
        self.phandler.append_participiation(p)

        migrator = DossierMigrator(self.portal, {contact.id: 'new'}, 'move')
        migrator.migrate()

        # Should not have been migrated, participation should still refer
        # to contact:old-contact
        self.assertEquals('contact:old-contact',
                          self.phandler.get_participations()[-1].contact)

    def test_raises_if_strict_and_user_doesnt_exist(self):
        migrator = DossierMigrator(
            self.portal, {'old.participant': 'doesnt.exist'}, 'move')

        with self.assertRaises(UserMigrationException):
            migrator.migrate()

    def test_doesnt_raise_if_not_strict_and_user_doesnt_exist(self):
        migrator = DossierMigrator(
            self.portal, {'old.participant': 'doesnt.exist'},
            'move', strict=False)

        migrator.migrate()

        self.assertEquals('doesnt.exist',
                          self.phandler.get_participations()[0].contact)

    def test_returns_proper_results_for_moving_participants(self):
        migrator = DossierMigrator(
            self.portal, {'old.participant': 'new.participant'}, 'move')
        results = migrator.migrate()

        self.assertEquals(
            [('/plone/dossier-1', 'old.participant', 'new.participant')],
            results['participations']['moved']
        )