@@ -19,10 +19,10 @@ Lets start with an example permission::
19
19
class FlatpagePermission(permissions.BasePermission):
20
20
label = 'flatpage_permission'
21
21
checks = ('can_do_foo',)
22
-
22
+
23
23
def can_do_foo(self):
24
24
# ...
25
-
25
+
26
26
authority.register(Campaign, FlatpagePermission)
27
27
28
28
A decorator for such a simple view would look like::
@@ -53,12 +53,12 @@ a string on the decorator::
53
53
@permission_required('flatpage_permission.can_do_foo', 'arg1', 'arg2')
54
54
def my_view(required, arg1, arg2):
55
55
# ...
56
-
56
+
57
57
What happens under the hood?::
58
58
59
59
# Assumed the view gets called like this
60
60
my_view(request, 'bla', 'blubb')
61
-
61
+
62
62
# At the end, the decorator would been called like this
63
63
can_do_foo('bla', 'blubb')
64
64
@@ -78,9 +78,9 @@ Here is an example::
78
78
# permission.py
79
79
def can_do_foo(self, flatpage_instance=None):
80
80
# ...
81
-
82
- # views.py
83
- from django.contrib.flatpages.models import Flatpage
81
+
82
+ # views.py
83
+ from django.contrib.flatpages.models import Flatpage
84
84
@permission_required('flatpage_permission.can_do_foo', (Flatpage, 'url__iexact', 'url))
85
85
def flatpage(required, url):
86
86
# ...
0 commit comments