fix doc display

This commit is contained in:
imperosol
2025-01-14 17:14:59 +01:00
parent 9b5f08e13c
commit 9272f53bea
6 changed files with 63 additions and 28 deletions

View File

@ -3,7 +3,8 @@
Some permissions are global (like `IsInGroup` or `IsRoot`),
and some others are per-object (like `CanView` or `CanEdit`).
Examples:
Example:
```python
# restrict all the routes of this controller
# to subscribed users
@api_controller("/foo", permissions=[IsSubscriber])
@ -33,6 +34,7 @@ Examples:
]
def bar_delete(self, bar_id: int):
# ...
```
"""
from typing import Any

View File

@ -21,6 +21,7 @@
# Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
from __future__ import annotations
import types
import warnings
@ -30,11 +31,11 @@ from django.contrib.auth.mixins import AccessMixin, PermissionRequiredMixin
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
from django.views.generic.base import View
from core.models import User
if TYPE_CHECKING:
from django.db.models import Model
from core.models import User
def can_edit_prop(obj: Any, user: User) -> bool:
"""Can the user edit the properties of the object.
@ -46,7 +47,7 @@ def can_edit_prop(obj: Any, user: User) -> bool:
Returns:
True if user is authorized to edit object properties else False
Examples:
Example:
```python
if not can_edit_prop(self.object ,request.user):
raise PermissionDenied
@ -65,7 +66,7 @@ def can_edit(obj: Any, user: User) -> bool:
Returns:
True if user is authorized to edit object else False
Examples:
Example:
```python
if not can_edit(self.object, request.user):
raise PermissionDenied
@ -86,7 +87,7 @@ def can_view(obj: Any, user: User) -> bool:
Returns:
True if user is authorized to see object else False
Examples:
Example:
```python
if not can_view(self.object ,request.user):
raise PermissionDenied