Skip to main content

Implements a function to test whether a given url is currently visible to a given user.

Project description

DEPRECATED. This approach causes more headaches than it's worth.

django_page_visibility

This package implements a standard protocol allowing developers to ask "can user X currently access page Y?".

Rather than duplicating the permission checks performed in that view, you ask the view itself whether or not the user can access it.

Conforming Views

Conforming views must implement a .test_page_visibilty(request, *args, **kwargs) method. This will be called with the same args and kwargs that the actual view would be called with.

This method must return a truthy value if the user can access the page, and False otherwise. It may also raise an exception, to indicate that the user cannot access the page. See PAGE_VISIBILITY_EXCEPTIONS below.

The Test Function

Developers can call django_page_visibility.is_visible_to_user(path, user) (see the code for details) to test visibility. Or, in a template, you can use our is_permitted_to_see filter or permitted_link tag.

PAGE_VISIBILITY_EXCEPTIONS setting

By default, we return False if either django.http.Http404 or django.core.exceptions.PermissionDenied are raised. You can override this by setting (in your django settings) PAGE_VISIBILITY_EXCEPTIONS to a list of exception classes.

We expect most users to override this setting. For example, if you are using exceptional_auth and django_early_return, then you'll want to set:

PAGE_VISIBILITY_EXCEPTIONS = [
    'django.core.exceptions.PermissionDenied',
    'django.http.Http404',
    'django_early_return.EarlyReturn',
    'exceptional_auth.AuthException',
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_page_visibility-0.2.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

django_page_visibility-0.2.0-py2-none-any.whl (11.5 kB view details)

Uploaded Python 2

File details

Details for the file django_page_visibility-0.2.0.tar.gz.

File metadata

  • Download URL: django_page_visibility-0.2.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.10.1 urllib3/1.26.7 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for django_page_visibility-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bd4b842c5cfe08777a4b06460a36ab505775e17300a7e841c8454441a3a9e299
MD5 8e56b0ddd1473a75f12c357e916c1c29
BLAKE2b-256 c8c62aaa83039a5c12cf2579cecac329033553123afc4c5d6864bb1eaef0b3e2

See more details on using hashes here.

File details

Details for the file django_page_visibility-0.2.0-py2-none-any.whl.

File metadata

  • Download URL: django_page_visibility-0.2.0-py2-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.10.1 urllib3/1.26.7 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for django_page_visibility-0.2.0-py2-none-any.whl
Algorithm Hash digest
SHA256 27fa845f23f75ef40c86cbccda9187f5f476ac0a92490b4daf58d62cfd116096
MD5 cdfa08439a1ff1fed67d0cc06d53f579
BLAKE2b-256 4daf997fd02003b59407dc84b3793db84b9ce0ae87e1ab93039192cce1f3a6c9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page