コード例 #1
0
 def _msg_mapping(self):
     mapping = super(Reject, self)._msg_mapping
     change = self.get_change('responsible')
     if change:
         mapping['old_responsible'] = Actor.lookup(change.get('before')).get_link()
         mapping['new_responsible'] = Actor.lookup(change.get('after')).get_link()
     return mapping
コード例 #2
0
 def _msg_mapping(self):
     mapping = super(Reject, self)._msg_mapping
     change = self.response.get_change('responsible')
     if change:
         mapping['old_responsible'] = Actor.lookup(change.get('before')).get_link()
         mapping['new_responsible'] = Actor.lookup(change.get('after')).get_link()
     return mapping
コード例 #3
0
    def test_user_is_the_only_representatives_of_a_user(self):
        actor = Actor.lookup('jurgen.konig')
        self.assertEquals([self.get_ogds_user(self.secretariat_user)],
                          actor.representatives())

        actor = Actor.lookup(self.regular_user.getId())
        self.assertEquals([self.get_ogds_user(self.regular_user)],
                          actor.representatives())
コード例 #4
0
 def msg(self):
     change = self.response.get_change('responsible')
     responsible_new = Actor.lookup(change.get('after')).get_link()
     responsible_old = Actor.lookup(change.get('before')).get_link()
     return _('transition_msg_reassign',
              u'Reassigned from ${responsible_old} to '
              u'${responsible_new} by ${user}',
              mapping={'user': self.response.creator_link(),
                       'responsible_new': responsible_new,
                       'responsible_old': responsible_old})
コード例 #5
0
    def actor(self):
        """Returns a formatted link to the actor that created this version.
        """
        if self.version == 0:
            # Always return document's original creator for initial version
            return Actor.user(self._context.Creator()).get_link()

        principal = self.sys_metadata['principal']
        actor = Actor.user(principal)
        return actor.get_link()
コード例 #6
0
    def actor(self):
        """Returns a formatted link to the actor that created this version.
        """
        if self.version == 0:
            # Always return document's original creator for initial version
            return Actor.user(self._context.Creator()).get_link()

        principal = self.sys_metadata['principal']
        actor = Actor.user(principal)
        return actor.get_link()
コード例 #7
0
 def msg(self):
     change = self.response.get_change('responsible')
     responsible_new = Actor.lookup(change.get('after')).get_link()
     responsible_old = Actor.lookup(change.get('before')).get_link()
     return _('transition_msg_reassign',
              u'Reassigned from ${responsible_old} to '
              u'${responsible_new} by ${user}',
              mapping={'user': self.response.creator_link(),
                       'responsible_new': responsible_new,
                       'responsible_old': responsible_old})
コード例 #8
0
    def setUp(self):
        super(TestResolveOGUIDView, self).setUp()

        self.group = create(
            Builder('ogds_group').having(groupid='group', users=[self.user]))
        self.user2 = create(
            Builder('ogds_user').in_group(self.group).having(
                userid='x.john.doe', lastname='Doe', firstname='John'))

        self.actor1 = Actor.user(self.user.userid)
        self.actor2 = Actor.user(self.user2.userid)
コード例 #9
0
    def summary(self):
        responsible = Actor.lookup(self.context.responsible)
        user = Actor.lookup(self.actor_id)

        msg = _(u'summary_todo_assigned_activity',
                u'Assigned to ${responsible} by ${user}',
                mapping={
                    'responsible': responsible.get_label(with_principal=False),
                    'user': user.get_label(with_principal=False)
                })

        return self.translate_to_all_languages(msg)
コード例 #10
0
    def setUp(self):
        super(TestResolveOGUIDView, self).setUp()

        self.group = create(Builder('ogds_group')
                            .having(groupid='group', users=[self.user]))
        self.user2 = create(Builder('ogds_user')
                            .in_group(self.group)
                            .having(userid='x.john.doe',
                                    lastname='Doe',
                                    firstname='John'))

        self.actor1 = Actor.user(self.user.userid)
        self.actor2 = Actor.user(self.user2.userid)
