Login form.
authorRadek Czajka <rczajka@rczajka.pl>
Thu, 20 Oct 2022 10:29:58 +0000 (12:29 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Thu, 20 Oct 2022 10:29:58 +0000 (12:29 +0200)
src/wolnelektury/forms.py
src/wolnelektury/static/2022/more.scss
src/wolnelektury/templates/registration/login.html [new file with mode: 0644]
src/wolnelektury/views.py

index 1804065..f04501f 100644 (file)
@@ -2,12 +2,16 @@
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 from allauth.socialaccount.forms import SignupForm
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 from allauth.socialaccount.forms import SignupForm
-from django.contrib.auth.forms import UserCreationForm
+from django.contrib.auth.forms import AuthenticationForm, UserCreationForm
 from django.contrib.auth.models import User
 
 from newsletter.forms import NewsletterForm
 
 
 from django.contrib.auth.models import User
 
 from newsletter.forms import NewsletterForm
 
 
+class WLAuthenticationForm(AuthenticationForm):
+    template_name = '2022/form.html'
+
+
 # has to be this order, because otherwise the form is lacking fields
 class RegistrationForm(UserCreationForm, NewsletterForm):
     data_processing_part2 = '''\
 # has to be this order, because otherwise the form is lacking fields
 class RegistrationForm(UserCreationForm, NewsletterForm):
     data_processing_part2 = '''\
index 89621ce..06a4627 100644 (file)
@@ -273,4 +273,16 @@ form {
         line-height: 150%;
         margin-bottom: 30px;
     }
         line-height: 150%;
         margin-bottom: 30px;
     }
+
 }
 }
+
+.socialaccount_providers {
+    list-style: none;
+    padding: 0;
+
+    li {
+        display: inline-block;
+        margin-right: 10px;
+    }
+}
+
diff --git a/src/wolnelektury/templates/registration/login.html b/src/wolnelektury/templates/registration/login.html
new file mode 100644 (file)
index 0000000..691d3db
--- /dev/null
@@ -0,0 +1,50 @@
+{% extends "2022/base.html" %}
+{% load i18n %}
+
+{% block content %}
+  <div class="l-container">
+    <div class="l-breadcrumb">
+      <a href="/"><span>Strona główna</span></a>
+      <a>Zaloguj się</a>
+    </div>
+  </div>
+
+  <main class="l-main">
+    <div class="l-checkout__box" style="margin-bottom: 70px;">
+      <div class="l-checkout__box__header">
+        <div class="l-checkout__box__header__content">
+          <h1>Zaloguj się</h1>
+        </div>
+      </div>
+      <div class="l-checkout__cols">
+        <div class="l-checkout__col"></div>
+        <div class="l-checkout__col">
+          <form method="post">
+            <div class="l-checkout__form">
+              {% csrf_token %}
+              {{ form }}
+              <div class="l-checkout__form__row confirm">
+                <div class="l-checkout__input">
+                  <button style="margin-left:0">Dalej</button>
+                </div>
+              </div>
+
+              <a href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
+            </div>
+          </form>
+
+          {% if USE_OPENID %}
+            <h3>{% trans "Sign in using:" %}</h3>
+
+            <ul class="socialaccount_providers">
+              {% include "socialaccount/snippets/provider_list.html" %}
+            </ul>
+
+            {% include "socialaccount/snippets/login_extra.html" %}
+          {% endif %}
+
+        </div>
+      </div>
+    </div>
+  </main>
+{% endblock %}
index 1855222..593a7ba 100644 (file)
@@ -10,6 +10,7 @@ from django.conf import settings
 from django.contrib import auth
 from django.contrib.auth.decorators import login_required
 from django.contrib.auth.forms import AuthenticationForm
 from django.contrib import auth
 from django.contrib.auth.decorators import login_required
 from django.contrib.auth.forms import AuthenticationForm
+from django.contrib.auth.views import LoginView
 from django.core.cache import cache
 from django.http import HttpResponse, HttpResponseRedirect
 from django.shortcuts import render
 from django.core.cache import cache
 from django.http import HttpResponse, HttpResponseRedirect
 from django.shortcuts import render
@@ -21,7 +22,7 @@ from ajaxable.utils import placeholdized
 from catalogue.models import Book, Collection, Tag, Fragment
 
 from social.utils import get_or_choose_cite
 from catalogue.models import Book, Collection, Tag, Fragment
 
 from social.utils import get_or_choose_cite
-from wolnelektury.forms import RegistrationForm, SocialSignupForm
+from wolnelektury.forms import RegistrationForm, SocialSignupForm, WLAuthenticationForm
 
 
 @never_cache
 
 
 @never_cache
@@ -72,6 +73,13 @@ def main_page(request):
     return render(request, "main_page.html", ctx)
 
 
     return render(request, "main_page.html", ctx)
 
 
+class WLLoginView(LoginView):
+    form_class = WLAuthenticationForm
+
+
+wl_login_view = WLLoginView.as_view()
+
+
 class LoginFormView(AjaxableFormView):
     form_class = AuthenticationForm
     template = "auth/login.html"
 class LoginFormView(AjaxableFormView):
     form_class = AuthenticationForm
     template = "auth/login.html"
@@ -81,6 +89,9 @@ class LoginFormView(AjaxableFormView):
     ajax_redirect = True
 
     def __call__(self, request):
     ajax_redirect = True
 
     def __call__(self, request):
+        if request.EXPERIMENTS['layout'].value:
+            return wl_login_view(request)
+
         if request.user.is_authenticated:
             return self.redirect_or_refresh(
                 request, '/',
         if request.user.is_authenticated:
             return self.redirect_or_refresh(
                 request, '/',