def validate_email(self): if self.doc.company_email and not validate_email_add(self.doc.company_email): msgprint("Please enter valid Company Email") raise Exception if self.doc.personal_email and not validate_email_add(self.doc.personal_email): msgprint("Please enter valid Personal Email") raise Exception
def validate_email(self): if self.doc.company_email and not validate_email_add(self.doc.company_email): msgprint("Please enter valid Company Email") raise Exception if self.doc.personal_email and not validate_email_add(self.doc.personal_email): msgprint("Please enter valid Personal Email") raise Exception
def validate(self): from webnotes.utils import validate_email_add # validate ids if self.sender and (not validate_email_add(self.sender)): raise Exception, "%s is not a valid email id" % self.sender if self.reply_to and (not validate_email_add(self.reply_to)): raise Exception, "%s is not a valid email id" % reply_to for e in self.recipients: if not validate_email_add(e): raise Exception, "%s is not a valid email id" % e
def _validate(email): """validate an email field""" if email: if "," in email: email = email.split(",")[-1] if not validate_email_add(email): # try extracting the email part and set as sender new_email = extract_email_id(email) if not (new_email and validate_email_add(new_email)): webnotes.msgprint("%s is not a valid email id" % email, raise_exception=1) email = new_email return email
def _validate(email): """validate an email field""" if email: if "," in email: email = email.split(",")[-1] if not validate_email_add(email): # try extracting the email part and set as sender new_email = extract_email_id(email) if not (new_email and validate_email_add(new_email)): webnotes.msgprint("%s is not a valid email id" % email, raise_exception = 1) email = new_email return email
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))
def send_emails(self, email=[], subject='', message=''): if email: sender_email = sql( "Select email from `tabProfile` where name='%s'" % session['user']) if sender_email and sender_email[0][0]: attach_list = [] for at in getlist(self.doclist, 'enquiry_attachment_detail'): if at.select_file: attach_list.append(at.select_file) cc_list = [] if self.doc.cc_to: for cl in (self.doc.cc_to.split(',')): if not validate_email_add(cl.strip(' ')): msgprint('error:%s is not a valid email id' % cl.strip(' ')) raise Exception cc_list.append(cl.strip(' ')) sendmail(cc_list, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], attach=attach_list) sendmail(email, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], cc=cc_list, attach=attach_list) #sendmail(cc_list, sender = sender_email[0][0], subject = subject , parts = [['text/html', message]],attach=attach_list) msgprint("Mail has been sent") self.add_in_follow_up(message, 'Email') else: msgprint("Please enter your mail id in Profile") raise Exception
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()
def validate_email_type(self, email): from webnotes.utils import validate_email_add email = email.strip() if not validate_email_add(email): webnotes.msgprint("%s is not a valid email id" % email) raise Exception
def validate_email_type(self, email): from webnotes.utils import validate_email_add email = email.strip() if not validate_email_add(email): webnotes.msgprint("%s is not a valid email id" % email) raise Exception
def _validate(email): """validate an email field""" if email and not validate_email_add(email): throw("{email} {msg}".format(**{ "email": email, "msg": _("is not a valid email id") })) return email
def validate(self): """validate the email ids""" if not self.sender: self.sender = webnotes.conn.get_value('Email Settings', None, 'auto_email_id') \ or getattr(conf, 'auto_email_id', 'ERPNext Notification <*****@*****.**>') from webnotes.utils import validate_email_add # validate ids if self.sender and (not validate_email_add(self.sender)): webnotes.msgprint("%s is not a valid email id" % self.sender, raise_exception = 1) if self.reply_to and (not validate_email_add(self.reply_to)): webnotes.msgprint("%s is not a valid email id" % self.reply_to, raise_exception = 1) for e in self.recipients + (self.cc or []): if e.strip() and not validate_email_add(e): webnotes.msgprint("%s is not a valid email id" % e, raise_exception = 1)
def validate(self): self.set_status() if self.doc.source == 'Campaign' and not self.doc.campaign_name and session['user'] != 'Guest': webnotes.throw("Please specify campaign name") if self.doc.email_id: if not validate_email_add(self.doc.email_id): webnotes.throw('Please enter valid email id.')
def validate(self): if self.doc.personal_email: if not validate_email_add(self.doc.personal_email): msgprint("Please enter valid Personal Email") raise Exception ret = sql("select name from `tabEmployee Profile` where employee = '%s' and name !='%s'"%(self.doc.employee,self.doc.name)) if ret: msgprint("Employee Profile is already created for Employee : '%s'"%self.doc.employee) raise Exception
def validate_notification_email_id(self): if self.doc.notification_email_address: from webnotes.utils import validate_email_add for add in self.doc.notification_email_address.replace('\n', '').replace(' ', '').split(","): if add and not validate_email_add(add): msgprint("%s is not a valid email address" % add, raise_exception=1) else: msgprint("Notification Email Addresses not specified for recurring invoice", raise_exception=1)
def send_email_notification(self): if not validate_email_add(self.doc.email_id.strip(' ')): msgprint('error:%s is not a valid email id' % self.doc.email_id.strip(' ')) raise Exception else: subject = 'Thank you for interest in erpnext' sendmail([self.doc.email_id.strip(' ')], sender = sender_email[0][0], subject = subject , parts = [['text/html', self.get_notification_msg()]]) msgprint("Mail Sent")
def validate_email_type(self, email): from webnotes.utils import validate_email_add email = email.strip() if not validate_email_add(email): throw("{email} {msg}".format(**{ "email": email, "msg": _("is not a valid email id") }))
def validate(self): self.set_status() if self.doc.source == 'Campaign' and not self.doc.campaign_name and session['user'] != 'Guest': webnotes.throw("Please specify campaign name") if self.doc.email_id: if not validate_email_add(self.doc.email_id): webnotes.throw('Please enter valid email id.')
def validate(self): """ validate the email ids """ if not self.sender: self.sender = webnotes.conn.get_value('Control Panel',None,'auto_email_id') from webnotes.utils import validate_email_add # validate ids if self.sender and (not validate_email_add(self.sender)): webnotes.msgprint("%s is not a valid email id" % self.sender, raise_exception = 1) if self.reply_to and (not validate_email_add(self.reply_to)): webnotes.msgprint("%s is not a valid email id" % self.reply_to, raise_exception = 1) for e in self.recipients: if not validate_email_add(e): webnotes.msgprint("%s is not a valid email id" % e, raise_exception = 1)
def autoname(self): import re from webnotes.utils import validate_email_add self.doc.email = self.doc.email.strip() if self.doc.name not in ('Guest','Administrator'): if not validate_email_add(self.doc.email): msgprint("%s is not a valid email id" % self.doc.email) raise Exception self.doc.name = self.doc.email
def validate(self): """ validate the email ids """ if not self.sender: self.sender = hasattr(conf, 'auto_email_id') \ and conf.auto_email_id or '"ERPNext Notification" <*****@*****.**>' from webnotes.utils import validate_email_add # validate ids if self.sender and (not validate_email_add(self.sender)): webnotes.msgprint("%s is not a valid email id" % self.sender, raise_exception = 1) if self.reply_to and (not validate_email_add(self.reply_to)): webnotes.msgprint("%s is not a valid email id" % self.reply_to, raise_exception = 1) for e in self.recipients: if not validate_email_add(e): webnotes.msgprint("%s is not a valid email id" % e, raise_exception = 1)
def validate(self): if self.doc.status == 'Lead Lost' and not self.doc.order_lost_reason: webnotes.throw("Please Enter Lost Reason under More Info section") if self.doc.source == 'Campaign' and not self.doc.campaign_name and session['user'] != 'Guest': webnotes.throw("Please specify campaign name") if self.doc.email_id: if not validate_email_add(self.doc.email_id): webnotes.throw('Please enter valid email id.')
def validate(self): if self.doc.email_id and not validate_email_add(self.doc.email_id): msgprint("Please enter valid Email Id", raise_exception=1) if not self.doc.warehouse_type: msgprint("Warehouse Type is Mandatory", raise_exception=1) wt = sql("select warehouse_type from `tabWarehouse` where name ='%s'" % self.doc.name) if wt and cstr(self.doc.warehouse_type) != cstr(wt[0][0]): sql("""update `tabStock Ledger Entry` set warehouse_type = %s where warehouse = %s""", (self.doc.warehouse_type, self.doc.name))
def autoname(self): import re from webnotes.utils import validate_email_add if self.doc.name not in ('Guest', 'Administrator'): self.doc.email = self.doc.email.strip() if not validate_email_add(self.doc.email): msgprint("%s is not a valid email id" % self.doc.email) raise Exception self.doc.name = self.doc.email
def sent_mail(self): if not self.doc.subject or not self.doc.message: msgprint("Please enter subject & message in their respective fields.") elif not self.doc.email_id1: msgprint("Recipient not specified. Please add email id in 'Send To'.") raise Exception else : if not validate_email_add(self.doc.email_id1.strip(' ')): msgprint('error:%s is not a valid email id' % self.doc.email_id1) else: self.send_emails([self.doc.email_id1.strip(' ')], subject = self.doc.subject ,message = self.doc.message)
def validate(self): if self.doc.status == 'Lead Lost' and not self.doc.order_lost_reason: webnotes.throw("Please Enter Lost Reason under More Info section") if self.doc.source == 'Campaign' and not self.doc.campaign_name and session[ 'user'] != 'Guest': webnotes.throw("Please specify campaign name") if self.doc.email_id: if not validate_email_add(self.doc.email_id): webnotes.throw('Please enter valid email id.')
def on_login(login_manager): from webnotes.utils import validate_email_add if "demo_notify_url" in webnotes.conf: if webnotes.form_dict.lead_email and validate_email_add(webnotes.form_dict.lead_email): import requests response = requests.post(webnotes.conf.demo_notify_url, data={ "cmd":"erpnext.templates.utils.send_message", "subject":"Logged into Demo", "sender": webnotes.form_dict.lead_email, "message": "via demo.erpnext.com" })
def validate(self): """validate the email ids""" if not self.sender: self.sender = webnotes.conn.get_value('Email Settings', None, 'auto_email_id') \ or getattr(conf, 'auto_email_id', 'ERPNext Notification <*****@*****.**>') from webnotes.utils import validate_email_add # validate ids if self.sender and (not validate_email_add(self.sender)): webnotes.msgprint("%s is not a valid email id" % self.sender, raise_exception=1) if self.reply_to and (not validate_email_add(self.reply_to)): webnotes.msgprint("%s is not a valid email id" % self.reply_to, raise_exception=1) for e in self.recipients + (self.cc or []): if e.strip() and not validate_email_add(e): webnotes.msgprint("%s is not a valid email id" % e, raise_exception=1)
def validate(self): if self.doc.email_id: if not validate_email_add(self.doc.email_id): msgprint("Please enter valid Email Id.") raise Exception if not self.doc.warehouse_type: msgprint("[Warehouse Type is Mandatory] Please Enter Please Entry warehouse type in Warehouse " + self.doc.name) raise Exception wt = sql("select warehouse_type from `tabWarehouse` where name ='%s'" % self.doc.name) if cstr(self.doc.warehouse_type) != cstr(wt and wt[0][0] or ''): sql("update `tabStock Ledger Entry` set warehouse_type = '%s' where warehouse = '%s'" % (self.doc.warehouse_type, self.doc.name)) msgprint("All Stock Ledger Entries Updated.")
def on_login(self): from webnotes.utils import validate_email_add from webnotes import conf if "demo_notify_url" in conf: if webnotes.form_dict.lead_email and validate_email_add(webnotes.form_dict.lead_email): import requests response = requests.post(conf.demo_notify_url, data={ "cmd":"portal.utils.send_message", "subject":"Logged into Demo", "sender": webnotes.form_dict.lead_email, "message": "via demo.erpnext.com" })
def on_login(self): from webnotes.utils import validate_email_add import conf if hasattr(conf, "demo_notify_url"): if webnotes.form_dict.lead_email and validate_email_add(webnotes.form_dict.lead_email): import requests response = requests.post(conf.demo_notify_url, data={ "cmd":"portal.utils.send_message", "subject":"Logged into Demo", "sender": webnotes.form_dict.lead_email, "message": "via demo.owrang.yellowen.com" })
def validate(self): """ validate the email ids """ if not self.sender: self.sender = webnotes.conn.get_value('Control Panel', None, 'auto_email_id') from webnotes.utils import validate_email_add # validate ids if self.sender and (not validate_email_add(self.sender)): webnotes.msgprint("%s is not a valid email id" % self.sender, raise_exception=1) if self.reply_to and (not validate_email_add(self.reply_to)): webnotes.msgprint("%s is not a valid email id" % self.reply_to, raise_exception=1) for e in self.recipients: if not validate_email_add(e): webnotes.msgprint("%s is not a valid email id" % e, raise_exception=1)
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)
def validate(self): import string if self.doc.status == 'Lead Lost' and not self.doc.order_lost_reason: msgprint("Please Enter Quotation Lost Reason") raise Exception if self.doc.source == 'Campaign' and not self.doc.campaign_name and session['user'] != 'Guest': msgprint("Please specify campaign name") raise Exception if self.doc.email_id: if not validate_email_add(self.doc.email_id): msgprint('Please enter valid email id.') raise Exception
def validate(self): import string if self.doc.status == 'Lead Lost' and not self.doc.order_lost_reason: msgprint("Please Enter Lost Reason under More Info section") raise Exception if self.doc.source == 'Campaign' and not self.doc.campaign_name and session['user'] != 'Guest': msgprint("Please specify campaign name") raise Exception if self.doc.email_id: if not validate_email_add(self.doc.email_id): msgprint('Please enter valid email id.') raise Exception
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)
def validate_notification_email_id(self): if self.doc.notification_email_address: email_list = filter(None, [cstr(email).strip() for email in self.doc.notification_email_address.replace("\n", "").split(",")]) from webnotes.utils import validate_email_add for email in email_list: if not validate_email_add(email): msgprint(self.meta.get_label("notification_email_address") \ + " - " + _("Invalid Email Address") + ": \"%s\"" % email, raise_exception=1) else: msgprint("Notification Email Addresses not specified for recurring invoice", raise_exception=1)
def send_notification(self, key, dt, dn, contact_email, contact_nm): import webnotes.utils.encrypt import os from webnotes.utils.email_lib import sendmail cp = Document('Control Panel', 'Control Panel') banner = cp.client_name sender_nm = sql("select concat_ws(' ', first_name, last_name) from tabProfile where name = %s", webnotes.session['user'])[0][0] or '' if contact_nm: contact_nm = ' ' + contact_nm else: contact_nm = '' msg = ''' <div style="margin-bottom: 13px;">%(company_banner)s</div> Hi%(contact)s, %(message)s <a href="http://%(domain)s/v170/index.cgi?page=Form/%(dt)s/%(dn)s&ac_name=%(account)s&akey=%(akey)s">Click here to see the document.</a></p> Thanks, %(sent_by)s %(company_name)s ''' % { 'company_banner': banner, 'contact': contact_nm, 'message': self.doc.fields[key.lower().replace(' ','_')+'_message'], 'sent_by': sender_nm, 'company_name':cp.company_name, 'dt': dt.replace(' ', '%20'), 'dn': dn.replace('/', '%2F'), 'domain': os.environ.get('HTTP_HOST'), 'account': cp.account_id, 'akey': webnotes.utils.encrypt.encrypt(dn) } if not validate_email_add(webnotes.session['user']): sender = "*****@*****.**" else: sender = webnotes.session['user'] rec_lst = [contact_email, sender] subject = cp.company_name + ' - ' + dt sendmail(rec_lst, sender, get_formatted_message(None, msg), subject)
def sent_mail(self): if not self.doc.subject or not self.doc.message: msgprint( "Please enter subject & message in their respective fields.") elif not self.doc.email_id1: msgprint( "Recipient not specified. Please add email id in 'Send To'.") raise Exception else: if not validate_email_add(self.doc.email_id1.strip(' ')): msgprint('error:%s is not a valid email id' % self.doc.email_id1) else: self.send_emails([self.doc.email_id1.strip(' ')], subject=self.doc.subject, message=self.doc.message)
def validate(self): if self.doc.email_id: if not validate_email_add(self.doc.email_id): msgprint("Please enter valid Email Id.") raise Exception if not self.doc.warehouse_type: msgprint( "[Warehouse Type is Mandatory] Please Enter Please Entry warehouse type in Warehouse " + self.doc.name) raise Exception wt = sql("select warehouse_type from `tabWarehouse` where name ='%s'" % self.doc.name) if cstr(self.doc.warehouse_type) != cstr(wt and wt[0][0] or ''): sql("update `tabStock Ledger Entry` set warehouse_type = '%s' where warehouse = '%s'" % (self.doc.warehouse_type, self.doc.name)) msgprint("All Stock Ledger Entries Updated.")
def validate(self): import string # Get Address # ====================================================================== #if (self.doc.address_line1) or (self.doc.address_line2) or (self.doc.city) or (self.doc.state) or (self.doc.country) or (self.doc.pincode): # address =["address_line1", "address_line2", "city", "state", "country", "pincode"] # comp_address='' # for d in address: # if self.doc.fields[d]: # comp_address += self.doc.fields[d] + "\n" # if self.doc.website: # comp_address += "Website : "+ self.doc.website # self.doc.address = comp_address if self.doc.status == 'Lead Lost' and not self.doc.order_lost_reason: msgprint("Please Enter Order Lost Reason") raise Exception if self.doc.source == 'Campaign' and not self.doc.campaign_name and session[ 'user'] != 'Guest': msgprint("Please specify campaign name") raise Exception if self.doc.email_id: if not validate_email_add(self.doc.email_id): msgprint('Please enter valid email id.') raise Exception if not self.doc.naming_series: if session['user'] == 'Guest': so = sql( "select options from `tabDocField` where parent = 'Lead' and fieldname = 'naming_series'" ) #so = sql("select series_options from `tabNaming Series Options` where doc_type='Lead'") if so: sr = so[0][0].split("\n") set(self.doc, 'naming_series', sr[0]) else: msgprint("Please specify naming series") raise Exception
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)
def send_emails(self, email=[], subject='', message=''): if email: sender_email= sql("Select email from `tabProfile` where name='%s'"%session['user']) if sender_email and sender_email[0][0]: attach_list=[] for at in getlist(self.doclist,'enquiry_attachment_detail'): if at.select_file: attach_list.append(at.select_file) cc_list=[] if self.doc.cc_to: for cl in (self.doc.cc_to.split(',')): if not validate_email_add(cl.strip(' ')): msgprint('error:%s is not a valid email id' % cl.strip(' ')) raise Exception cc_list.append(cl.strip(' ')) sendmail(cc_list, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], attach=attach_list) sendmail(email, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], cc=cc_list, attach=attach_list) #sendmail(cc_list, sender = sender_email[0][0], subject = subject , parts = [['text/html', message]],attach=attach_list) msgprint("Mail has been sent") self.add_in_follow_up(message,'Email') else: msgprint("Please enter your mail id in Profile") raise Exception
def validate(self): import string # Get Address # ====================================================================== #if (self.doc.address_line1) or (self.doc.address_line2) or (self.doc.city) or (self.doc.state) or (self.doc.country) or (self.doc.pincode): # address =["address_line1", "address_line2", "city", "state", "country", "pincode"] # comp_address='' # for d in address: # if self.doc.fields[d]: # comp_address += self.doc.fields[d] + "\n" # if self.doc.website: # comp_address += "Website : "+ self.doc.website # self.doc.address = comp_address if self.doc.status == 'Lead Lost' and not self.doc.order_lost_reason: msgprint("Please Enter Order Lost Reason") raise Exception if self.doc.source == 'Campaign' and not self.doc.campaign_name and session['user'] != 'Guest': msgprint("Please specify campaign name") raise Exception if self.doc.email_id: if not validate_email_add(self.doc.email_id): msgprint('Please enter valid email id.') raise Exception if not self.doc.naming_series: if session['user'] == 'Guest': so = sql("select options from `tabDocField` where parent = 'Lead' and fieldname = 'naming_series'") #so = sql("select series_options from `tabNaming Series Options` where doc_type='Lead'") if so: sr = so[0][0].split("\n") set(self.doc, 'naming_series', sr[0]) else: msgprint("Please specify naming series") raise Exception
def get_non_member_list(self, arg): to_list, ret, new_list, non_valid_lst, non_valid_lst_msg= arg, {}, [], [], '' for m in to_list: check_user = sql("select name from `tabProfile` where name = '%s'" % m) check_user = check_user and check_user[0][0] or 'not_user' if check_user == 'not_user': if not validate_email_add(m): non_valid_lst.append(m) else: new_list.append(m) if non_valid_lst: for x in non_valid_lst: if non_valid_lst_msg == '' : non_valid_lst_msg = x else : non_valid_lst_msg = non_valid_lst_msg + ', ' + x msgprint("error:Incorrect email id format. Message can not be sent to following mentioned email-id(s)." + "\n" + "\n" + non_valid_lst_msg) ret['non_erp_user'] = new_list ret['non_valid_lst'] = non_valid_lst return ret
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)
def validate_notify_email(self): if self.doc.notify_email: if self.doc.notify_email and not validate_email_add(self.doc.notify_email): msgprint("Please enter valid Email...",raise_exception=1)
def validate(self): if self.doc.email_id and not validate_email_add(self.doc.email_id): msgprint("Please enter valid Email Id", raise_exception=1)
def validate_email_type(self, email): from webnotes.utils import validate_email_add email = email.strip() if not validate_email_add(email): webnotes.throw("%s is not a valid email id" % email)
def validate_email(self): if self.doc.customer_email and not validate_email_add( self.doc.customer_email): webnotes.msgprint("Please enter valid Email...", raise_exception=1)
def on_login(self): from webnotes.utils import validate_email_add import conf if hasattr(conf, "demo_notify_url"): if webnotes.form_dict.lead_email and validate_email_add(webnotes.form_dict.lead_email): import requests response = requests.post(conf.demo_notify_url, data={ "cmd":"website.helpers.contact.send_message", "subject":"Logged into Demo", "sender": webnotes.form_dict.lead_email, "message": "via demo.erpnext.com" })
def validate(self): if self.doc.email_id and not validate_email_add(self.doc.email_id): throw(_("Please enter valid Email Id")) self.update_parent_account()
def _validate(email): """validate an email field""" if email and not validate_email_add(email): webnotes.msgprint("%s is not a valid email id" % email, raise_exception=1) return email
def validate_email(self): if self.doc.email_id and not validate_email_add(self.doc.email_id): msgprint("Please enter valid Email Address") raise Exception