/
permissions.py
48 lines (39 loc) · 1.26 KB
/
permissions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
Module that provides a base Permission class. This class may be overridden by changing the `PERMISSION_CLASS` value in the settings module.
"""
class Permissions(object):
"""
This class defines the methods that a Permission class should implement.
By default all permissions are granted to a staff user.
"""
def filter_objects(self, user, qs):
"""
Should only return those objects whose `user` is allowed to edit.
`qs` can consist of type `Page` or `ContentItem`.
"""
return qs
def filter_images(self, user, qs):
"""
Called by API while listing images.
"""
return qs
def filter_files(self, user, qs):
"""
Called by API while listing files.
"""
return qs
def can_edit(self, user, obj):
"""
Should return :const:`True` if user is allowed to edit `obj`.
"""
return user.is_staff
def can_move_page(self, user, page):
"""
Should return :const:`True` if user is allowed to move page.
"""
return user.is_staff
def object_created(self, user, obj):
"""
Called whenever a new instance has been created of one of Fiber's models by `user`.
"""
pass