theatlantic / django-nested-admin

Django admin classes that allow for nested inlines
http://django-nested-admin.readthedocs.org/
Other
715 stars 99 forks source link

has_change_permission not working properly for NestedStackedPolymorphicInline #217

Open 9Y0 opened 2 years ago

9Y0 commented 2 years ago

I have a polymorphic model Question with a submodel OpenQuestion. I use the following InlineAdmin:

class QuestionInline(SortableHiddenMixin, NestedStackedPolymorphicInline):
    model = Question

    class OpenQuestionInline(SortableHiddenMixin, NestedStackedPolymorphicInline.Child):
        model = OpenQuestion
        fields = (("description", "weight"), "position")

    child_inlines = (OpenQuestionInline,)

    def has_change_permission(self, request, obj=None):
        return False

    def has_add_permission(self, request, obj=None):
        return False

    def has_delete_permission(self, request, obj=None):
        return False

However, I can still change the description and weight field of the open question. afbeelding I'm also able to reorder them. When I save the object, these changes are not saved, but I think I still shouldn't be allowed to change the values. I also tried adding the has_..._permission methods to the OpenQuestionInline, but it did not seem that they were called.

DAWorm1 commented 1 year ago

I also have the same issue. My configuration is exactly the same (minus the SortableMixin). Regardless, I can still edit fields even when explicitly returning False in has_change_permission.