django-nested-admin icon indicating copy to clipboard operation
django-nested-admin copied to clipboard

has_change_permission not working properly for NestedStackedPolymorphicInline

Open simchavc opened this issue 3 years ago • 1 comments

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.

simchavc avatar Mar 23 '22 15:03 simchavc

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.

DAWorm1 avatar Jul 17 '23 17:07 DAWorm1