Projet

Général

Profil

0004-manager-set-created-user-s-OU-in-clean-43074.patch

Benjamin Dauvergne, 19 mai 2020 18:17

Télécharger (1,49 ko)

Voir les différences:

Subject: [PATCH 4/5] manager: set created user's OU in clean() (#43074)

Any modification to the model should be done trough clean() method, as
it enables later checks like uniqueness validation. No instance
initialization should ever be done in save() methods unless it's
garanteed that it cannot mess with validation.
 src/authentic2/manager/forms.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/authentic2/manager/forms.py
312 312
        super(UserAddForm, self).__init__(*args, **kwargs)
313 313

  
314 314
    def clean(self):
315
        self.instance.ou = self.ou
315 316
        super(UserAddForm, self).clean()
316 317
        # check if this account is going to be real online account, i.e. with a
317 318
        # password, it it's the case complain that there is no identifiers.
......
330 331
        return bool(self.cleaned_data.get('email'))
331 332

  
332 333
    def save(self, commit=True):
333
        self.instance.ou = self.ou
334 334
        user = super(UserAddForm, self).save(commit=commit)
335 335
        if self.cleaned_data.get('reset_password_at_next_login'):
336 336
            if commit:
337
-