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:
Joseph Nuthalapati authored and Sunil Mohan Adapa committed 2020-05-18 21:38:58 -07:00
1 parent 10924a1dca
commit f13ad07ecb
2 files changed
+6 -1

No files matched your search

+4
View File
@@ -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)
+2 -1
View File
@@ -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)