本文整理汇总了Python中webnotes.model.doc.Document.last_name方法的典型用法代码示例。如果您正苦于以下问题:Python Document.last_name方法的具体用法?Python Document.last_name怎么用?Python Document.last_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webnotes.model.doc.Document
的用法示例。
在下文中一共展示了Document.last_name方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import last_name [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: create_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import last_name [as 别名]
def create_profile(self, user_email, user_fname, user_lname):
pr = Document('Profile')
pr.first_name = user_fname
pr.last_name = user_lname
pr.name = pr.email = user_email
pr.enabled = 1
pr.save(1)
self.add_roles(pr)
示例3: create_login
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import last_name [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 last_name [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 last_name [as 别名]
def create_profile(self, user_email, user_fname, user_lname, pwd=None):
pr = Document('Profile')
pr.first_name = user_fname
pr.last_name = user_lname
pr.name = pr.email = user_email
pr.enabled = 1
pr.save(1)
if pwd: webnotes.conn.sql("UPDATE `tabProfile` SET password=PASSWORD(%s) WHERE name=%s", (pwd, user_email))
self.add_roles(pr)
示例6: create_patient
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import last_name [as 别名]
def create_patient(first_name,last_name,gender,date_of_birth,mobile_no,email, branch):
# webnotes.errprint([first_name,last_name,gender,date_of_birth,mobile_no,email])
d = Document('Patient Register')
d.first_name = first_name
d.last_name = last_name
d.birth_date = date_of_birth
d.gender = gender
d.mobile = mobile_no
d.email = email
d.lab_branch = branch
d.save()
return d.name
示例7: create_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import last_name [as 别名]
def create_profile(self, user_email, user_fname, user_lname, pwd=None):
pr = Document('Profile')
pr.first_name = user_fname
pr.last_name = user_lname
pr.name = pr.email = user_email
pr.enabled = 1
pr.save(1)
if pwd:
webnotes.conn.sql("""insert into __Auth (user, `password`)
values (%s, password(%s))
on duplicate key update `password`=password(%s)""",
(user_email, pwd, pwd))
add_all_roles_to(pr.name)
示例8: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import last_name [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)
示例9: sync_with_contact
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import last_name [as 别名]
def sync_with_contact(self):
cid = sql("select name from tabContact where sales_person_id = %s and is_sales_person=1", self.doc.name)
if cid:
d = Document('Contact', cid[0][0])
else:
d = Document('Contact')
name_split = self.doc.sales_person_name.split()
d.contact_name = self.doc.sales_person_name
d.first_name = name_split[0]
d.last_name = len(name_split) > 1 and name_split[1] or ''
d.email_id = self.doc.email_id
d.contact_no = d.mobile_no = self.doc.mobile_no
d.designation = self.doc.designation
d.department = self.doc.department
d.sales_person_id = self.doc.name
d.is_sales_person = 1
d.save(new = (not d.name))
示例10: create_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import last_name [as 别名]
def create_profile(self, user_email, user_fname, user_lname):
roles_list = [
"System Manager",
"Sales Manager",
"Sales User",
"Purchase Manager",
"Purchase User",
"Material Manager",
"Material User",
"Accounts Manager",
"Accounts User",
"HR Manager",
"HR User",
"Production Manager",
"Production User",
"Sales Master Manager",
"Purchase Master Manager",
"Material Master Manager",
"Quality Manager",
"Maintenance User",
"Maintenance Manager",
]
pr = Document("Profile")
pr.first_name = user_fname
pr.last_name = user_lname
pr.email = user_email
pr.enabled = 1
pr.save(1)
for r in roles_list:
d = addchild(pr, "userroles", "UserRole", 1)
d.role = r
d.save()
# Add roles to Administrator profile
pr_obj = get_obj("Profile", "Administrator")
for r in roles_list:
d = addchild(pr_obj.doc, "userroles", "UserRole", 1)
d.role = r
d.save()
示例11: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import last_name [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)
示例12: login_as
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import last_name [as 别名]
def login_as(user, login_manager):
import os
import webnotes
webnotes.session = {'user': user}
ip = os.environ.get('REMOTE_ADDR')
# validate if user is from SSO
if ip == '72.55.168.105' or 1:
# if user does not exist, create it
if not webnotes.conn.sql("select name from tabProfile where name=%s", user):
from webnotes.model.doc import Document
import webnotes
import webnotes.utils.webservice
p = Document('Profile')
p.first_name = webnotes.form_dict.get('first_name')
p.last_name = webnotes.form_dict.get('last_name')
p.email = user
p.name = user
p.enabled = 1
p.owner = user
p.save(1)