better login/register page (new default login)
authorJan Szejko <janek37@gmail.com>
Tue, 8 May 2018 11:09:48 +0000 (13:09 +0200)
committerJan Szejko <janek37@gmail.com>
Tue, 8 May 2018 11:09:48 +0000 (13:09 +0200)
src/ajaxable/templates/ajaxable/form.html
src/wolnelektury/settings/auth.py
src/wolnelektury/templates/auth/login_register.html
src/wolnelektury/templates/auth/register.html
src/wolnelektury/templates/auth/register_form.html [new file with mode: 0644]
src/wolnelektury/views.py

index 3363bc8..0af34f4 100755 (executable)
@@ -3,7 +3,7 @@
 
 <h1>{{ title }}</h1>
 
-<form action="{{ action }}" method="post" accept-charset="utf-8"
+<form action="{% if action_url %}{% url action_url %}{% else %}{{ action }}{% endif %}{% if action_query %}?{{ action_query }}{% endif %}" method="post" accept-charset="utf-8"
       class="cuteform{% if placeholdize %} hidelabels{% endif %}">
   {% ssi_csrf_token %}
   {% if honeypot %}
index 2034db7..e704dc6 100644 (file)
@@ -7,7 +7,7 @@ AUTHENTICATION_BACKENDS = [
     # 'allauth.account.auth_backends.AuthenticationBackend',
 ]
 ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 2
-LOGIN_URL = '/uzytkownik/login/'
+LOGIN_URL = '/uzytkownik/zaloguj-utworz/'
 
 LOGIN_REDIRECT_URL = '/'
 
index 31d137c..6be2054 100755 (executable)
@@ -6,16 +6,5 @@
 {% block extra %}
   {{ block.super }}
 
-  <h1>{% trans "or register" %}:</h1>
-
-  <form action="{% url 'register' %}" method="post" accept-charset="utf-8"
-        class="cuteform hidelabels">
-    {% ssi_csrf_token %}
-    {% render_honeypot_field %}
-    <ol>
-      <div id="id_register-__all__"></div>
-      {{ register_form.as_ul }}
-      <li><input type="submit" value="{{ register_submit }}"/></li>
-    </ol>
-  </form>
+  {% include "auth/register_form.html" with form=register_form title=_("or register") action_url='register' action_query=request.GET.urlencode honeypot=True submit=register_submit %}
 {% endblock %}
index 967fc6f..6849438 100644 (file)
@@ -1,27 +1,16 @@
-{% extends "ajaxable/form.html" %}
 {% load i18n %}
-{% load ajaxable_tags %}
 
 
-{% block form_fields %}
-  {{ form.username|pretty_field }}
-  {{ form.email|pretty_field }}
-  {{ form.password1|pretty_field }}
-  {{ form.password2|pretty_field }}
-  {{ form.agree_newsletter|pretty_checkbox }}
-{% endblock %}
-
-
-{% block extra %}
+{% include "auth/register_form.html" %}
 
 {% if USE_OPENID %}
-<h1>{% trans "Sign in using:" %}</h1>
+  <div class="form-extra">
+    <h1>{% trans "Sign in using:" %}</h1>
 
-<ul class="socialaccount_providers">
-  {% include "socialaccount/snippets/provider_list.html" %}
-</ul>
+    <ul class="socialaccount_providers">
+      {% include "socialaccount/snippets/provider_list.html" %}
+    </ul>
 
-{% include "socialaccount/snippets/login_extra.html" %}
+    {% include "socialaccount/snippets/login_extra.html" %}
+  </div>
 {% endif %}
-
-{% endblock %}
diff --git a/src/wolnelektury/templates/auth/register_form.html b/src/wolnelektury/templates/auth/register_form.html
new file mode 100644 (file)
index 0000000..d9fb6a1
--- /dev/null
@@ -0,0 +1,11 @@
+{% extends "ajaxable/form.html" %}
+{% load ajaxable_tags %}
+
+
+{% block form_fields %}
+  {{ form.username|pretty_field }}
+  {{ form.email|pretty_field }}
+  {{ form.password1|pretty_field }}
+  {{ form.password2|pretty_field }}
+  {{ form.agree_newsletter|pretty_checkbox }}
+{% endblock %}
\ No newline at end of file
index c62c2e5..6108122 100644 (file)
@@ -115,7 +115,7 @@ class LoginRegisterFormView(LoginFormView):
 
     def extra_context(self, request, obj):
         return {
-            "register_form": placeholdized(UserCreationForm(prefix='register')),
+            "register_form": placeholdized(RegistrationForm(prefix='register')),
             "register_submit": _('Register'),
         }