コード例 #1
0
ファイル: overview.py プロジェクト: hellfish2/opengever.core
    def sharing(self):

        # get the participants
        phandler = IParticipationAware(self.context)
        results = list(phandler.get_participations())

        # also append the responsible
        class ResponsibleParticipant(object):
            pass

        responsible = ResponsibleParticipant()
        responsible.roles = _dossier(u'label_responsible', 'Responsible')
        responsible.role_list = responsible.roles

        dossier_adpt = IDossier(self.context)
        responsible.contact = dossier_adpt.responsible
        results.append(responsible)

        info = getUtility(IContactInformation)

        return [{
            'Title': info.describe(xx.contact),
            'getURL': info.get_profile_url(xx.contact),
            'css_class': 'function-user',
        } for xx in results]
コード例 #2
0
ファイル: overview.py プロジェクト: 4teamwork/opengever.core
    def plone_participations(self):
        if not self.context.has_participation_support():
            return []

        # get the participants
        phandler = IParticipationAware(self.context)
        results = list(phandler.get_participations())

        # also append the responsible
        class ResponsibleParticipant(object):
            pass

        responsible = ResponsibleParticipant()
        responsible.roles = _dossier(u'label_responsible', 'Responsible')
        responsible.role_list = responsible.roles

        dossier_adpt = IDossier(self.context)
        responsible.contact = dossier_adpt.responsible
        results.append(responsible)

        users = []
        for dossier in results:
            actor = Actor.lookup(dossier.contact)
            users.append({
                'Title': actor.get_label(),
                'getURL': actor.get_profile_url(),
                'css_class': 'function-user',
            })
        return users
コード例 #3
0
    def plone_participations(self):
        if not self.context.has_participation_support():
            return []

        # get the participants
        phandler = IParticipationAware(self.context)
        results = list(phandler.get_participations())

        # also append the responsible
        class ResponsibleParticipant(object):
            pass

        responsible = ResponsibleParticipant()
        responsible.roles = _dossier(u'label_responsible', 'Responsible')
        responsible.role_list = responsible.roles

        dossier_adpt = IDossier(self.context)
        responsible.contact = dossier_adpt.responsible
        results.append(responsible)

        users = []
        for dossier in results:
            actor = Actor.lookup(dossier.contact)
            users.append({
                'Title': actor.get_label(),
                'getURL': actor.get_profile_url(),
                'css_class': 'function-user',
            })
        return users
コード例 #4
0
ファイル: overview.py プロジェクト: hellfish2/opengever.core
    def sharing(self):

        # get the participants
        phandler = IParticipationAware(self.context)
        results = list(phandler.get_participations())

        # also append the responsible
        class ResponsibleParticipant(object):
            pass

        responsible = ResponsibleParticipant()
        responsible.roles = _dossier(u'label_responsible', 'Responsible')
        responsible.role_list = responsible.roles

        dossier_adpt = IDossier(self.context)
        responsible.contact = dossier_adpt.responsible
        results.append(responsible)

        info = getUtility(IContactInformation)

        return [{
            'Title': info.describe(xx.contact),
            'getURL': info.get_profile_url(xx.contact),
            'css_class': 'function-user',
            }
            for xx in results]
コード例 #5
0
    def validate_base_query(self, query):
        """hacky: get the actual elements here because we are not
        able to use queries on annotations / lists ...
        """
        context = self.config.context

        phandler = IParticipationAware(context)
        results = list(phandler.get_participations())

        dossier_adpt = IDossier(context)
        responsible_name = _(u'label_responsible', 'Responsible')
        results.append(
            ParticipationResponsible(contact=dossier_adpt.responsible,
                                     responsible=responsible_name))

        return results
コード例 #6
0
    def validate_base_query(self, query):
        """hacky: get the actual elements here because we are not
        able to use queries on annotations / lists ...
        """
        context = self.config.context

        phandler = IParticipationAware(context)
        results = list(phandler.get_participations())

        dossier_adpt = IDossier(context)
        responsible_name = _(u'label_responsible', 'Responsible')
        results.append(ParticipationResponsible(
            contact=dossier_adpt.responsible,
            responsible=responsible_name))

        return results
コード例 #7
0
    def _migrate_participations(self, dossier):
        moved = []
        path = '/'.join(dossier.getPhysicalPath())

        if not IParticipationAwareMarker.providedBy(dossier):
            # No participation support - probably a template folder
            return moved

        phandler = IParticipationAware(dossier)
        participations = phandler.get_participations()
        for participation in participations:
            old_userid = participation.contact
            if old_userid in self.principal_mapping:
                new_userid = self.principal_mapping[old_userid]
                logger.info("Migrating participation for {} ({} -> {})".format(
                    path, old_userid, new_userid))
                self._verify_user(new_userid)
                participation.contact = new_userid
                moved.append((path, old_userid, new_userid))

        return moved
コード例 #8
0
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']
        )