misc/migration/3.15.4_Any.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 18 Dec 2015 09:23:23 +0100
changeset 11033 63d860a14a17
parent 10589 7c23b7de2b8d
permissions -rw-r--r--
[schema] Use TZDatetime for creation_date and modification_date No work has been done for form fields/widgets since creation_date / modification_date are by default not editable through the default UI. One may want to add such feature at some point. Time will be displayed as UTC, let the end-application decide otherwise by customizing the tzdatetime printer if desired. Closes #4848923

from __future__ import print_function

from logilab.common.shellutils import generate_password
from cubicweb.server.utils import crypt_password

for user in rql('CWUser U WHERE U cw_source S, S name "system", U upassword P, U login L').entities():
    salt = user.upassword.getvalue()
    if crypt_password('', salt) == salt:
        passwd = generate_password()
        print('setting random password for user %s' % user.login)
        user.set_attributes(upassword=passwd)

commit()