def has_object_permission(self, getter_name):
        """
        Checks for object level permission for an arbitrary getter
        """
        obj = None
        obj_getter = getattr(self, getter_name, None)

        # get object requires pk
        if getter_name == "get_object" and 'pk' not in self.kwargs:
            return False

        if obj_getter:
            obj = obj_getter()
            if obj:
                return self.request.user.has_perm(getattr(self, 'permission', None), obj)
dataset/ETHPy150Open nyaruka/smartmin/smartmin/views.py/SmartView.has_object_permission/original