misc/migration/3.15.4_Any.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Thu, 11 Sep 2014 16:43:20 +0200
changeset 9976 457efde98629
parent 8522 85b1c4b36d1d
child 10589 7c23b7de2b8d
permissions -rw-r--r--
[views] Display attributes in entity creation form based on "add" permission Previously, the "update" permission was used. Hence in case the latter is more restrictive that the "add" permission, an user may not be able to set such an attribute, despite she may have "add" permission on it. As a result of the change of permissions action in `editable_attributes` method (add/update depending on whether the entity is being created or modified), the "eid" attribute would have shown up in the edition form. To avoid this, it is moved in the "hidden" section (where it should arguably belong anyways). Closes #4342844.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8522
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     1
from logilab.common.shellutils import generate_password
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     2
from cubicweb.server.utils import crypt_password
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     3
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     4
for user in rql('CWUser U WHERE U cw_source S, S name "system", U upassword P, U login L').entities():
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     5
    salt = user.upassword.getvalue()
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     6
    if crypt_password('', salt) == salt:
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     7
        passwd = generate_password()
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     8
        print 'setting random password for user %s' % user.login
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     9
        user.set_attributes(upassword=passwd)
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    10
85b1c4b36d1d migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    11
commit()