(feature) Add Django retention apply flow
Expose retention apply from the host retention plan page so planned snapshot deletions can be executed from the Django UI. The form requires explicit host confirmation, carries through the selected retention kind and base-protection setting, and uses max_delete as a deletion guard. The view delegates to the SQL retention apply service and reports predictable pobsync errors back through Django messages instead of surfacing a server error. Add view coverage for confirmed deletion, invalid confirmation, and POST-only enforcement.
This commit is contained in:
@@ -133,6 +133,24 @@ class ManualBackupForm(forms.Form):
|
||||
)
|
||||
|
||||
|
||||
class RetentionApplyForm(forms.Form):
|
||||
kind = forms.ChoiceField(choices=(("scheduled", "Scheduled"), ("manual", "Manual"), ("all", "All")))
|
||||
protect_bases = forms.BooleanField(required=False)
|
||||
max_delete = forms.IntegerField(min_value=0, initial=10)
|
||||
confirm_host = forms.CharField()
|
||||
|
||||
def __init__(self, *args, host_name: str, **kwargs) -> None:
|
||||
self.host_name = host_name
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["confirm_host"].help_text = f"Type {host_name} to confirm deletion."
|
||||
|
||||
def clean_confirm_host(self) -> str:
|
||||
value = self.cleaned_data["confirm_host"].strip()
|
||||
if value != self.host_name:
|
||||
raise forms.ValidationError(f"Type {self.host_name} to confirm.")
|
||||
return value
|
||||
|
||||
|
||||
class ScheduleConfigForm(forms.ModelForm):
|
||||
cron_expr = forms.CharField(
|
||||
label="Cron expression",
|
||||
|
||||
Reference in New Issue
Block a user