Skip to content

Commit 6d23440

Browse files
committed
Remove custom DjangoModelPermissions (Details: encode/django-rest-framework#8009)
1 parent 245585e commit 6d23440

File tree

3 files changed

+6
-23
lines changed

3 files changed

+6
-23
lines changed

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ GET https://api.example.org/accounts/?page=4&limit=100
3434

3535
# Permissions
3636

37-
## DjangoModelPermissions
38-
39-
Add ``view`` permission control.
40-
41-
Usage:
42-
43-
```
44-
from djangorestframework_ext.permissions import DjangoModelPermissions
45-
```
46-
4737
## IsCurrentUser
4838

4939
Determine whether the object is the current login user.

rest_framework_ext/permissions.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
1-
from rest_framework import permissions
1+
from rest_framework.permissions import BasePermission
22

33

4-
class DjangoModelPermissions(permissions.DjangoModelPermissions):
5-
def __init__(self):
6-
self.perms_map['GET'] = ['%(app_label)s.view_%(model_name)s']
7-
self.perms_map['OPTIONS'] = ['%(app_label)s.view_%(model_name)s']
8-
self.perms_map['HEAD'] = ['%(app_label)s.view_%(model_name)s']
9-
10-
11-
class IsCurrentUser(permissions.BasePermission):
4+
class IsCurrentUser(BasePermission):
125
def has_object_permission(self, request, view, obj):
136
return obj == request.user
147

158

16-
class IsSuperuser(permissions.BasePermission):
9+
class IsSuperuser(BasePermission):
1710
def has_permission(self, request, view):
1811
return bool(request.user and request.user.is_superuser)
1912

2013

21-
class ExportPermission(permissions.BasePermission):
14+
class ExportPermission(BasePermission):
2215
def has_permission(self, request, view):
2316
if view.action == 'export':
2417
model = view.get_queryset().model

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='djangorestframework-ext',
11-
version='0.19',
11+
version='0.20',
1212
url='https://github.com/zengqiu/django-rest-framework-ext',
1313
license='MIT',
1414
author='zengqiu',
@@ -18,7 +18,7 @@
1818
long_description_content_type='text/markdown',
1919
packages=find_packages(),
2020
platforms='any',
21-
install_requires=['django>=3.2', 'djangorestframework>=3.10.0'],
21+
install_requires=['django>=3.2', 'djangorestframework>=3.15'],
2222
python_requires='>=3.5',
2323
classifiers=[
2424
'Development Status :: 5 - Production/Stable',

0 commit comments

Comments
 (0)