本文整理汇总了Python中webnotes.model.doc.Document.user_type方法的典型用法代码示例。如果您正苦于以下问题:Python Document.user_type方法的具体用法?Python Document.user_type怎么用?Python Document.user_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webnotes.model.doc.Document
的用法示例。
在下文中一共展示了Document.user_type方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import user_type [as 别名]
def add_profile(args):
from webnotes.utils import validate_email_add
from webnotes.model.doc import Document
email = args['user']
sql = webnotes.conn.sql
if not email:
email = webnotes.form_dict.get('user')
if not validate_email_add(email):
raise Exception
return 'Invalid Email Id'
if sql("select name from tabProfile where name = %s", email):
# exists, enable it
sql("update tabProfile set enabled = 1, docstatus=0 where name = %s", email)
webnotes.msgprint('Profile exists, enabled it')
else:
# does not exist, create it!
pr = Document('Profile')
pr.name = email
pr.email = email
pr.first_name = args.get('first_name')
pr.last_name = args.get('last_name')
pr.enabled = 1
pr.user_type = 'System User'
pr.save(1)
if args.get('password'):
sql("""
UPDATE tabProfile
SET password = PASSWORD(%s)
WHERE name = %s""", (args.get('password'), email))
示例2: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import user_type [as 别名]
def add_profile(email):
from webnotes.utils import validate_email_add
from webnotes.model.doc import Document
sql = webnotes.conn.sql
if not email:
email = webnotes.form_dict.get('user')
if not validate_email_add(email):
raise Exception
return 'Invalid Email Id'
if sql("select name from tabProfile where name = %s", email):
# exists, enable it
sql("update tabProfile set enabled = 1, docstatus=0 where name = %s", email)
webnotes.msgprint('Profile exists, enabled it')
else:
# does not exist, create it!
pr = Document('Profile')
pr.name = email
pr.email = email
pr.enabled=1
pr.user_type='System User'
pr.save(1)
from webnotes.model.code import get_obj
pr_obj = get_obj(doc=pr)
pr_obj.on_update()
示例3: create_login
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import user_type [as 别名]
def create_login(self,arg):
arg = eval(arg)
cont_det = sql("select * from tabContact where name=%s",(arg['contact']),as_dict=1)
if cont_det[0]['docstatus'] !=0:
msgprint('Please save the corresponding contact first')
raise Exception
if sql("select name from tabProfile where name=%s",cont_det[0]['email_id']):
msgprint('Profile with same name already exist.')
raise Exception
else:
p = Document('Profile')
p.name = cont_det[0]['email_id']
p.first_name = cont_det[0]['first_name']
p.last_name = cont_det[0]['last_name']
p.email = cont_det[0]['email_id']
p.cell_no = cont_det[0]['contact_no']
p.password = 'password'
p.enabled = 1
p.user_type = 'Partner';
p.save(1)
get_obj(doc=p).on_update()
role = []
if cont_det[0]['contact_type'] == 'Individual':
role = ['Customer']
else:
if cont_det[0]['is_customer']:
role.append('Customer')
if cont_det[0]['is_supplier']:
role.append('Supplier')
if cont_det[0]['is_sales_partner']:
role.append('Partner')
if role:
prof_nm = p.name
for i in role:
r = Document('UserRole')
r.parent = p.name
r.role = i
r.parenttype = 'Profile'
r.parentfield = 'userroles'
r.save(1)
if i == 'Customer':
def_keys = ['from_company','customer_name','customer']
def_val = cont_det[0]['customer_name']
self.set_default_val(def_keys,def_val,prof_nm)
if i == 'Supplier':
def_keys = ['supplier_name','supplier']
def_val = cont_det[0]['supplier_name']
self.set_default_val(def_keys,def_val,prof_nm)
sql("update tabContact set has_login = 'Yes' where name=%s",cont_det[0]['name'])
sql("update tabContact set disable_login = 'No' where name=%s",cont_det[0]['name'])
msgprint('User login is created.')
示例4: create_login
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import user_type [as 别名]
def create_login(self, arg):
arg = eval(arg)
cont_det = sql("select * from tabContact where name=%s", (arg["contact"]), as_dict=1)
if cont_det[0]["docstatus"] != 0:
msgprint("Please save the corresponding contact first")
raise Exception
if sql("select name from tabProfile where name=%s", cont_det[0]["email_id"]):
msgprint("Profile with same name already exist.")
raise Exception
else:
p = Document("Profile")
p.name = cont_det[0]["email_id"]
p.first_name = cont_det[0]["first_name"]
p.last_name = cont_det[0]["last_name"]
p.email = cont_det[0]["email_id"]
p.cell_no = cont_det[0]["contact_no"]
p.password = "password"
p.enabled = 1
p.user_type = "Partner"
p.save(1)
get_obj(doc=p).on_update()
role = []
if cont_det[0]["contact_type"] == "Individual":
role = ["Customer"]
else:
if cont_det[0]["is_customer"]:
role.append("Customer")
if cont_det[0]["is_supplier"]:
role.append("Supplier")
if cont_det[0]["is_sales_partner"]:
role.append("Partner")
if role:
prof_nm = p.name
for i in role:
r = Document("UserRole")
r.parent = p.name
r.role = i
r.parenttype = "Profile"
r.parentfield = "userroles"
r.save(1)
if i == "Customer":
def_keys = ["from_company", "customer_name", "customer"]
def_val = cont_det[0]["customer_name"]
self.set_default_val(def_keys, def_val, prof_nm)
if i == "Supplier":
def_keys = ["supplier_name", "supplier"]
def_val = cont_det[0]["supplier_name"]
self.set_default_val(def_keys, def_val, prof_nm)
sql("update tabContact set has_login = 'Yes' where name=%s", cont_det[0]["name"])
sql("update tabContact set disable_login = 'No' where name=%s", cont_det[0]["name"])
msgprint("User login is created.")
示例5: create_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import user_type [as 别名]
def create_profile(self, email):
if sql("select name from tabProfile where name = %s", email):
sql("update tabProfile set docstatus = 0 where name = %s", email)
else:
pr = Document('Profile')
pr.email = email
pr.enabled=0
pr.user_type='System User'
pr.save(1)
示例6: create_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import user_type [as 别名]
def create_profile(usr, name):
d = Document("Profile")
d.owner = "Administrator"
d.email = usr
d.first_name = name
d.enabled = 1
d.creation = nowdate() + ' ' + nowtime()
d.user_type = "System User"
d.save(1)
示例7: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import user_type [as 别名]
def add_profile(args):
from webnotes.utils import validate_email_add, now
email = args['user']
sql = webnotes.conn.sql
# validate max number of users exceeded or not
import conf
if hasattr(conf, 'max_users'):
active_users = sql("""select count(*) from tabProfile
where ifnull(enabled, 0)=1 and docstatus<2
and name not in ('Administrator', 'Guest')""")[0][0]
if active_users >= conf.max_users and conf.max_users:
# same message as in users.js
webnotes.msgprint("""Alas! <br />\
You already have <b>%(active_users)s</b> active users, \
which is the maximum number that you are currently allowed to add. <br /><br /> \
So, to add more users, you can:<br /> \
1. <b>Upgrade to the unlimited users plan</b>, or<br /> \
2. <b>Disable one or more of your existing users and try again</b>""" \
% {'active_users': active_users}, raise_exception=1)
if not email:
email = webnotes.form_dict.get('user')
if not validate_email_add(email):
raise Exception
return 'Invalid Email Id'
if sql("select name from tabProfile where name = %s", email):
# exists, enable it
sql("update tabProfile set enabled = 1, docstatus=0 where name = %s", email)
webnotes.msgprint('Profile exists, enabled it with new password')
else:
# does not exist, create it!
pr = Document('Profile')
pr.name = email
pr.email = email
pr.first_name = args.get('first_name')
pr.last_name = args.get('last_name')
pr.enabled = 1
pr.user_type = 'System User'
pr.save(1)
if args.get('password'):
sql("""
UPDATE tabProfile
SET password = PASSWORD(%s), modified = %s
WHERE name = %s""", (args.get('password'), now, email))
send_welcome_mail(email, args)
示例8: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import user_type [as 别名]
def add_profile(self,arg):
# Check credit balance
get_obj('WN ERP Client Control').check_credit_balance()
arg=eval(arg)
pr=Document('Profile')
for d in arg.keys():
if d!='role':
pr.fields[d] = arg[d]
pr.enabled=0
pr.user_type='System User'
pr.save(1)
pr_obj = get_obj('Profile',pr.name)
if (pr.name):
msg="New member is added"
pr_obj.on_update()
else:
msg="Profile not created"
return cstr(msg)
示例9: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import user_type [as 别名]
def add_profile(args):
from webnotes.utils import validate_email_add, now
email = args["user"]
sql = webnotes.conn.sql
if not email:
email = webnotes.form_dict.get("user")
if not validate_email_add(email):
raise Exception
return "Invalid Email Id"
if sql("select name from tabProfile where name = %s", email):
# exists, enable it
sql("update tabProfile set enabled = 1, docstatus=0 where name = %s", email)
webnotes.msgprint("Profile exists, enabled it with new password")
else:
# does not exist, create it!
pr = Document("Profile")
pr.name = email
pr.email = email
pr.first_name = args.get("first_name")
pr.last_name = args.get("last_name")
pr.enabled = 1
pr.user_type = "System User"
pr.save(1)
if args.get("password"):
sql(
"""
UPDATE tabProfile
SET password = PASSWORD(%s), modified = %s
WHERE name = %s""",
(args.get("password"), now, email),
)
send_welcome_mail(email, args)