Development #11324
Enhance registration frontend management.
100%
Description
The proposition breaks the compatibility with plugins but as far as I know, registration frontend management is for now only used with the FC plugin.
- Grab frontend from the plugin frontend class and not the plugin itself.
- Provide the templates with information on the frontend and not only the rendered html.
- Update registration_form template
The blocks building is largely inspired form the login frontend management.
Give more info to the template to freely define title is better than defining titles with a fixed level directly in the plugin.
Fichiers
Demandes liées
Révisions associées
update Frontend class to match recent authentic changes
commit c237f561bd866bb261ea2f082c91a4b607a8284a
Author: Mikaël Ates <mates@entrouvert.com>
Date: Mon Jun 13 16:50:45 2016 +0200
Enhance get backends helper function and registration frontend management
(fixes #11324).
Historique
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
- Lié à Development #11351: Déplacer le frontend registration du plugin vers la classe Frontend ajouté
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
Seul le thème montpellier utilise un thème différent pour registration_form.html et utilise les frontaux d'enregistrements des plugins. Le patch serait le suivant :
diff --git a/templates/registration/registration_form.html b/templates/registration/registration_form.html index 33dccf3..06b6868 100644 --- a/templates/registration/registration_form.html +++ b/templates/registration/registration_form.html @@ -11,13 +11,13 @@ </div> <div class="right"> -{% include 'authentic2/form.html' with form=form %} -{% for registration_frontend in registration_frontends %} + {% include 'authentic2/form.html' with form=form %} + {% if frontends.fc %} <div class="textbreak"><span>OU</span></div> - {{ registration_frontend|safe }} -{% endfor %} + <h2>{{ frontends.fc.name }}</h2> + {{ frontends.fc.content|safe }} + {% endif %} </div> <br class="clear"/> - {% endblock %} (END)
Mis à jour par Frédéric Péters il y a presque 8 ans
The proposition breaks the compatibility with plugins but as far as I know, registration frontend management is for now only used with the FC plugin.
It's also used for the belgian eid authentication (https://git.entrouvert.org/authentic2-auth-fedict.git/).
Mis à jour par Frédéric Péters il y a presque 8 ans
{% for id, block in frontends.items %} <br/> <h2>{{ block.name }}</h2> {{ block.content|safe }} {% endfor %}
I wouldn't add <br> to the markup, but I would enclose title/content in a <div class="whatever">.
if hasattr(frontend.name, '__call__'):
Use callable(). ?
blocks.append({ 'id': frontend.id(), 'name': frontend.name, 'content': response.content, 'frontend': frontend, })
Reading get_backends it allow .id not to be a callable, this is lost here. Maybe get_backends() could be changed to add a new attribute with the appropriate id instead of relying on callers to duplicate the work?
response = frontend.registration(self.request, context_instance=request_context) if not response or response.status_code != 200:
I understand the convenience of shortcut functions (like django.shortcuts.render) but this feels wrong to rely on HttpResponse here.
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
- Fichier 0001-Enhance-get-backends-helper-function-and-registratio.patch ajouté
- name and id attributes or methods of backends are now string attributes.
- only enabled backends are returned. If no enabled function is defined, it is enabled by default.
- finnaly, get_backends orders by priority.
The helper function get_backend_method is added to build a dic around the frontend method called.
Note that it is accepted that some login method return a http response with a status code different from 200, 302 for the LoginPasswordBackend for instance. If a frontend returns such a response, that http response is returned by the login view (it was the case before this patch).
<br> removed.
callable() used instead of testing call attribute.
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
- Fichier
0001-Enhance-registration-frontend-management.patchsupprimé
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
Concerning the belgian eid authentication plugin there is no concern since no registration_frontend method is defined on the plugin.
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
- Fichier 0001-Enhance-get-backends-helper-function-and-registratio.patch ajouté
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
- Fichier
0001-Enhance-get-backends-helper-function-and-registratio.patchsupprimé
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
- Fichier 0001-Enhance-get-backends-helper-function-and-registratio.patch ajouté
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
- Fichier
0001-Enhance-get-backends-helper-function-and-registratio.patchsupprimé
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
- Fichier
0001-Enhance-get-backends-helper-function-and-registratio.patchsupprimé
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
- Statut changé de Nouveau à Résolu (à déployer)
- % réalisé changé de 0 à 100
Appliqué par commit authentic2|c237f561bd866bb261ea2f082c91a4b607a8284a.
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
- Statut changé de Résolu (à déployer) à En cours
Mis à jour par Frédéric Péters il y a presque 8 ans
- Statut changé de En cours à Résolu (à déployer)
Nope, it's fine, I updated the plugin to fit the change.
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
Defining the Frontend id with an attribute or a method should not be a problem. Could you explain a little bit more ?
Mis à jour par Mikaël Ates (de retour le 29 avril) il y a presque 8 ans
I extended the practice
if hasattr(frontend.name, '__call__'): frontend.name = frontend.name()
to the id attribute, what broke authentic2-auth-fedict since id was defined as a method and used as it in the plugin, but redefined as not being callable by get_backends().
name and id should stay callable if they are defined callable in the plugin to avoid issues like this.
So It was given a partial answer to
Maybe get_backends() could be changed to add a new attribute with the appropriate id instead of relying on callers to duplicate the work?
So we could go back and let callers check those attributes. Or we could move plugins towards id and name attributes not being callable and modify them as it was done for authentic2-auth-fedict. Finally, we could go towards id and name being only callable.
Mis à jour par Benjamin Dauvergne il y a plus de 7 ans
- Statut changé de Résolu (à déployer) à Fermé
Enhance get backends helper function and registration frontend management (fixes #11324).