mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
backups: Add optional field - Name
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> [sunil: Perform validation for name field] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
10924a1dca
commit
f13ad07ecb
@ -48,6 +48,10 @@ def _get_repository_choices():
|
||||
|
||||
class CreateArchiveForm(forms.Form):
|
||||
repository = forms.ChoiceField()
|
||||
name = forms.RegexField(
|
||||
label=_('Name'),
|
||||
help_text=_('(Optional) Set a name for this backup archive'),
|
||||
regex=r'^[^{}/]*$', required=False, strip=True)
|
||||
selected_apps = forms.MultipleChoiceField(
|
||||
label=_('Included apps'), help_text=_('Apps to include in the backup'),
|
||||
widget=forms.CheckboxSelectMultiple)
|
||||
|
||||
@ -66,7 +66,8 @@ class CreateArchiveView(SuccessMessageMixin, FormView):
|
||||
if repository.flags.get('mountable'):
|
||||
repository.mount()
|
||||
|
||||
name = datetime.now().strftime('%Y-%m-%d:%H:%M')
|
||||
name = form.cleaned_data['name'] or datetime.now().strftime(
|
||||
'%Y-%m-%d:%H:%M')
|
||||
selected_apps = form.cleaned_data['selected_apps']
|
||||
repository.create_archive(name, selected_apps)
|
||||
return super().form_valid(form)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user