From 44331719a2adb1f5469020525607741342ddacfa Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 7 Jul 2023 16:44:48 +0200 Subject: 💄 open registration form: disabled by default - improve layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog/en/changelog_2022-06-15.md | 1 + changelog/fr/changelog_2023-01-25.md | 3 +- example_project/settings.py | 1 + ishtar_common/templates/registration/form.html | 34 ++++++++++++++++++++++ ishtar_common/templates/registration/login.html | 6 ++-- .../registration/password_change_form.html | 34 ---------------------- .../registration/registration_closed.html | 12 ++++++++ .../templates/registration/registration_form.html | 9 +++--- ishtar_common/urls_registration.py | 2 +- ishtar_common/views.py | 25 ++++++++++++++++ 10 files changed, 85 insertions(+), 42 deletions(-) create mode 100644 ishtar_common/templates/registration/form.html delete mode 100644 ishtar_common/templates/registration/password_change_form.html create mode 100644 ishtar_common/templates/registration/registration_closed.html diff --git a/changelog/en/changelog_2022-06-15.md b/changelog/en/changelog_2022-06-15.md index c2171b440..4333237a0 100644 --- a/changelog/en/changelog_2022-06-15.md +++ b/changelog/en/changelog_2022-06-15.md @@ -4,6 +4,7 @@ v4.0.54 - 2099-12-31 ### Features/improvements ### - wizards: automatic scroll on field when navigating with TAB key - update password form: improve layout - redirect to start page +- open registration form: disabled by default - improve layout v4.0.53 - 2023-07-06 diff --git a/changelog/fr/changelog_2023-01-25.md b/changelog/fr/changelog_2023-01-25.md index f9780efb1..2a68aaecd 100644 --- a/changelog/fr/changelog_2023-01-25.md +++ b/changelog/fr/changelog_2023-01-25.md @@ -3,7 +3,8 @@ v4.0.54 - 2099-12-31 ### Fonctionnalités/améliorations ### - `wizards` : défilement automatique sur le champ lorsque l'on navigue avec la touche TAB -- formulaire de mise à jour mot de passe : amélioration de la présentation - redirection vers la page d'accueil +- formulaire de mise à jour mot de passe : amélioration de la mise en page - redirection vers la page d'accueil +- formulaire d'inscription ouvert : désactivé par défaut - amélioration de la mise en page v4.0.53 - 2023-07-06 -------------------- diff --git a/example_project/settings.py b/example_project/settings.py index 55bc92465..3c0accc82 100644 --- a/example_project/settings.py +++ b/example_project/settings.py @@ -279,6 +279,7 @@ ISHTAR_SLUGS = { ISHTAR_MIGRATE_V4 = False +REGISTRATION_OPEN = False SRID = 4326 # WGS84 - World SURFACE_SRID = 4326 # WGS84 - World ENCODING = "windows-1252" diff --git a/ishtar_common/templates/registration/form.html b/ishtar_common/templates/registration/form.html new file mode 100644 index 000000000..f75a82c0f --- /dev/null +++ b/ishtar_common/templates/registration/form.html @@ -0,0 +1,34 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block content %} +
+
+
+

{{page_title}}

+
{% csrf_token %} + {% if form.non_field_errors %} +
+ {% for error in form.non_field_errors %} +
+ {{error}} +
+ {% endfor %} +
+ {% endif %} + {% with force_large_col=True %} + {% for field in form %} + {% include "blocks/bs_field_snippet.html" %} + {% endfor %} + {% endwith %} + +
+
+ +
+
+
+
+
+
+{% endblock %} diff --git a/ishtar_common/templates/registration/login.html b/ishtar_common/templates/registration/login.html index adefb3176..de7c28317 100644 --- a/ishtar_common/templates/registration/login.html +++ b/ishtar_common/templates/registration/login.html @@ -35,8 +35,10 @@
- {% trans "Forgot password?" %} {% trans "Reset it" %} – - {% trans "Not member?" %} {% trans "Register" %} + {% trans "Forgot password?" %} {% trans "Reset it" %} + {% if registration_open %}– + {% trans "Not member?" %} {% trans "Register" %} + {% endif %}
{% endblock %} diff --git a/ishtar_common/templates/registration/password_change_form.html b/ishtar_common/templates/registration/password_change_form.html deleted file mode 100644 index deb7af503..000000000 --- a/ishtar_common/templates/registration/password_change_form.html +++ /dev/null @@ -1,34 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% block content %} -
-
-
-

