Exemplo n.º 1
0
    def download_link(self, formatter, ns, target, label):
        if ns == 'download':
            if 'FILES_DOWNLOADS_VIEW' not in formatter.req.perm:
                return html.a(label,
                              href='#',
                              title=_('Missing %(permission)s permission',
                                      permission='FILES_DOWNLOADS_VIEW'),
                              class_='missing')
            files_core = FilesCoreComponent(self.env)
            wiki = ProjectDownloadsWiki(self.env)
            node_factory, download_config = files_core.files_node_factory_and_config(
                formatter.req)
            id_, filename = self._get_id_filename(target)
            if id_ and filename:
                primary_path = get_download_path(id_, filename)
                node = MappedFileNode.from_download_path(
                    primary_path, node_factory, True)
                if node.exists() and node.is_download():
                    return wiki.file_link(formatter, 'filesdownload',
                                          node.download().download_path, label)

                node = MappedFileNode.from_download_path(
                    filename, node_factory, True)
                if node.exists() and node.is_download():
                    return wiki.file_link(formatter, 'filesdownload',
                                          node.download().download_path, label)
            return wiki.file_link(formatter, 'filesdownload', target, label)
Exemplo n.º 2
0
    def download_link(self, formatter, ns, target, label):
        if ns == 'download':
            if 'FILES_DOWNLOADS_VIEW' not in formatter.req.perm:
                return html.a(label, href='#',
                    title = _('Missing %(permission)s permission',
                                permission='FILES_DOWNLOADS_VIEW'),
                        class_ = 'missing')
            files_core = FilesCoreComponent(self.env)
            wiki = ProjectDownloadsWiki(self.env)
            node_factory, download_config = files_core.files_node_factory_and_config(formatter.req)
            id_, filename = self._get_id_filename(target)
            if id_ and filename:
                primary_path = get_download_path(id_, filename)
                node = MappedFileNode.from_download_path(primary_path, node_factory, True)
                if node.exists() and node.is_download():
                    return wiki.file_link(formatter, 'filesdownload',
                        node.download().download_path, label)

                node = MappedFileNode.from_download_path(filename, node_factory, True)
                if node.exists() and node.is_download():
                    return wiki.file_link(formatter, 'filesdownload',
                        node.download().download_path, label)
            return wiki.file_link(formatter, 'filesdownload', target, label)