django-page-visibility-0.1.2
توضیحات
Implements a function to test whether a given url is currently visible to a given user.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | django-page-visibility-0.1.2 |
| نام | django-page-visibility |
| نسخه کتابخانه | 0.1.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Alex Fischer |
| ایمیل نویسنده | alex@quadrant.net |
| آدرس صفحه اصلی | https://github.com/quadrant-newmedia/django_page_visibility |
| آدرس اینترنتی | https://pypi.org/project/django-page-visibility/ |
| مجوز | - |
# 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:
```python
PAGE_VISIBILITY_EXCEPTIONS = [
'django.core.exceptions.PermissionDenied',
'django.http.Http404',
'django_early_return.EarlyReturn',
'exceptional_auth.AuthException',
]
```
نیازمندی
| مقدار | نام |
|---|---|
| <4,>=2.2 | Django |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl django-page-visibility-0.1.2:
pip install django-page-visibility-0.1.2.whl
نصب پکیج tar.gz django-page-visibility-0.1.2:
pip install django-page-visibility-0.1.2.tar.gz