mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
fix doc display
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user