(self, view)
return new_permissions
Return a clone of the permission wrapper with a new view bind to it.
Return a clone of the permission wrapper with a new view bind to it.
Return a clone of the permission wrapper with a new view bind to it .
def bind_view(self, view):
        '''
        Return a clone of the permission wrapper with a new view bind to it.
        '''
        if isinstance(view, str):
            if view not in self.view_name_mapping:
                return ''
            view_name = self.view_name_mapping[view]
            view = getattr(self._model_admin, view_name).view
        # we don't support binding view classes yet, only the name of views
        # are processed. We have the problem with view classes that we cannot
        # tell which model admin it was attached to.
        else:
            return ''
        # if view is a class and not instantiated yet, do it!
        if isinstance(view, type):
            view = view(
                request=self._request,
                **self._model_admin.get_default_view_kwargs())
        new_permissions = self.clone()
        new_permissions._view = view
        return new_permissions
def bind_view ( self , view ) : if isinstance ( view , str ) : if view not in self . view_name_mapping : return '' view_name = self . view_name_mapping [ view ] view = getattr ( self . _model_admin , view_name ) . view # we don't support binding view classes yet, only the name of views # are processed. We have the problem with view classes that we cannot # tell which model admin it was attached to. else : return '' # if view is a class and not instantiated yet, do it! if isinstance ( view , type ) : view = view ( request = self . _request , * * self . _model_admin . get_default_view_kwargs ( ) ) new_permissions = self . clone ( ) new_permissions . _view = view return new_permissions