Exemple #1
0
 def filter_queryset(self, request, queryset, view):
     user = request.user
     model_cls = queryset.model
     kwargs = {
         'app_label': model_cls._meta.app_label,
         'model_name': get_model_name(model_cls)
     }
     permission = self.perm_format % kwargs
     return guardian.shortcuts.get_objects_for_user(user, permission, queryset)
 def get_required_permissions(self, method, model_cls):
     """
     Given a model and an HTTP method, return the list of permission
     codes that the user is required to have.
     """
     kwargs = {
         'app_label': model_cls._meta.app_label,
         'model_name': get_model_name(model_cls)
     }
     return [perm % kwargs for perm in self.perms_map[method]]
 def get_required_object_permissions(self, method, model_cls):
     kwargs = {
         'app_label': model_cls._meta.app_label,
         'model_name': get_model_name(model_cls)
     }
     return [perm % kwargs for perm in self.perms_map[method]]