本文整理汇总了Python中webnotes.model.doc.Document.email方法的典型用法代码示例。如果您正苦于以下问题:Python Document.email方法的具体用法?Python Document.email怎么用?Python Document.email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webnotes.model.doc.Document
的用法示例。
在下文中一共展示了Document.email方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_users
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [as 别名]
def create_users(self):
"""
Create Administrator / Guest
"""
webnotes.conn.begin()
from webnotes.model.doc import Document
p = Document('Profile')
p.name = p.first_name = 'Administrator'
p.email = '[email protected]'
p.save(new = 1)
ur = Document('UserRole')
ur.parent = 'Administrator'
ur.role = 'Administrator'
ur.parenttype = 'Profile'
ur.parentfield = 'userroles'
p.enabled = 1
ur.save(1)
p = Document('Profile')
p.name = p.first_name = 'Guest'
p.email = '[email protected]'
p.enabled = 1
p.save(new = 1)
ur = Document('UserRole')
ur.parent = 'Guest'
ur.role = 'Guest'
ur.parenttype = 'Profile'
ur.parentfield = 'userroles'
ur.save(1)
webnotes.conn.commit()
示例2: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [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: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [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))
示例4: profile_ceation
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [as 别名]
def profile_ceation(self):
webnotes.errprint("creating profile_ceation")
ch=webnotes.conn.sql("select name from tabProfile where name like '%"+cstr(self.doc.contact_email)+"%'")
if ch:
pass
else :
pp=Document('Profile')
pp.email=self.doc.contact_email
pp.first_name=self.doc.contact_name
webnotes.errprint(self.doc.password)
pp.new_password=self.doc.password
pp.account_id=self.doc.name
pp.franchise_admin='1'
pp.enabled='1'
pp.save(new=1)
ur=Document('UserRole')
ur.parent=self.doc.contact_email
ur.parentfield='user_roles'
ur.parenttype='Profile'
ur.role='Franchise'
ur.save(new=1)
dv=Document('DefaultValue')
dv.parent=self.doc.contact_email
dv.parentfield='system_defaults'
dv.parenttype='Control Panel'
dv.defkey='region'
dv.defvalue=self.doc.region
dv.save(new=1)
aa="insert into __Auth(user,password) values('"+self.doc.contact_email+"',password('"+self.doc.password+"'))"
webnotes.errprint(aa)
webnotes.conn.sql(aa)
示例5: create_login
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [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.')
示例6: create_login
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [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.")
示例7: import_core_module
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [as 别名]
def import_core_module(self):
"""
Imports the "Core" module from .txt file and creates
Creates profile Administrator
"""
from webnotes.modules.import_module import import_module
from webnotes.modules.module_manager import reload_doc
reload_doc("core", "doctype", "doctype")
reload_doc("core", "doctype", "docfield")
reload_doc("core", "doctype", "docperm")
import_module("core")
webnotes.conn.begin()
from webnotes.model.doc import Document
p = Document("Profile")
p.name = p.first_name = "Administrator"
p.email = "[email protected]"
p.save(new=1)
ur = Document("UserRole")
ur.parent = "Administrator"
ur.role = "Administrator"
ur.parenttype = "Profile"
ur.parentfield = "userroles"
p.enabled = 1
ur.save(1)
p = Document("Profile")
p.name = p.first_name = "Guest"
p.email = "[email protected]"
p.enabled = 1
p.save(new=1)
ur = Document("UserRole")
ur.parent = "Guest"
ur.role = "Guest"
ur.parenttype = "Profile"
ur.parentfield = "userroles"
ur.save(1)
webnotes.conn.commit()
示例8: create_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [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)
示例9: create_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [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)
示例10: create_users_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [as 别名]
def create_users_profile(self,args):
args = eval(args)
for email_id in args['user_email_ids']:
if sql("select email from tabProfile where email=%s",(email_id)):
p = Document('Profile',email_id)
p.enabled = 1
p.save()
else:
p = Document('Profile')
p.email = email_id
p.save(1)
示例11: create_patient
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [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
示例12: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [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)
示例13: create_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [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()
示例14: add_profile
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [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)
示例15: login_as
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import email [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)