|
6 | 6 | from user.models import User, BlockedUser, LoginRequest |
7 | 7 |
|
8 | 8 |
|
9 | | -class PermissionQuerysetMixin: |
10 | | - permission_field_name = '' |
11 | | - |
12 | | - def formfield_for_manytomany(self, db_field, request=None, **kwargs): |
13 | | - if db_field.name == self.permission_field_name: |
14 | | - qs = kwargs.get("queryset", db_field.remote_field.model.objects) |
15 | | - # Avoid a major performance hit resolving permission names which |
16 | | - # triggers a content_type load: |
17 | | - kwargs["queryset"] = qs.filter(content_type__app_label='application', |
18 | | - content_type__model__in=['application', 'applicationlog']) |
19 | | - return super().formfield_for_manytomany(db_field, request=request, **kwargs) |
20 | | - |
21 | | - |
22 | | -class UserAdmin(PermissionQuerysetMixin, BaseUserAdmin): |
| 9 | +class UserAdmin(BaseUserAdmin): |
23 | 10 | permission_field_name = "user_permissions" |
24 | 11 |
|
25 | 12 | # The forms to add and change user instances |
@@ -50,7 +37,7 @@ class UserAdmin(PermissionQuerysetMixin, BaseUserAdmin): |
50 | 37 | filter_horizontal = () |
51 | 38 |
|
52 | 39 |
|
53 | | -class GroupAdmin(PermissionQuerysetMixin, BaseGroupAdmin): |
| 40 | +class GroupAdmin(BaseGroupAdmin): |
54 | 41 | permission_field_name = 'permissions' |
55 | 42 |
|
56 | 43 |
|
|
0 commit comments