[minor] [demo] form_dict

This commit is contained in:
Anand Doshi 2013-08-27 15:39:31 +05:30
parent 8d2e716697
commit cb4c0ea1d5
2 changed files with 35 additions and 14 deletions

View File

@ -406,7 +406,7 @@ def import_data(dt, submit=False):
for doctype in dt: for doctype in dt:
print "Importing", doctype.replace("_", " "), "..." print "Importing", doctype.replace("_", " "), "..."
webnotes.form_dict = _dict() webnotes.form_dict = webnotes._dict()
if submit: if submit:
webnotes.form_dict["params"] = json.dumps({"_submit": 1}) webnotes.form_dict["params"] = json.dumps({"_submit": 1})
webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", doctype+".csv") webnotes.uploaded_file = os.path.join(os.path.dirname(__file__), "demo_docs", doctype+".csv")

View File

@ -9,6 +9,23 @@ def make_demo_app():
utilities.demo.make_demo.make(reset=True) utilities.demo.make_demo.make(reset=True)
def make_demo_user(): def make_demo_user():
roles = ["Accounts Manager", "Analytics", "Expense Approver", "Accounts User",
"Leave Approver", "Blogger", "Customer", "Sales Manager", "Employee", "Support Manager",
"HR Manager", "HR User", "Maintenance Manager", "Maintenance User", "Material Manager",
"Material Master Manager", "Material User", "Partner", "Manufacturing Manager",
"Manufacturing User", "Projects User", "Purchase Manager", "Purchase Master Manager",
"Purchase User", "Quality Manager", "Report Manager", "Sales Master Manager",
"Sales User", "Supplier", "Support Team"]
def add_roles(bean):
for role in roles:
p.doclist.append({
"doctype": "UserRole",
"parentfield": "user_roles",
"role": role
})
# make demo user
if webnotes.conn.exists("Profile", "demo@erpnext.com"): if webnotes.conn.exists("Profile", "demo@erpnext.com"):
webnotes.delete_doc("Profile", "demo@erpnext.com") webnotes.delete_doc("Profile", "demo@erpnext.com")
@ -21,20 +38,24 @@ def make_demo_user():
p.doc.send_invite_email = 0 p.doc.send_invite_email = 0
p.doc.new_password = "demo" p.doc.new_password = "demo"
p.insert() p.insert()
add_roles(p)
p.save()
for role in ("Accounts Manager", "Analytics", "Expense Approver", "Accounts User", # make system manager user
"Leave Approver", "Blogger", "Customer", "Sales Manager", "Employee", "Support Manager", if webnotes.conn.exists("Profile", "admin@erpnext.com"):
"HR Manager", "HR User", "Maintenance Manager", "Maintenance User", "Material Manager", webnotes.delete_doc("Profile", "admin@erpnext.com")
"Material Master Manager", "Material User", "Partner", "Manufacturing Manager",
"Manufacturing User", "Projects User", "Purchase Manager", "Purchase Master Manager", p = webnotes.new_bean("Profile")
"Purchase User", "Quality Manager", "Report Manager", "Sales Master Manager", "Sales User", p.doc.email = "admin@erpnext.com"
"Supplier", "Support Team"): p.doc.first_name = "Admin"
p.doclist.append({ p.doc.last_name = "User"
"doctype": "UserRole", p.doc.enabled = 1
"parentfield": "user_roles", p.doc.user_type = "System User"
"role": role p.doc.send_invite_email = 0
}) p.doc.new_password = "admin010123"
p.insert()
roles.append("System Manager")
add_roles(p)
p.save() p.save()
# only read for newsletter # only read for newsletter