def test_removed_documents_are_prefixed_with_removed_marker(self, browser):
        document_a = create(Builder('document').with_dummy_content())
        document_b = create(Builder('document').with_dummy_content().removed())

        browser.open_html(DocumentLinkWidget(document_a).render())
        self.assertEquals([], browser.css('.removed_document'))

        browser.open_html(DocumentLinkWidget(document_b).render())
        self.assertEquals(1, len(browser.css('.removed_document')))
 def test_title_can_disable_icon(self, browser):
     document = create(Builder('document').titled('Important'))
     browser.open_html(DocumentLinkWidget(document).render())
     icon_css_class = 'icon-document_empty'
     self.assertIn(icon_css_class,
                   browser.css('a.document_link').first.classes)
     browser.open_html(DocumentLinkWidget(document).render(show_icon=False))
     self.assertNotIn(icon_css_class,
                      browser.css('a.document_link').first.classes)
    def test_tooltip_link_is_documents_tooltip_view(self, browser):
        document = create(Builder('document').with_dummy_content())

        browser.open_html(DocumentLinkWidget(document).render())
        self.assertEquals(
            'http://nohost/plone/document-1/tooltip',
            browser.css('.tooltip-trigger').first.get('data-tooltip-url'))
    def test_link_contains_mimetype_icon_class(self, browser):
        document = create(Builder('document').with_dummy_content())

        browser.open_html(DocumentLinkWidget(document).render())

        link = browser.css('a.document_link').first
        self.assertEquals('document_link icon-doc', link.get('class'))
    def test_document_link_is_not_extended_with_showrom_data(self, browser):
        document = create(Builder('document').with_dummy_content())

        browser.open_html(DocumentLinkWidget(document).render())

        link = browser.css('a.document_link').first
        self.assertNotIn('showroom-item', link.get('class'))
    def test_title_can_be_overriden(self, browser):
        document = create(
            Builder('document').titled('Protocol of the 37th meeting in 2016'))
        browser.open_html(
            DocumentLinkWidget(document).render(title='Protocol'))

        link = browser.css('a.document_link').first
        self.assertEquals('Protocol', link.text)
示例#7
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
    def test_is_linked_to_the_object(self, browser):
        document = create(
            Builder('document').titled('Anfrage Meier').with_dummy_content())

        browser.open_html(DocumentLinkWidget(document).render())

        link = browser.css('a.document_link').first
        self.assertEquals('Anfrage Meier', link.text)
        self.assertEquals(document.absolute_url(), link.get('href'))
    def test_omits_link_when_user_has_no_View_permission(self, browser):
        document = create(
            Builder('document').titled('Anfrage Meier').with_dummy_content())
        document.manage_permission('View', roles=[], acquire=False)

        browser.open_html(DocumentLinkWidget(document).render())

        self.assertFalse(browser.css('a'))
        link = browser.css('span.document_link').first
        self.assertEquals('Anfrage Meier', link.text)
        self.assertEquals('You are not allowed to view this document.',
                          link.get('title'))
示例#10
0
def linked_document(item, value):
    """Tabbedview helper wich returns a rendered link for the a document,
    using the DocumentLinkWidget.
    """

    return DocumentLinkWidget(item).render()
