Skip to content

Saleor Core: the high performance, composable, headless commerce API.

First scrach of checkout login view

Mira Szewczyk880254136d1d
diff --git a/saleor/checkout/urls.py b/saleor/checkout/urls.py
index b700f8e999..7181219f4e 100644
--- a/saleor/checkout/urls.py
+++ b/saleor/checkout/urls.py
@@ -14,5 +14,6 @@ urlpatterns = [
url(r'^shipping-method/', load_checkout(views.shipping_method_view),
name='shipping-method'),
url(r'^summary/', load_checkout(views.summary_view), name='summary'),
- url(r'^remove_voucher/', load_checkout(remove_voucher_view), name='remove-voucher')
+ url(r'^remove_voucher/', load_checkout(remove_voucher_view), name='remove-voucher'),
+ url(r'^login/', load_checkout(views.alternative_login), name='login'),
]
diff --git a/saleor/checkout/views/__init__.py b/saleor/checkout/views/__init__.py
index 8b5ef73217..f9cee900d8 100644
--- a/saleor/checkout/views/__init__.py
+++ b/saleor/checkout/views/__init__.py
@@ -10,6 +10,7 @@ from .shipping import anonymous_user_shipping_address_view, user_shipping_addres
from .summary import summary_with_shipping_view, anonymous_summary_without_shipping, \
summary_without_shipping
+from allauth.account.views import LoginView
@validate_cart
@validate_is_shipping_required
@@ -55,3 +56,10 @@ def summary_view(request, checkout):
return summary_without_shipping(request, checkout)
else:
return anonymous_summary_without_shipping(request, checkout)
+
+
+@validate_cart
+def alternative_login(request, checkout):
+ if request.user.is_authenticated:
+ return redirect('checkout:index')
+ return TemplateResponse(request, 'checkout/alternative_login.html')
diff --git a/templates/cart/index.html b/templates/cart/index.html
index d438e5c4fc..13c3006400 100644
--- a/templates/cart/index.html
+++ b/templates/cart/index.html
@@ -97,7 +97,7 @@
</div>
<div class="cart__checkout row">
<div class="col-md-12">
- <a href="{% url "checkout:index" %}" class="btn primary float-md-right">{% trans "Checkout" %}</a>
+ <a href="{% url "checkout:login" %}" class="btn primary float-md-right">{% trans "Checkout" %}</a>
</div>
</div>
{% else %}
diff --git a/templates/checkout/alternative_login.html b/templates/checkout/alternative_login.html
new file mode 100644
index 0000000000..330f92dea7
--- /dev/null
+++ b/templates/checkout/alternative_login.html
@@ -0,0 +1,57 @@
+{% extends "base.html" %}
+{% load staticfiles %}
+{% load account socialaccount %}
+{% load i18n %}
+
+{% block title %}{% trans "Login" %} — {{ block.super }}{% endblock %}
+
+{% block content %}
+<div class="row login">
+ <div class="col-lg-10 offset-lg-1 col-xl-8 offset-xl-2">
+ <div class="row">
+ <div class="col-md-6">
+ <form method="post" action="{% url 'account_login' %}" novalidate>
+ {% csrf_token %}
+ <fieldset>
+ <h2>{% trans 'Log in' %}</h2>
+ <input type="hidden" name="next" name="next" value="{% url 'checkout:index' %}" />
+ </fieldset>
+ <div class="row login__btn-group">
+ <div class="col-lg-6">
+ <button class="btn primary">
+ {% trans "Log in" %}
+ </button>
+ </div>
+ <div class="col-lg-6">
+ <a href="{% url 'account_reset_password' %}">{% trans "Forgot password?" %}</a>
+ </div>
+ </div>
+ {% get_providers as socialaccount_providers %}
+ {% if socialaccount_providers %}
+ <p>{% trans "Want to use your social profile?" %}</p>
+ <p>
+ {% if facebook_login_url %}
+ <a class="btn btn-default" href="{% provider_login_url "facebook" method="oauth2" %}">
+ {% trans "Log in using Facebook" %}
+ </a>
+ {% endif %}
+ {% if google_login_url %}
+ <a class="btn btn-default" href="{% provider_login_url "google" %}"> {% trans "Log in using Google" %}</a>
+ {% endif %}
+ </p>
+ {% endif %}
+ </form>
+ </div>
+ <div class="col-md-6">
+ <div class="login__register-link">
+ <h2>{% trans "New customer?" %}</h2>
+ <h6>{% trans "Registration is not required!" %}</h6>
+ <img src="{% static 'img/pirate_login.png' %}" srcset="{% static 'img/pirate_cart.png' %} 1x, {% static 'img/pirate_login2x.png' %} 2x">
+ <p><a href="{% url 'checkout:index' %}" class="btn secondary">{% trans "Continue" %}</a></p>
+ </div>
+ </div>
+ </div>
+
+ </div>
+</div>
+{% endblock %}
\ No newline at end of file