def form_valid(self, form): """Mark the first wizard step as done, save value and redirect.""" enabled = form.cleaned_data['backports_enabled'] upgrades.set_backports_requested(enabled) upgrades.setup_repositories(None) first_boot.mark_step_done('backports_wizard') return super().form_valid(form)
def activate_backports(request): """Activate backports.""" if request.method == 'POST': upgrades.set_backports_requested(True) upgrades.setup_repositories(None) messages.success(request, _('Frequent feature updates activated.')) return redirect(reverse_lazy('upgrades:index'))
def dispatch(self, request, *args, **kwargs): """Show backports configuration form only if it can be activated.""" if upgrades.is_backports_enabled(): # Backports is already enabled. Record this preference and # skip first boot step. upgrades.set_backports_requested(True) first_boot.mark_step_done('backports_wizard') return HttpResponseRedirect(reverse_lazy(first_boot.next_step())) if not upgrades.can_activate_backports(): # Skip first boot step. upgrades.set_backports_requested(False) first_boot.mark_step_done('backports_wizard') return HttpResponseRedirect(reverse_lazy(first_boot.next_step())) return super().dispatch(request, *args, *kwargs)