mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-18 09:10:49 +00:00
backups: Rename the backups API module
- Also other minor refactoring. Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
d48ab72cf0
commit
0ce97005b2
@ -29,7 +29,7 @@ from plinth.errors import PlinthError
|
||||
from plinth.menu import main_menu
|
||||
from plinth.modules import storage
|
||||
|
||||
from .backups import backup_apps, restore_apps
|
||||
from . import api
|
||||
|
||||
version = 1
|
||||
|
||||
@ -100,7 +100,7 @@ def _backup_handler(packet):
|
||||
|
||||
|
||||
def create_archive(name, app_names):
|
||||
backup_apps(_backup_handler, app_names, name)
|
||||
api.backup_apps(_backup_handler, app_names, name)
|
||||
|
||||
|
||||
def delete_archive(name):
|
||||
@ -177,5 +177,5 @@ def _restore_handler(packet):
|
||||
def restore_exported(label, archive_name, apps=None):
|
||||
"""Restore files from exported backup archive."""
|
||||
filename = find_exported_archive(label, archive_name)
|
||||
restore_apps(_restore_handler, app_names=apps, create_subvolume=False,
|
||||
backup_file=filename)
|
||||
api.restore_apps(_restore_handler, app_names=apps, create_subvolume=False,
|
||||
backup_file=filename)
|
||||
|
||||
@ -25,7 +25,7 @@ from django.core import validators
|
||||
from django.core.validators import FileExtensionValidator
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from . import backups as backups_api
|
||||
from . import api
|
||||
from . import get_export_locations, get_archive_path, get_location_path
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ class CreateArchiveForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Initialize the form with selectable apps."""
|
||||
super().__init__(*args, **kwargs)
|
||||
apps = backups_api.get_all_apps_for_backup()
|
||||
apps = api.get_all_apps_for_backup()
|
||||
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]
|
||||
|
||||
@ -34,8 +34,7 @@ from django.views.generic import View, FormView, TemplateView
|
||||
|
||||
from plinth.modules import backups
|
||||
|
||||
from . import backups as backups_api, find_exported_archive
|
||||
from .forms import CreateArchiveForm, ExportArchiveForm, RestoreForm, UploadForm
|
||||
from . import api, find_exported_archive, forms
|
||||
|
||||
|
||||
subsubmenu = [{
|
||||
@ -60,14 +59,14 @@ class IndexView(TemplateView):
|
||||
context['archives'] = backups.list_archives()
|
||||
context['exports'] = backups.get_export_files()
|
||||
context['subsubmenu'] = subsubmenu
|
||||
apps = backups_api.get_all_apps_for_backup()
|
||||
apps = api.get_all_apps_for_backup()
|
||||
context['available_apps'] = [app[0] for app in apps]
|
||||
return context
|
||||
|
||||
|
||||
class CreateArchiveView(SuccessMessageMixin, FormView):
|
||||
"""View to create a new archive."""
|
||||
form_class = CreateArchiveForm
|
||||
form_class = forms.CreateArchiveForm
|
||||
prefix = 'backups'
|
||||
template_name = 'backups_form.html'
|
||||
success_url = reverse_lazy('backups:index')
|
||||
@ -134,7 +133,7 @@ class DownloadArchiveView(View):
|
||||
|
||||
|
||||
class UploadArchiveView(SuccessMessageMixin, FormView):
|
||||
form_class = UploadForm
|
||||
form_class = forms.UploadForm
|
||||
prefix = 'backups'
|
||||
template_name = 'backups_upload.html'
|
||||
success_url = reverse_lazy('backups:index')
|
||||
@ -157,7 +156,7 @@ class UploadArchiveView(SuccessMessageMixin, FormView):
|
||||
|
||||
class ExportArchiveView(SuccessMessageMixin, FormView):
|
||||
"""View to export an archive."""
|
||||
form_class = ExportArchiveForm
|
||||
form_class = forms.ExportArchiveForm
|
||||
prefix = 'backups'
|
||||
template_name = 'backups_form.html'
|
||||
success_url = reverse_lazy('backups:index')
|
||||
@ -181,7 +180,7 @@ class ExportArchiveView(SuccessMessageMixin, FormView):
|
||||
|
||||
class RestoreView(SuccessMessageMixin, FormView):
|
||||
"""View to restore files from an exported archive."""
|
||||
form_class = RestoreForm
|
||||
form_class = forms.RestoreForm
|
||||
prefix = 'backups'
|
||||
template_name = 'backups_restore.html'
|
||||
success_url = reverse_lazy('backups:index')
|
||||
@ -198,7 +197,7 @@ class RestoreView(SuccessMessageMixin, FormView):
|
||||
"""Pass additional keyword args for instantiating the form."""
|
||||
kwargs = super().get_form_kwargs()
|
||||
included_apps = self._get_included_apps()
|
||||
installed_apps = backups_api.get_all_apps_for_backup()
|
||||
installed_apps = api.get_all_apps_for_backup()
|
||||
kwargs['apps'] = [
|
||||
app for app in installed_apps if app[0] in included_apps
|
||||
]
|
||||
|
||||
@ -15,6 +15,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from plinth.modules.backups.backups import validate as validate_backup
|
||||
from plinth.modules.backups.api import validate as validate_backup
|
||||
|
||||
backup = validate_backup({'config': {'directories': ['/etc/ez-ipupdate/']}})
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.modules.backups.backups import validate as validate_backup
|
||||
from plinth.modules.backups.api import validate as validate_backup
|
||||
from plinth.clients import store_url, validate
|
||||
from plinth.modules.jsxc import manifest as jsxc_manifest
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.modules.backups.backups import validate as validate_backup
|
||||
from plinth.modules.backups.api import validate as validate_backup
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import cfg
|
||||
from plinth.modules.backups.backups import validate as validate_backup
|
||||
from plinth.modules.backups.api import validate as validate_backup
|
||||
from plinth.clients import validate
|
||||
from plinth.utils import format_lazy
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.modules.backups.backups import validate as validate_backup
|
||||
from plinth.modules.backups.api import validate as validate_backup
|
||||
from plinth.clients import store_url, validate
|
||||
|
||||
_android_package_id = 'im.vector.alpha'
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.modules.backups.backups import validate as validate_backup
|
||||
from plinth.modules.backups.api import validate as validate_backup
|
||||
from plinth.clients import validate
|
||||
|
||||
clients = validate([{
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.modules.backups.backups import validate as validate_backup
|
||||
from plinth.modules.backups.api import validate as validate_backup
|
||||
from plinth.clients import store_url, validate
|
||||
|
||||
clients = validate([{
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.modules.backups.backups import validate as validate_backup
|
||||
from plinth.modules.backups.api import validate as validate_backup
|
||||
from plinth.clients import store_url, validate
|
||||
|
||||
clients = validate([{
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth.modules.backups.backups import validate as validate_backup
|
||||
from plinth.modules.backups.api import validate as validate_backup
|
||||
from plinth.clients import store_url, validate
|
||||
|
||||
_jitsi_package_id = 'org.jitsi.meet'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user