def delete_folder(folder):
 parent_folder = (folder.parent if folder.parent_id else None)
 parent_name = (parent_folder.name if parent_folder else _(u'Root'))
 subfolders = list(folder.children.all())
 message_bits = []
 if subfolders:
  for subfolder in subfolders:
   subfolder.move_to(parent_folder, u'last-child')
   subfolder.save()
  message_bits.append(_(u'{num} subfolders moved to {folder}.').format(num=len(subfolders), folder=parent_name))
 n_files = folder.files.count()
 if n_files:
  folder.files.update(folder=parent_folder)
  message_bits.append(_(u'{num} files moved to {folder}.').format(num=n_files, folder=parent_name))
 folder.delete()
 if subfolders:
  Folder._tree_manager.rebuild()
 message_bits.insert(0, (_(u'Folder %s deleted.') % folder.name))
 return u'\n'.join(message_bits)

def delete_folder ( folder ) : parent_folder = ( folder . parent if folder . parent_id else None ) parent_name = ( parent_folder . name if parent_folder else _ ( u'Root' ) ) subfolders = list ( folder . children . all ( ) ) message_bits = [ ] if subfolders : for subfolder in subfolders : subfolder . move_to ( parent_folder , u'last-child' ) subfolder . save ( ) message_bits . append ( _ ( u'{num} subfolders moved to {folder}.' ) . format ( num = len ( subfolders ) , folder = parent_name ) ) n_files = folder . files . count ( ) if n_files : folder . files . update ( folder = parent_folder ) message_bits . append ( _ ( u'{num} files moved to {folder}.' ) . format ( num = n_files , folder = parent_name ) ) folder . delete ( ) if subfolders : Folder . _tree_manager . rebuild ( ) message_bits . insert ( 0 , ( _ ( u'Folder %s deleted.' ) % folder . name ) ) return u'\n' . join ( message_bits )
delete a filer folder and move files and subfolders up to the parent .