mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-13 10:30:16 +00:00
backups: Simplify getting included apps during restoring
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
parent
f2528c434d
commit
f172925d9d
@ -32,7 +32,6 @@ from django.views.generic import FormView, TemplateView
|
|||||||
from plinth.modules import backups
|
from plinth.modules import backups
|
||||||
|
|
||||||
from . import backups as backups_api
|
from . import backups as backups_api
|
||||||
from . import find_exported_archive, get_export_apps
|
|
||||||
from .forms import CreateArchiveForm, ExportArchiveForm, RestoreForm
|
from .forms import CreateArchiveForm, ExportArchiveForm, RestoreForm
|
||||||
|
|
||||||
|
|
||||||
@ -134,29 +133,20 @@ class RestoreView(SuccessMessageMixin, FormView):
|
|||||||
success_url = reverse_lazy('backups:index')
|
success_url = reverse_lazy('backups:index')
|
||||||
success_message = _('Restored files from backup.')
|
success_message = _('Restored files from backup.')
|
||||||
|
|
||||||
def collect_data(self, label, name):
|
def _get_included_apps(self):
|
||||||
"""Save some data used to instantiate the form."""
|
"""Save some data used to instantiate the form."""
|
||||||
self.label = unquote(label)
|
label = unquote(self.kwargs['label'])
|
||||||
self.name = unquote(name)
|
name = unquote(self.kwargs['name'])
|
||||||
self.filename = find_exported_archive(self.label, self.name)
|
filename = backups.find_exported_archive(label, name)
|
||||||
self.installed_apps = backups_api.get_all_apps_for_backup()
|
return backups.get_export_apps(filename)
|
||||||
self.included_apps = get_export_apps(self.filename)
|
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
|
||||||
"""Save request parameters for later."""
|
|
||||||
self.collect_data(kwargs['label'], kwargs['name'])
|
|
||||||
return super().get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
|
||||||
"""Save request parameters for later."""
|
|
||||||
self.collect_data(kwargs['label'], kwargs['name'])
|
|
||||||
return super().post(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
"""Pass additional keyword args for instantiating the form."""
|
"""Pass additional keyword args for instantiating the form."""
|
||||||
kwargs = super().get_form_kwargs()
|
kwargs = super().get_form_kwargs()
|
||||||
|
included_apps = self._get_included_apps()
|
||||||
|
installed_apps = backups_api.get_all_apps_for_backup()
|
||||||
kwargs['apps'] = [
|
kwargs['apps'] = [
|
||||||
app for app in self.installed_apps if app[0] in self.included_apps
|
app for app in installed_apps if app[0] in included_apps
|
||||||
]
|
]
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user