apps: retire tous les champs d'enregistrement sauf mot de passe

This commit is contained in:
Benjamin Dauvergne 2019-05-23 15:34:31 +02:00
parent 31aa01e608
commit c2ccbb78a9
1 changed files with 8 additions and 0 deletions

View File

@ -366,6 +366,8 @@ class AppConfig(django.apps.AppConfig):
other_actions.append(RemoveFranceConnect())
def a2_hook_front_modify_form(self, view, form):
from django.forms.widgets import HiddenInput
if view.__class__.__name__ == 'EditProfile':
if form.instance and form.instance.attributes.validated:
for field in ('first_name', 'last_name', 'birthdate', 'title',
@ -378,7 +380,13 @@ class AppConfig(django.apps.AppConfig):
field.widget.attrs['maxlength'] = 128
elif view.__class__.__name__ == 'RegistrationCompletionView':
form.initial['preferred_username'] = view.token.get('last_name', '')
form.fields['preferred_username'].widget = HiddenInput()
form.initial['preferred_givenname'] = view.token.get('first_name', '')
form.fields['preferred_givenname'].widget = HiddenInput()
for name in form.fields:
if 'password' not in name and name not in ('preferred_username', 'preferred_givenname'):
form.fields.pop(name)
def a2_hook_api_modify_queryset(self, view, queryset):
from django.utils.timezone import now