コード例 #11
0
    def __call__(self):
        self.team_id = self.context.REQUEST.get('team', None)
        self.members = []

        if not self.team_id:
            raise BadRequest('no team id')

        try:
            team = Team.query.filter_by(team_id=self.team_id).one()
            group = getattr(team, 'group', None)
            self.group_id = getattr(group, 'groupid', None)
        except NoResultFound:
            self.group_id = None

        if not self.group_id:
            raise BadRequest('no group id')

        self.active = getattr(group, 'active', None)

        actors = [
            Actor.user(user.userid) for user in getattr(group, 'users', [])
        ]
        actors.sort(key=lambda actor: actor.get_label())
        self.members = [each.get_link() for each in actors]

        return self.template()
コード例 #12
0
    def get_data_for_item(self, item):
        admin_unit = item.get_admin_unit().title
        task_type = task_type_helper(item, item.task_type)
        sequence_number = unicode(item.sequence_number).encode("utf-8")
        deadline = helper.readable_date(item, item.deadline)

        title = unicode(getattr(item, "Title", getattr(item, "title", ""))).encode("utf-8")

        issuer = get_issuer_of_task(item, with_client=True, with_principal=False)

        responsible_org_unit = item.get_assigned_org_unit()
        responsible = Actor.lookup(item.responsible)
        responsible_label = responsible_org_unit.prefix_label(responsible.get_label(with_principal=False))

        dossier_title = item.containing_dossier or ""

        reference = unicode(getattr(item, "reference", getattr(item, "reference_number", ""))).encode("utf-8")

        review_state = workflow_state(item, item.review_state)

        return [
            admin_unit,
            sequence_number,
            title,
            task_type,
            dossier_title,
            reference,
            issuer,
            responsible_label,
            deadline,
            review_state,
        ]
コード例 #13
0
    def test_inbox_corresponds_to_all_inbox_assigned_users(self):
        actor = Actor.lookup('inbox:fa')

        self.assertTrue(
            actor.corresponds_to(self.get_ogds_user(self.secretariat_user)))
        self.assertFalse(
            actor.corresponds_to(self.get_ogds_user(self.regular_user)))
コード例 #14
0
    def render_checked_out_link(self):
        manager = queryMultiAdapter((self.context, self.request),
                                    ICheckinCheckoutManager)

        if manager.get_checked_out_by():
            return Actor.user(manager.get_checked_out_by()).get_link()
        return ''
コード例 #15
0
 def test_team_profile_url_for_foreign_user(self):
     self.login(self.foreign_contributor)
     actor = Actor.lookup('team:1')
     self.assertEqual(
         u'<a href="http://nohost/plone/kontakte/team-1/view">'
         u'Projekt \xdcberbaung Dorfmatte (Finanz\xe4mt)</a>',
         actor.get_link())
コード例 #16
0
    def test_contact_has_no_representatives(self):
        contact = create(Builder('contact')
                         .having(firstname=u'Paul')
                         .in_state('published'))

        actor = Actor.lookup('contact:{}'.format(contact.id))
        self.assertItemsEqual([], actor.representatives())
コード例 #17
0
    def test_user_corresponds_to_current_user(self):
        actor = Actor.lookup('jurgen.konig')

        self.assertTrue(
            actor.corresponds_to(self.get_ogds_user(self.secretariat_user)))
        self.assertFalse(
            actor.corresponds_to(self.get_ogds_user(self.regular_user)))
コード例 #18
0
    def test_inbox_actor_lookup(self):
        actor = Actor.lookup('inbox:fa')

        self.assertEqual(u'Inbox: Finanzamt', actor.get_label())
        self.assertIsNone(actor.get_profile_url())
        self.assertEqual('Inbox: Finanzamt', actor.get_link())
        self.assertEqual(u'fa_inbox_users', actor.permission_identifier)
