equal
deleted
inserted
replaced
1 from django.conf import settings |
1 from django.conf import settings |
2 from django.contrib.contenttypes.models import ContentType |
2 from django.contrib.contenttypes.models import ContentType |
3 from guardian.core import ObjectPermissionChecker |
|
4 from guardian.shortcuts import assign, remove_perm, get_users_with_perms, get_groups_with_perms |
3 from guardian.shortcuts import assign, remove_perm, get_users_with_perms, get_groups_with_perms |
5 |
4 from cache import get_checker_for |
6 |
5 |
7 try: |
6 try: |
8 from threading import local |
7 from threading import local |
9 except ImportError: |
8 except ImportError: |
10 from django.utils._threading_local import local |
9 from django.utils._threading_local import local |
102 model_name = obj_list[0].__class__.__name__.lower() |
101 model_name = obj_list[0].__class__.__name__.lower() |
103 ctype = ContentType.objects.get(model=model_name) |
102 ctype = ContentType.objects.get(model=model_name) |
104 cls = ctype.model_class() |
103 cls = ctype.model_class() |
105 |
104 |
106 if model_name in [cls_name.lower() for cls_name in settings.USE_GROUP_PERMISSIONS]: |
105 if model_name in [cls_name.lower() for cls_name in settings.USE_GROUP_PERMISSIONS]: |
107 checker = ObjectPermissionChecker(user) |
106 checker = get_checker_for(user) |
108 else: |
107 else: |
109 checker = None |
108 checker = None |
110 |
109 |
111 perm_name = "%s.change_%s" % (cls._meta.app_label, model_name) |
110 perm_name = "%s.change_%s" % (cls._meta.app_label, model_name) |
112 |
111 |