def generate_url(package):
    site_url = config.get("ckan.site_url")

    if int(helpers.ckan_version().split(".")[1]) >= 9:
        controller_type = "dataset"
    else:
        controller_type = "package"

    relative_path = helpers.url_for_static(controller=controller_type, action="read", id=package["name"])
    return "".join([site_url, relative_path])
    def test_api_doc_link(self, app):
        """Assert CKAN major/minor version matches API docs URL."""
        # TODO mock helpers.api_doc_url and then assert the mock was called
        # after the request. Is this possible in CKAN?
        from ckan.lib.helpers import ckan_version
        expected_version = '.'.join(ckan_version().split('.')[0:2])

        index_response = app.get('/dataset')
        html = BeautifulSoup(index_response.body, 'html.parser')

        # Test link to api docs matches CKAN version
        api_doc_href = html.find('a', string='API Docs')['href']
        assert expected_version in api_doc_href
def is_fontawesome_4():
    if hasattr(h, 'ckan_version'):
        ckan_version = float(h.ckan_version()[0:3])
        return ckan_version >= 2.7
    else:
        return False
def is_fontawesome_4():
    if hasattr(h, 'ckan_version'):
        ckan_version = float(h.ckan_version()[0:3])
        return ckan_version >= 2.7
    else:
        return False
Exemple #5
0
def api_doc_url():
    lang = h.lang()
    ckan_major_minor_version = '.'.join(h.ckan_version().split('.')[0:2])

    return 'https://docs.ckan.org/{lang}/{version}/api/index.html'.format(
        lang=lang, version=ckan_major_minor_version)
Exemple #6
0
def get_ckan_version():
    try:
        return float(h.ckan_version()[0:3])
    except AttributeError:
        #So old that we can't ask CKAN this way, but let's be optimistic
        return 2.4