コード例 #19
0
    def get_responsible_label(self, linked=True):
        actor = Actor.lookup(self.responsible)
        org_unit = ogds_service().fetch_org_unit(self.assigned_org_unit)
        if not linked:
            return org_unit.prefix_label(actor.get_label())

        return org_unit.prefix_label(actor.get_link())
コード例 #20
0
    def render_checked_out_link(self):
        manager = queryMultiAdapter(
            (self.context, self.request), ICheckinCheckoutManager)

        if manager.get_checked_out_by():
            return Actor.user(manager.get_checked_out_by()).get_link()
        return ''
コード例 #21
0
 def test_all_users_of_the_responsible_group_are_committee_representatives(
         self):
     actor = Actor.lookup('committee:1')
     self.assertItemsEqual([
         self.get_ogds_user(self.committee_responsible),
         self.get_ogds_user(self.administrator)
     ], actor.representatives())
コード例 #22
0
 def test_template_journal_tab(self, browser):
     browser.login().open(self.template, view=JOURNAL_TAB)
     journal_entries = browser.css('table.listing').first.dicts()
     self.assertEqual(Actor.lookup(TEST_USER_ID).get_label(),
                      journal_entries[0]['Changed by'])
     self.assertEqual('Document added: My Document',
                      journal_entries[0]['Title'])
コード例 #23
0
 def summary(self):
     actor = Actor.lookup(self.context.Creator())
     msg = _('summary_disposition_added',
             u'New disposition added by ${user} on admin unit ${admin_unit}',
             mapping={'user': actor.get_label(with_principal=False),
                      'admin_unit': get_current_admin_unit().label()})
     return self.translate_to_all_languages(msg)
コード例 #24
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
コード例 #25
0
    def getTerm(self, value, brain=None):
        # Contacts
        if ActorLookup(value).is_contact() and brain is None:
            catalog = api.portal.get_tool('portal_catalog')
            brain = catalog.unrestrictedSearchResults(
                portal_type=CONTACT_TYPE,
                contactid=value)[0]

        if brain and ActorLookup(value).is_contact():
            actor = Actor.contact(brain.contactid, contact=brain)
            token = value
            title = actor.get_label()
            return SimpleTerm(value, token, title)

        # Inboxes
        if ActorLookup(value).is_inbox():
            orgunit_id = value.split(':', 1)[1]
            orgunit = OrgUnit.query.filter(OrgUnit.unit_id == orgunit_id).one()

            value = token = orgunit.inbox().id()
            title = translate(_(u'inbox_label',
                                default=u'Inbox: ${client}',
                                mapping=dict(client=orgunit.label())),
                              context=getRequest())

            return SimpleTerm(value, token, title)

        user = self.base_query.filter(User.userid == value).one()

        token = value
        title = u'{} ({})'.format(user.fullname(),
                                  user.userid)
        return SimpleTerm(value, token, title)
コード例 #26
0
    def get_responsible_label(self, linked=True):
        actor = Actor.lookup(self.responsible)
        org_unit = ogds_service().fetch_org_unit(self.assigned_org_unit)
        if not linked:
            return org_unit.prefix_label(actor.get_label())

        return org_unit.prefix_label(actor.get_link())
コード例 #27
0
    def test_document_report(self, browser):
        browser.login().open(view='document_report',
                             data={'paths:list': [
                                   '/'.join(self.document.getPhysicalPath()),
                                   ]})

        with NamedTemporaryFile(delete=False, suffix='.xlsx') as tmpfile:
            tmpfile.write(browser.contents)
            tmpfile.flush()
            workbook = load_workbook(tmpfile.name)

        self.assertSequenceEqual(
            [
             u'Client1 / 1 / 1',
             1L,
             u'Testdokum\xe4nt',
             u'Mustermann Max',
             get_localized_time(self.document_date),
             get_localized_time(self.receipt_date),
             get_localized_time(self.delivery_date),
             Actor.lookup(TEST_USER_ID).get_label(),
             u'unchecked',
             u'Dossier A',
             ],
            [cell.value for cell in workbook.active.rows[1]])
