backups: Rename the backups API module

- Also other minor refactoring.

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2018-09-28 11:04:21 -07:00 committed by James Valleroy
parent d48ab72cf0
commit 0ce97005b2
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
13 changed files with 22 additions and 23 deletions

View File

@ -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)

View File

@ -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]

View File

@ -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
]

View File

@ -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/']}})

View File

@ -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

View File

@ -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([{

View File

@ -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

View File

@ -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'

View File

@ -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([{

View File

@ -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([{

View File

@ -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([{

View File

@ -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'