コード例 #1
0
ファイル: indexers.py プロジェクト: 4teamwork/opengever.core
def main_dossier_title(obj):
    """Return the title of the main dossier."""
    if obj.portal_type not in TYPES_WITH_CONTAINING_DOSSIER_INDEX:
        return None

    dossier = get_main_dossier(obj)
    if not dossier:
        return None
    try:
        title = dossier.Title()
    except TypeError:
        # XXX: During upgrades, the odd case can happen that a mail inside a
        # forwarding inside the inbox wants to have its containing_dossier
        # reindexed. This can lead to a situation where we attempt to adapt
        # the Inbox to ITranslatedTitle, but it doesn't provide this behavior
        # yet because that behavior is going to be actived in the very same
        # upgrade.
        #
        # Account for this case, and fall back to inbox.title, which
        # will contain the original title (in unicode though).
        if IInbox.providedBy(dossier):
            title = dossier.title.encode('utf-8')
        else:
            raise
    return title
コード例 #2
0
def main_dossier_title(obj):
    """Return the title of the main dossier."""
    if obj.portal_type not in TYPES_WITH_CONTAINING_DOSSIER_INDEX:
        return None

    dossier = get_main_dossier(obj)
    if not dossier:
        return None
    try:
        title = dossier.Title()
    except TypeError:
        # XXX: During upgrades, the odd case can happen that a mail inside a
        # forwarding inside the inbox wants to have its containing_dossier
        # reindexed. This can lead to a situation where we attempt to adapt
        # the Inbox to ITranslatedTitle, but it doesn't provide this behavior
        # yet because that behavior is going to be actived in the very same
        # upgrade.
        #
        # Account for this case, and fall back to inbox.title, which
        # will contain the original title (in unicode though).
        if IInbox.providedBy(dossier):
            title = dossier.title.encode('utf-8')
        else:
            raise
    return title
コード例 #3
0
def main_dossier_title(obj):
    """Return the title of the main dossier."""

    dossier = get_main_dossier(obj)
    if not dossier:
        return None
    return dossier.Title()
コード例 #4
0
    def render(self):
        main_dossier = get_main_dossier(self.context)
        if not main_dossier:
            msg = _(u'msg_main_dossier_not_found',
                    default=u'The object `${title}` is not stored inside a dossier.',
                    mapping={'title': self.context.Title().decode('utf-8')})
            api.portal.show_message(msg, request=self.request, type='error')
            return self.request.RESPONSE.redirect(self.context.absolute_url())

        return self.request.RESPONSE.redirect(main_dossier.absolute_url())
コード例 #5
0
    def render(self):
        main_dossier = get_main_dossier(self.context)
        if not main_dossier:
            msg = _(u'msg_main_dossier_not_found',
                    default=
                    u'The object `${title}` is not stored inside a dossier.',
                    mapping={'title': self.context.Title().decode('utf-8')})
            api.portal.show_message(msg, request=self.request, type='error')
            return self.request.RESPONSE.redirect(self.context.absolute_url())

        return self.request.RESPONSE.redirect(main_dossier.absolute_url())
コード例 #6
0
 def available(self):
     return self.context == get_main_dossier(self.context)
コード例 #7
0
 def __call__(self):
     self.request.RESPONSE.redirect(
         get_main_dossier(self.context).absolute_url())
コード例 #8
0
 def containing_dossier_title(self):
     """"Returns the title of the main dossier which the document is placed in.
     """
     dossier = get_main_dossier(self)
     if dossier:
         return dossier.title