コード例 #28
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
コード例 #29
0
ファイル: helpers.py プロジェクト: 4teamwork/opengever.core
def display_name(userid):
    if not isinstance(userid, unicode):
        if userid is not None:
            userid = userid.decode('utf-8')
        else:
            userid = ''

    return Actor.user(userid).get_label(with_principal=False)
コード例 #30
0
def readable_ogds_user(item, userid):
    if not isinstance(userid, unicode):
        if userid is not None:
            userid = userid.decode('utf-8')
        else:
            userid = ''

    return Actor.user(userid).get_label()
コード例 #31
0
def display_name(userid):
    if not isinstance(userid, unicode):
        if userid is not None:
            userid = userid.decode('utf-8')
        else:
            userid = ''

    return Actor.lookup(userid).get_label(with_principal=False)
コード例 #32
0
    def test_template_journal_tab(self, browser):
        self.login(self.regular_user, browser)
        browser.open(self.normal_template, view='tabbedview_view-journal')

        journal_entries = browser.css('table.listing').first.dicts()

        self.assertEqual(Actor.lookup(self.administrator.id).get_label(), journal_entries[0]['Changed by'])
        self.assertEqual(u'Document added: T\xc3\xb6mpl\xc3\xb6te Normal', journal_entries[0]['Title'])
コード例 #33
0
    def test_team_actor_lookup(self):
        self.login(self.regular_user)
        actor = Actor.lookup('team:1')

        self.assertEqual(u'Projekt \xdcberbaung Dorfmatte (Finanzamt)',
                         actor.get_label())
        self.assertEqual('http://nohost/plone/@@team-details/1',
                         actor.get_profile_url())
コード例 #34
0
 def summary(self):
     actor = Actor.lookup(self.context.Creator())
     msg = _(
         "msg_forwarding_added",
         u"New forwarding added by ${user}",
         mapping={"user": actor.get_label(with_principal=False)},
     )
     return self.translate_to_all_languages(msg)
コード例 #35
0
def linked_user_helper(item, value):
    """Helper for linking the value with the user profile.
    """
    userid = getattr(item, 'userid', None)
    url = Actor.user(userid, user=item).get_profile_url()
    if not url:
        return value
    return u'<a href="{}">{}</a>'.format(url, value)
コード例 #36
0
    def test_template_journal_tab(self, browser):
        self.login(self.regular_user, browser)
        browser.open(self.normal_template, view='tabbedview_view-journal')

        journal_entries = browser.css('table.listing').first.dicts()

        self.assertEqual(Actor.lookup(self.administrator.id).get_label(), journal_entries[0]['Changed by'])
        self.assertEqual(u'Document added: T\xc3\xb6mpl\xc3\xb6te Normal', journal_entries[0]['Title'])
コード例 #37
0
 def test_template_journal_tab(self, browser):
     browser.login().open(self.template, view=JOURNAL_TAB)
     journal_entries = browser.css('table.listing').first.dicts()
     self.assertEqual(
         Actor.lookup(TEST_USER_ID).get_label(),
         journal_entries[0]['Changed by'])
     self.assertEqual('Document added: My Document',
                      journal_entries[0]['Title'])
コード例 #38
0
ファイル: helper.py プロジェクト: 4teamwork/opengever.core
def readable_ogds_user(item, userid):
    if not isinstance(userid, unicode):
        if userid is not None:
            userid = userid.decode('utf-8')
        else:
            userid = ''

    return Actor.user(userid).get_label()
