Redirect to next step if AddOnsStep would show up empty (Z#23167007) (#4530)

This commit is contained in:
Mira
2024-10-21 13:27:43 +02:00
committed by GitHub
parent 2d9bfc80dc
commit f8df66e621

View File

@@ -47,6 +47,7 @@ from django.db import models
from django.db.models import Count, F, Q, Sum from django.db.models import Count, F, Q, Sum
from django.db.models.functions import Cast from django.db.models.functions import Cast
from django.http import HttpResponseNotAllowed, JsonResponse from django.http import HttpResponseNotAllowed, JsonResponse
from django.shortcuts import redirect
from django.utils import translation from django.utils import translation
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.utils.translation import ( from django.utils.translation import (
@@ -659,6 +660,8 @@ class AddOnsStep(CartMixin, AsyncAction, TemplateFlowStep):
self.request = request self.request = request
if 'async_id' in request.GET and settings.HAS_CELERY: if 'async_id' in request.GET and settings.HAS_CELERY:
return self.get_result(request) return self.get_result(request)
if len(self.forms) == 0 and len(self.cross_selling_data) == 0:
return redirect(self.get_next_url(request))
return TemplateFlowStep.get(self, request) return TemplateFlowStep.get(self, request)
def _clean_category(self, form, category): def _clean_category(self, form, category):