@@ -25,12 +25,12 @@ A custom permission is a simple method of the permission class::
25
25
class FlatpagePermission(permissions.BasePermission):
26
26
label = 'flatpage_permission'
27
27
checks = ('my_custom_check',)
28
-
28
+
29
29
def my_custom_check(self, flatpage):
30
30
if(flatpage.url == '/about/'):
31
31
return True
32
32
return False
33
-
33
+
34
34
authority.register(Flatpage, FlatpagePermission)
35
35
36
36
Note that we first added the name of your custom permission to the ``checks``
@@ -47,7 +47,7 @@ permission is True or False::
47
47
return True
48
48
return False
49
49
50
- .. warning:: Although it's possible to return other values than ``True``, for
50
+ .. warning:: Although it's possible to return other values than ``True``, for
51
51
example an object which also evluates to True, we highly advise to only
52
52
return booleans.
53
53
@@ -86,7 +86,7 @@ In your python code
86
86
::
87
87
88
88
from myapp.permissions import FlatPagePermission
89
- def my_view(request):
89
+ def my_view(request):
90
90
check = FlatPagePermission(request.user)
91
91
flatpage_object = Flatpage.objects.get(url='/homepage/')
92
92
if check.my_custom_check(flatpage=flatpage_object):
@@ -103,9 +103,9 @@ Using the view decorator
103
103
(Flatpage, 'url__iexact', 'url')) # The flatpage_object
104
104
def my_view(request, url):
105
105
# ...
106
-
106
+
107
107
See :ref:`check-decorator` how the decorator works in detail.
108
-
108
+
109
109
In your templates
110
110
-----------------
111
111
::
0 commit comments