コード例 #39
0
def linked_user_helper(item, value):
    """Helper for linking the value with the user profile.
    """
    userid = getattr(item, 'userid', None)
    url = Actor.user(userid, user=item).get_profile_url()
    if not url:
        return value
    return u'<a href="{}">{}</a>'.format(url, value)
コード例 #40
0
    def test_team_corresponds_to_all_team_group_members(self):
        actor = Actor.lookup('team:1')

        self.assertTrue(
            actor.corresponds_to(self.get_ogds_user(self.regular_user)))
        self.assertTrue(
            actor.corresponds_to(self.get_ogds_user(self.dossier_responsible)))
        self.assertFalse(
            actor.corresponds_to(self.get_ogds_user(self.secretariat_user)))
コード例 #41
0
    def get_overview_attributes(self):
        model = self.load_model()
        assert model, 'missing db-model for {}'.format(self)

        attributes = [
            {
                'label': _(u"label_title", default=u'Title'),
                'value': self.title
            },
            {
                'label': _(u"label_description", default=u'Description'),
                'value': self.get_description(),
                'is_html': True
            },
            {
                'label': _('label_committee', default=u'Committee'),
                'value': model.committee.get_link(),
                'is_html': True
            },
            {
                'label': _('label_meeting', default=u'Meeting'),
                'value': model.get_meeting_link(),
                'is_html': True
            },
            {
                'label': _('label_issuer', default=u'Issuer'),
                'value': Actor.lookup(self.issuer).get_label(),
                'is_html': True
            },
        ]

        proposal_document = self.get_proposal_document()
        if proposal_document:
            attributes.append({
                'label':
                _('proposal_document', default=u'Proposal document'),
                'value':
                DocumentLinkWidget(proposal_document).render(),
                'is_html':
                True
            })

        attributes.extend([
            {
                'label': _('label_workflow_state', default=u'State'),
                'value': self.get_state().title,
                'is_html': True
            },
            {
                'label': _('label_decision_number',
                           default=u'Decision number'),
                'value': model.get_decision_number(),
                'is_html': True
            },
        ])

        return attributes
コード例 #42
0
 def summary(self):
     actor = Actor.lookup(self.context.Creator())
     msg = _(
         'summary_disposition_added',
         u'New disposition added by ${user} on admin unit ${admin_unit}',
         mapping={
             'user': actor.get_label(with_principal=False),
             'admin_unit': get_current_admin_unit().label()
         })
     return self.translate_to_all_languages(msg)
コード例 #43
0
    def test_get_link_returns_safe_html(self):
        self.login(self.regular_user)

        self.franz_meier.firstname = u"Foo <b onmouseover=alert('Foo!')>click me!</b>"
        self.franz_meier.reindexObject()
        actor = Actor.lookup('contact:meier-franz')

        self.assertEquals(
            u'<a href="http://nohost/plone/kontakte/meier-franz">Meier Foo &lt;b onmouseover=alert(&apos;Foo!&apos;)&gt;click me!&lt;/b&gt; ([email protected])</a>',
            actor.get_link())
コード例 #44
0
    def test_inbox_actor_lookup(self):
        actor = Actor.lookup('inbox:fa')

        self.assertEqual(u'Inbox: Finanzamt', actor.get_label())
        self.assertIsNone(actor.get_profile_url())
        self.assertEqual('Inbox: Finanzamt', actor.get_link())
        self.assertEqual(u'fa_inbox_users', actor.permission_identifier)
        self.assertEqual(
            u'<span class="actor-label actor-inbox">Inbox: Finanzamt</span>',
            actor.get_link(with_icon=True))
コード例 #45
0
    def summary(self):
        actor = Actor.lookup(self.context.Creator())
        msg = _('label_task_added', u'New task opened by ${user}',
                mapping={'user': actor.get_label(with_principal=False)})

        if self.context.is_private:
            msg = _('label_private_task_added',
                    default=u'New task (private) opened by ${user}',
                    mapping={'user': actor.get_label(with_principal=False)})

        return self.translate_to_all_languages(msg)
