snapshot: preserve trial lifecycle and product-grade expiry UX
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from workflows.trial import cleanup_trial_workspace_data, trial_cleanup_is_due
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Deletes operational trial data after trial expiry while keeping platform configuration.'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--force', action='store_true', help='Run cleanup even if the trial is not due yet.')
|
||||
parser.add_argument('--yes-delete', action='store_true', help='Confirm destructive cleanup.')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
if not options['yes_delete']:
|
||||
raise CommandError(_('Bitte mit --yes-delete bestätigen.'))
|
||||
if not options['force'] and not trial_cleanup_is_due():
|
||||
raise CommandError(_('Kein abgelaufener Trial mit aktiviertem Cleanup gefunden.'))
|
||||
|
||||
result = cleanup_trial_workspace_data()
|
||||
self.stdout.write(self.style.SUCCESS(_('Trial-Workspace bereinigt.')))
|
||||
for key, value in result.items():
|
||||
self.stdout.write(f'- {key}: {value}')
|
||||
Reference in New Issue
Block a user