diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 709b59e44a5b5bb9170d57d593fe1ea7930f612d..5cd079bca115d28e7caccf0566ead90ac2b66fca 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,11 @@ Added * [OAuth] Allow apps to fill in their own claim data matching their scopes +Fixed +~~~~~ + +* View for assigning permissions didn't work with some global permissions. + `2.2.1_ – 2021-12-02 -------------------- diff --git a/aleksis/core/forms.py b/aleksis/core/forms.py index 7ea513368fadd60d63d48711b9f5bcfba80ffe52..40e6f91c250bfd15dd2dee238fd46295a9184a3a 100644 --- a/aleksis/core/forms.py +++ b/aleksis/core/forms.py @@ -5,6 +5,7 @@ from django import forms from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.auth.models import Permission +from django.contrib.sites.models import Site from django.core.exceptions import ValidationError from django.db.models import QuerySet from django.http import HttpRequest @@ -460,7 +461,13 @@ class AssignPermissionForm(forms.Form): super().__init__(*args, **kwargs) model_class = self.permission.content_type.model_class() - queryset = model_class.objects.all() + if model_class._meta.managed and not model_class._meta.abstract: + queryset = model_class.objects.all() + else: + # The following queryset is just a dummy one. It has no real meaning. + # We need it as there are permissions without real objects, + # but we want to use the same form. + queryset = Site.objects.none() self.fields["objects"].queryset = queryset search_fields = getattr(model_class, "get_filter_fields", lambda: [])()