'Action which deletes the selected files and/or folders.
This action first displays a confirmation page whichs shows all the
deleteable files and/or folders, or, if the user has no permission on
one of the related childs (foreignkeys), a "permission denied" message.
Next, it deletes all selected files and/or folders and redirects back to
the folder.'

def delete_files_or_folders(self, request, files_queryset, folders_queryset):

    opts = self.model._meta
    app_label = opts.app_label
    if (not self.has_delete_permission(request)):
        raise PermissionDenied
    current_folder = self._get_current_action_folder(request, files_queryset, folders_queryset)
    all_protected = []
    using = router.db_for_write(self.model)
    (deletable_files, model_count_files, perms_needed_files, protected_files) = get_deleted_objects(files_queryset, files_queryset.model._meta, request.user, self.admin_site, using)
    (deletable_folders, model_count_folder, perms_needed_folders, protected_folders) = get_deleted_objects(folders_queryset, folders_queryset.model._meta, request.user, self.admin_site, using)
    all_protected.extend(protected_files)
    all_protected.extend(protected_folders)
    all_deletable_objects = [deletable_files, deletable_folders]
    all_perms_needed = perms_needed_files.union(perms_needed_folders)
    if request.POST.get(u'post'):
        if all_perms_needed:
            raise PermissionDenied
        n = (files_queryset.count() + folders_queryset.count())
        if n:
            for f in files_queryset:
                self.log_deletion(request, f, force_text(f))
                f.delete()
            folder_ids = set()
            for folder in folders_queryset:
                folder_ids.add(folder.id)
                folder_ids.update(folder.get_descendants().values_list(u'id', flat=True))
            for f in File.objects.filter(folder__in=folder_ids):
                self.log_deletion(request, f, force_text(f))
                f.delete()
            for f in folders_queryset:
                self.log_deletion(request, f, force_text(f))
                f.delete()
            self.message_user(request, (_(u'Successfully    deleted    %(count)d    files    and/or    folders.') % {u'count': n}))
        return None
    if (all_perms_needed or all_protected):
        title = _(u'Cannot    delete    files    and/or    folders')
    else:
        title = _(u'Are    you    sure?')
    context = self.admin_site.each_context(request)
    context.update({u'title': title, u'instance': current_folder, u'breadcrumbs_action': _(u'Delete    files    and/or    folders'), u'deletable_objects': all_deletable_objects, u'files_queryset': files_queryset, u'folders_queryset': folders_queryset, u'perms_lacking': all_perms_needed, u'protected': all_protected, u'opts': opts, u'is_popup': popup_status(request), u'filer_admin_context': AdminContext(request), u'root_path': reverse(u'admin:index'), u'app_label': app_label, u'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME})
    return render(request, u'admin/filer/delete_selected_files_confirmation.html', context)
