'Some fields may be excluded here. User can change only
permissions which are available for him. E.g. if user does not haves
can_publish flag, he can\'t change assign can_publish permissions.'

def get_formset(self, request, obj=None, **kwargs):

    exclude = (self.exclude or [])
    if obj:
        user = request.user
        if (not obj.has_add_permission(user)):
            exclude.append('can_add')
        if (not obj.has_delete_permission(user)):
            exclude.append('can_delete')
        if (not obj.has_publish_permission(user)):
            exclude.append('can_publish')
        if (not obj.has_advanced_settings_permission(user)):
            exclude.append('can_change_advanced_settings')
        if (not obj.has_move_page_permission(user)):
            exclude.append('can_move_page')
    kwargs['exclude'] = exclude
    formset_cls = super(PagePermissionInlineAdmin, self).get_formset(request, obj=obj, **kwargs)
    qs = self.get_queryset(request)
    if (obj is not None):
        qs = qs.filter(page=obj)
    formset_cls._queryset = qs
    return formset_cls