コード例 #46
0
    def getTerm(self, value, brain=None):
        if not ActorLookup(value).is_contact():
            raise ValueError('Value is not a contact token')

        catalog = api.portal.get_tool('portal_catalog')
        brain = catalog.unrestrictedSearchResults(portal_type=CONTACT_TYPE,
                                                  contactid=value)[0]
        actor = Actor.contact(brain.contactid, contact=brain)
        token = value
        title = actor.get_label()
        return SimpleTerm(value, token, title)
コード例 #47
0
    def test_inbox_actor_lookup(self):
        create(Builder('org_unit')
               .id('foobar')
               .having(title='Huhu',
                       admin_unit=self.admin_unit)
               .with_default_groups())
        actor = Actor.lookup('inbox:foobar')

        self.assertEqual('Inbox: Huhu', actor.get_label())
        self.assertIsNone(actor.get_profile_url())
        self.assertEqual('Inbox: Huhu', actor.get_link())
        self.assertEqual(u'foobar_inbox_users', actor.permission_identifier)
コード例 #48
0
    def test_get_link_returns_safe_html(self):
        contact = create(Builder('contact')
                         .having(firstname=u"Foo <b onmouseover=alert('Foo!')>click me!</b>",
                                 lastname=u'Blahbla',
                                 email='*****@*****.**')
                         .in_state('published'))
        actor = Actor.lookup('contact:{}'.format(contact.id))

        self.assertEquals(
            u'<a href="http://nohost/plone/blahbla-foo-b-onmouseover-alert-foo-click-me-b">'
            'Blahbla Foo &lt;b onmouseover=alert(&apos;Foo!&apos;)&gt;click me!&lt;/b&gt; ([email protected])</a>',
            actor.get_link())
コード例 #49
0
    def update(self):
        manager = queryMultiAdapter((self.context, self.request),
                                    ICheckinCheckoutManager)
        if not manager:
            self.available = False
        elif not manager.get_checked_out_by():
            self.available = False
        else:
            self.available = True

            self.checkout_by_link = Actor.user(
                manager.get_checked_out_by()).get_link()
コード例 #50
0
ファイル: watcher.py プロジェクト: lukasgraf/opengever.core
    def get_user_ids(self):
        """Returns a list of userids which represents the given watcher:

        Means for a single user, a list with the user_id and for a inbox watcher,
        a list of the userids of all inbox_group users.
        """
        actor_lookup = ActorLookup(self.actorid)
        if actor_lookup.is_inbox() or actor_lookup.is_team():
            return [user.userid for user in
                    Actor.lookup(self.actorid).representatives()]

        return [self.actorid]
コード例 #51
0
ファイル: sources.py プロジェクト: 4teamwork/opengever.core
    def getTerm(self, value, brain=None):
        if not ActorLookup(value).is_contact():
            raise ValueError('Value is not a contact token')

        catalog = api.portal.get_tool('portal_catalog')
        brain = catalog.unrestrictedSearchResults(
            portal_type=CONTACT_TYPE,
            contactid=value)[0]
        actor = Actor.contact(brain.contactid, contact=brain)
        token = value
        title = actor.get_label()
        return SimpleTerm(value, token, title)
コード例 #52
0
    def test_contact_actor_lookup(self):
        self.login(self.regular_user)
        actor = Actor.lookup('contact:{}'.format(self.franz_meier.id))

        self.assertEqual('Meier Franz ([email protected])',
                         actor.get_label())
        self.assertEqual(self.franz_meier.absolute_url(),
                         actor.get_profile_url())

        link = actor.get_link(with_icon=True)
        self.assertIn(actor.get_label(), link)
        self.assertIn(actor.get_profile_url(), link)
        self.assertIn('class="actor-label actor-contact"', link)