{% trans "Change password" %}

-
{% csrf_token %} - {% if form.non_field_errors %} -
- {% for error in form.non_field_errors %} -
- {{error}} -
- {% endfor %} -
- {% endif %} - {% with force_large_col=True %} - {% for field in form %} - {% include "blocks/bs_field_snippet.html" %} - {% endfor %} - {% endwith %} - -
-
- -
-
-
-
-
-
-{% endblock %} diff --git a/ishtar_common/templates/registration/registration_closed.html b/ishtar_common/templates/registration/registration_closed.html new file mode 100644 index 000000000..7e68ad378 --- /dev/null +++ b/ishtar_common/templates/registration/registration_closed.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block content %} +
+
+
+

{% trans "Registration are closed." %}

+
+
+
+{% endblock %} diff --git a/ishtar_common/templates/registration/registration_form.html b/ishtar_common/templates/registration/registration_form.html index b15f0e74b..e6c7c42e2 100644 --- a/ishtar_common/templates/registration/registration_form.html +++ b/ishtar_common/templates/registration/registration_form.html @@ -2,10 +2,11 @@ {% load i18n %} {% block content %} -
-
{% csrf_token %} - - +
+
+
+

{% trans "Register" %}

+ {% csrf_token %} {{ form.as_table }}
{% trans "Register" %}
diff --git a/ishtar_common/urls_registration.py b/ishtar_common/urls_registration.py index 085af2f87..97209646f 100644 --- a/ishtar_common/urls_registration.py +++ b/ishtar_common/urls_registration.py @@ -25,7 +25,7 @@ urlpatterns = [ registration_views.ActivationView.as_view(), name='registration_activate'), url(r'^accounts/register/$', - registration_views.RegistrationView.as_view(), + views.RegistrationView.as_view(), name='registration_register'), url(r'^accounts/register/complete/$', TemplateView.as_view( diff --git a/ishtar_common/views.py b/ishtar_common/views.py index c10da588a..64934a1d0 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -25,6 +25,7 @@ import json import logging import os import re +from registration import views as registration_views import unicodedata import urllib.parse @@ -177,6 +178,11 @@ def index(request): class LoginView(AuthLoginView): form_class = forms.AuthenticationForm + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["registration_open"] = settings.REGISTRATION_OPEN + return context + class LogoutView(AuthLogoutView): def get(self, request, *args, **kwargs): @@ -203,6 +209,7 @@ def update_password_last_update(user): class PasswordChangeView(AuthPasswordChangeView): form_class = forms.PasswordChangeForm success_url = reverse_lazy('start') + template_name = 'registration/form.html' def form_valid(self, form): returned = super().form_valid(form) @@ -210,6 +217,11 @@ class PasswordChangeView(AuthPasswordChangeView): messages.add_message(self.request, messages.INFO, _("Password changed")) return returned + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["page_title"] = _("Change password") + return context + class PasswordResetConfirmView(AuthPasswordResetConfirmView): def form_valid(self, form): @@ -218,6 +230,19 @@ class PasswordResetConfirmView(AuthPasswordResetConfirmView): return returned +class RegistrationView(registration_views.RegistrationView): + template_name = 'registration/form.html' + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["page_title"] = _("Register") + return context + + def register(self, form): + # TODO + raise NotImplementedError + + person_search_wizard = wizards.PersonSearch.as_view( [("general-person_search", forms.PersonFormSelection)], label=_("Person search"), -- cgit v1.2.3