@@ -0,0 +1,1636 @@
+import importlib%0Aimport logging%0Aimport os%0Aimport shutil%0A%0Amainapp_database = importlib.import_module('third_party.3dmr.mainapp.database')%0Amainapp_upload = getattr(mainapp_database, 'upload')%0Amainapp_models = importlib.import_module('third_party.3dmr.mainapp.models')%0Amainapp_model = getattr(mainapp_models, 'Model')%0Amainapp_location = getattr(mainapp_models, 'Location')%0Amainapp_change = getattr(mainapp_models, 'Change')%0AMODEL_DIR = getattr(importlib.import_module('third_party.3dmr.mainapp.utils'), 'MODEL_DIR')%0A%0Alogger = logging.getLogger(__name__)%0A%0Adef run(*args):%0A    %22%22%22Will **DELETE ALL MODELS** in DB and on storage.%0A%0A    This is dangerous and there is no going back. Use wisely.%0A    %22%22%22%0A    logger.info('Deleting all models and data.')%0A%0A    logger.info('Cearing database model entries.')%0A    mainapp_model.objects.all().delete()%0A    mainapp_location.objects.all().delete()%0A    mainapp_change.objects.all().delete()%0A%0A    logger.info('Deleting all modle files on disk.')%0A    failed_paths = %5B%5D%0A    for root, dirs, files in os.walk(MODEL_DIR):%0A        for dir_name in dirs:%0A            target_dir = os.path.join(root, dir_name)%0A            logger.info('Deleting %7B%7D'.format(target_dir))%0A            try:%0A                shutil.rmtree(target_dir)%0A            except Exception as e:%0A                failed_paths.append(target_dir)%0A                logger.error('Failed to delete %7B%7D for Reason: %7B%7D'.format(target_dir, e))%0A%0A%0A    if failed_paths:%0A        logger.error('Failed to delete all models on disk: %7B%7D'.format(failed_paths))%0A    else:%0A        logger.info('No failed deletions.')%0A%0A    logger.info('Delete all models job completed.')%0A

Add admin script to clear all models on disk and flush mainapp_model, mainapp_latestmodel and mainapp_location tables.