def backups(request): form = BackupForm() if request.method == "POST": if "repository" in request.POST: form = BackupForm(request.POST) if form.is_valid(): form.save() return redirect("manage-backups") elif "remove" in request.POST: service = BackupService.objects.get(pk=request.POST["service"]) service.delete() return redirect("manage-backups") elif "toggle" in request.POST: service = BackupService.objects.get(pk=request.POST["service"]) service.enabled = not service.enabled service.save() return redirect("manage-backups") elif "trigger" in request.POST: settings_backup.delay() database_backup.delay() backup_service.delay(pk=request.POST["service"]) messages.success(request, _("Backup process triggered")) return redirect("manage-backups") context = { "services": BackupService.objects.all(), "menu_items": MENU, "menu_page": "backups", "form": form, "activate_form": ActivateForm(), } return render(request, "manage/backups.html", context)
def backups(request): form = BackupForm() if request.method == "POST": if 'repository' in request.POST: form = BackupForm(request.POST) if form.is_valid(): form.save() return redirect('manage-backups') elif 'remove' in request.POST: service = BackupService.objects.get(pk=request.POST['service']) service.delete() return redirect('manage-backups') elif 'toggle' in request.POST: service = BackupService.objects.get(pk=request.POST['service']) service.enabled = not service.enabled service.save() return redirect('manage-backups') elif 'trigger' in request.POST: backup_service.delay(pk=request.POST['service']) messages.success(request, _('Backup process triggered')) return redirect('manage-backups') context = { 'services': BackupService.objects.all(), 'menu_items': MENU, 'menu_page': 'backups', 'form': form, 'activate_form': ActivateForm(), } return render(request, "manage/backups.html", context)