seitime-frappe/webnotes/utils/install.py

34 lines
1.2 KiB
Python

# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
import webnotes
def after_install():
# reset installed apps for re-install
webnotes.conn.set_global("installed_apps", "[]")
# core users / roles
install_docs = [
{'doctype':'Profile', 'name':'Administrator', 'first_name':'Administrator',
'email':'admin@localhost', 'enabled':1},
{'doctype':'Profile', 'name':'Guest', 'first_name':'Guest',
'email':'guest@localhost', 'enabled':1},
{'doctype':'UserRole', 'parent': 'Administrator', 'role': 'Administrator',
'parenttype':'Profile', 'parentfield':'user_roles'},
{'doctype':'UserRole', 'parent': 'Guest', 'role': 'Guest',
'parenttype':'Profile', 'parentfield':'user_roles'},
{'doctype': "Role", "role_name": "Report Manager"}
]
for d in install_docs:
webnotes.bean(d).insert()
# all roles to admin
webnotes.bean("Profile", "Administrator").get_controller().add_roles(*webnotes.conn.sql_list("""
select name from tabRole"""))
# update admin password
from webnotes.auth import _update_password
_update_password("Administrator", webnotes.conf.get("admin_password"))
webnotes.conn.commit()