示例#11
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': _('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
            },
        ]

        if is_word_meeting_implementation_enabled():
            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
                })

        else:
            attributes.extend([
                {
                    'label': _('label_legal_basis', default=u'Legal basis'),
                    'value': self.legal_basis,
                    'is_html': True
                },
                {
                    'label':
                    _('label_initial_position', default=u'Initial position'),
                    'value':
                    self.initial_position,
                    'is_html':
                    True
                },
                {
                    'label': _('label_proposed_action',
                               default=u'Proposed action'),
                    'value': self.proposed_action,
                    'is_html': True
                },
                {
                    'label': _('label_decision_draft',
                               default=u'Decision draft'),
                    'value': self.decision_draft,
                    'is_html': True
                },
                {
                    'label': _('label_decision', default=u'Decision'),
                    'value': model.get_decision(),
                    'is_html': True
                },
                {
                    'label': _('label_publish_in', default=u'Publish in'),
                    'value': self.publish_in,
                    'is_html': True
                },
                {
                    'label': _('label_disclose_to', default=u'Disclose to'),
                    'value': self.disclose_to,
                    'is_html': True
                },
                {
                    'label':
                    _('label_copy_for_attention',
                      default=u'Copy for attention'),
                    'value':
                    self.copy_for_attention,
                    '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
示例#12
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': _('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
            },
        ]

        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
            },
        ])

        if self.predecessor_proposal and self.predecessor_proposal.to_object:
            predecessor_model = self.predecessor_proposal.to_object.load_model(
            )
            attributes.append({
                'label':
                _('label_predecessor', default=u'Predecessor'),
                'value':
                predecessor_model.get_link(),
                'is_html':
                True
            })

        catalog = getUtility(ICatalog)
        doc_id = getUtility(IIntIds).getId(aq_inner(self))
        successor_html_items = []
        for relation in catalog.findRelations({
                'to_id':
                doc_id,
                'from_attribute':
                'predecessor_proposal'
        }):
            successor_html_items.append(u'<li>{}</li>'.format(
                relation.from_object.load_model().get_link()))
        if successor_html_items:
            attributes.append({
                'label':
                _('label_successors', default=u'Successors'),
                'value':
                u'<ul>{}</ul>'.format(''.join(successor_html_items)),
                'is_html':
                True
            })

        return attributes
示例#13
0
 def render_link(self, **kwargs):
     return DocumentLinkWidget(self).render(**kwargs)
 def render_link(self):
     return DocumentLinkWidget(self).render()
示例#15
0
 def render_protocol_excerpt_document_link(self):
     return DocumentLinkWidget(self.context.get_excerpt()).render()
示例#16
0
    def render_link(self):
        if self.is_documentish:
            return DocumentLinkWidget(self).render()

        return self._render_simplelink()
示例#17
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': _('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
            },
        ]

        if is_word_meeting_implementation_enabled():
            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
                })

        else:
            attributes.extend([
                {
                    'label': _('label_legal_basis', default=u'Legal basis'),
                    'value': self.legal_basis,
                    'is_html': True
                },
                {
                    'label':
                    _('label_initial_position', default=u'Initial position'),
                    'value':
                    self.initial_position,
                    'is_html':
                    True
                },
                {
                    'label': _('label_proposed_action',
                               default=u'Proposed action'),
                    'value': self.proposed_action,
                    'is_html': True
                },
                {
                    'label': _('label_decision_draft',
                               default=u'Decision draft'),
                    'value': self.decision_draft,
                    'is_html': True
                },
                {
                    'label': _('label_decision', default=u'Decision'),
                    'value': model.get_decision(),
                    'is_html': True
                },
                {
                    'label': _('label_publish_in', default=u'Publish in'),
                    'value': self.publish_in,
                    'is_html': True
                },
                {
                    'label': _('label_disclose_to', default=u'Disclose to'),
                    'value': self.disclose_to,
                    'is_html': True
                },
                {
                    'label':
                    _('label_copy_for_attention',
                      default=u'Copy for attention'),
                    'value':
                    self.copy_for_attention,
                    '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
            },
        ])

        if is_word_meeting_implementation_enabled():
            if self.predecessor_proposal and self.predecessor_proposal.to_object:
                predecessor_model = self.predecessor_proposal.to_object.load_model(
                )
                attributes.append({
                    'label':
                    _('label_predecessor', default=u'Predecessor'),
                    'value':
                    predecessor_model.get_link(),
                    'is_html':
                    True
                })

            catalog = getUtility(ICatalog)
            doc_id = getUtility(IIntIds).getId(aq_inner(self))
            successor_html_items = []
            for relation in catalog.findRelations({
                    'to_id':
                    doc_id,
                    'from_attribute':
                    'predecessor_proposal'
            }):
                successor_html_items.append(u'<li>{}</li>'.format(
                    relation.from_object.load_model().get_link()))
            if successor_html_items:
                attributes.append({
                    'label':
                    _('label_successors', default=u'Successors'),
                    'value':
                    u'<ul>{}</ul>'.format(''.join(successor_html_items)),
                    'is_html':
                    True
                })

        return attributes
 def render_protocol_excerpt_document_link(self):
     excerpt = self.context.get_excerpt()
     if excerpt:
         return DocumentLinkWidget(excerpt).render()
     return u''