Exemplo n.º 1
0
 def test_get_license_url_version(self):
     """The license URL method should return the expected URL for a license version"""
     assert "https://creativecommons.org/licenses/by/3.0" == licenses.get_license_url(
         "by", "3.0")
     assert "https://creativecommons.org/licenses/by-sa/3.0" == licenses.get_license_url(
         "by-sa", "3.0")
     assert "https://creativecommons.org/licenses/by-nc/3.0" == licenses.get_license_url(
         "by-nc", "3.0")
     assert "https://creativecommons.org/licenses/by-nc-nd/3.0" == licenses.get_license_url(
         "by-nc-nd", "3.0")
     assert "https://creativecommons.org/licenses/by-nc-sa/3.0" == licenses.get_license_url(
         "by-nc-sa", "3.0")
Exemplo n.º 2
0
def detail(request, identifier):
    obj = get_object_or_404(models.Image, identifier=identifier)
    if request.user.is_authenticated():
        # Is it a favorite?
        obj.is_favorite = models.Favorite.objects.filter(user=request.user,
                                                         image=obj).exists()
    license_url = licenses.get_license_url(obj.license, obj.license_version)
    return render(request, 'detail.html', {
        'image': obj,
        'license_url': license_url,
    })
Exemplo n.º 3
0
def by_image(request):
    """Load an image in detail view, passing parameters by query string so that
    we can either load an image from an external provider or from our own datastore."""
    license_version = licenses.license_map_from_partners()[request.GET.get(
        'provider')]['version']
    license_url = licenses.get_license_url(request.GET.get('license'),
                                           license_version)
    remaining = dict(
        (k, request.GET[k])
        for k in request.GET)  # The vals in request.GET are lists, so flatten
    remaining.update({'license_version': license_version})
    return render(request, 'detail.html', {
        'image': remaining,
        'license_url': license_url,
    })
Exemplo n.º 4
0
 def test_get_license_url_pd_licenses(self):
     """The license URL method should return the correct public domain licenses regardless of version"""
     assert "https://creativecommons.org/publicdomain/zero/1.0" == licenses.get_license_url(
         "cc0", "10.0")
     assert "https://creativecommons.org/publicdomain/mark/1.0" == licenses.get_license_url(
         "pdm", "10.0")
Exemplo n.º 5
0
 def test_get_license_url_unknown_license(self):
     """The license URL method should return None if passed an unknown license"""
     assert licenses.get_license_url("FAKE", "3.0") is None