Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve redirection after login
Anna Siwik17dc66ac5a12
diff --git a/saleor/registration/views.py b/saleor/registration/views.pyindex 7bc8556281..36e629b38f 100644--- a/saleor/registration/views.py+++ b/saleor/registration/views.py@@ -29,6 +29,7 @@ def logout(request):def signup(request):+ import ipdb; ipdb.set_trace()form = SignupForm(request.POST or None)if form.is_valid():form.save()diff --git a/templates/account/partials/login_form.html b/templates/account/partials/login_form.htmlindex 9d59eed8f2..1c80d9430a 100644--- a/templates/account/partials/login_form.html+++ b/templates/account/partials/login_form.html@@ -6,7 +6,10 @@{% csrf_token %}<fieldset>{% bootstrap_form form %}- <input type="hidden" name="next" value="{{ next }}"/>+ {% if REDIRECT_FIELD_VALUE %}+ <input type="hidden" name="{{ REDIRECT_FIELD_NAME }}"+ value="{{ REDIRECT_FIELD_VALUE }}"/>+ {% endif %}</fieldset><div class="row login__btn-group"><div class="col-sm-12">diff --git a/tests/test_registration.py b/tests/test_registration.pyindex 2fa824c301..fd05a6aae3 100644--- a/tests/test_registration.py+++ b/tests/test_registration.py@@ -102,6 +102,16 @@ def test_signup_view_create_user(client, db):assert redirect_location == '/'+def test_signup_view_redirect(client, customer_user):+ url = reverse('account_signup')+ data = {+ 'email': '[email protected]', 'password': 'password',+ 'next': '/cart/'}+ response = client.post(url, data)+ redirect_location = get_redirect_location(response)+ assert redirect_location == '/cart/'++def test_signup_view_fail(client, db, customer_user):url = reverse('account_signup')data = {'email': customer_user.email, 'password': 'password'}