From 461fe21a19e0431c7fa7b08e1d439fbea9abb06d Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sat, 1 Sep 2018 20:36:23 -0400 Subject: [PATCH] backups: Add apps selection to restore form Signed-off-by: James Valleroy Reviewed-by: Joseph Nuthalapati --- plinth/modules/backups/forms.py | 16 ++++++++++++++++ .../backups/templates/backups_restore.html | 2 ++ plinth/modules/backups/views.py | 17 +++++++++++------ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/plinth/modules/backups/forms.py b/plinth/modules/backups/forms.py index 2c221e948..e53745a7e 100644 --- a/plinth/modules/backups/forms.py +++ b/plinth/modules/backups/forms.py @@ -57,3 +57,19 @@ class ExportArchiveForm(forms.Form): """Initialize the form with disk choices.""" super().__init__(*args, **kwargs) self.fields['disk'].choices = get_export_locations() + + +class RestoreForm(forms.Form): + selected_apps = forms.MultipleChoiceField( + label=_('Restore apps'), + help_text=_('Apps data to restore from the backup'), + widget=forms.CheckboxSelectMultiple) + + def __init__(self, *args, **kwargs): + """Initialize the form with selectable apps.""" + super().__init__(*args, **kwargs) + apps = _list_of_all_apps_for_backup() + # TODO: Only list apps included in the backup file. + self.fields['selected_apps'].choices = [ + (app[0], app[1].name) for app in apps] + self.fields['selected_apps'].initial = [app[0] for app in apps] diff --git a/plinth/modules/backups/templates/backups_restore.html b/plinth/modules/backups/templates/backups_restore.html index 60bd3b8f1..a6917f3e3 100644 --- a/plinth/modules/backups/templates/backups_restore.html +++ b/plinth/modules/backups/templates/backups_restore.html @@ -47,6 +47,8 @@
{% csrf_token %} + {{ form|bootstrap }} +