diff --git a/webnotes/__init__.py b/webnotes/__init__.py index af578d84f6..ec801f9a3b 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -116,7 +116,6 @@ class DuplicateEntryError(Exception): pass class ValidationError(Exception): pass class AuthenticationError(Exception): pass class PermissionError(Exception): pass -class OutgoingEmailError(ValidationError): pass class UnknownDomainError(Exception): pass class SessionStopped(Exception): pass class MappingMismatchError(ValidationError): pass diff --git a/webnotes/model/bean.py b/webnotes/model/bean.py index dc44e689e1..dde95edc40 100644 --- a/webnotes/model/bean.py +++ b/webnotes/model/bean.py @@ -199,7 +199,7 @@ class Bean: if self.doc.fields.get("__islocal"): # set name before validate - self.doc.set_new_name() + self.doc.set_new_name(self.get_controller()) self.run_method('before_insert') if method != "cancel": diff --git a/webnotes/model/doc.py b/webnotes/model/doc.py index e8c31bfcdf..b8d0a7dc80 100755 --- a/webnotes/model/doc.py +++ b/webnotes/model/doc.py @@ -588,7 +588,7 @@ def make_autoname(key, doctype=''): def getseries(key, digits, doctype=''): # series created ? current = webnotes.conn.sql("select `current` from `tabSeries` where name=%s for update", key) - if current and current[0][0]: + if current and current[0][0] is not None: current = current[0][0] # yes, update it webnotes.conn.sql("update tabSeries set current = current+1 where name=%s", key) diff --git a/webnotes/utils/email_lib/smtp.py b/webnotes/utils/email_lib/smtp.py index f9a2121f45..34f0501910 100644 --- a/webnotes/utils/email_lib/smtp.py +++ b/webnotes/utils/email_lib/smtp.py @@ -12,6 +12,8 @@ from webnotes import conf from webnotes import msgprint from webnotes.utils import cint, expand_partial_links +class OutgoingEmailError(webnotes.ValidationError): pass + def get_email(recipients, sender='', msg='', subject='[No Subject]', text_content = None, footer=None): """send an html email as multipart with attachments and all""" email = EMail(sender, recipients, subject) @@ -108,7 +110,7 @@ class EMail: try: import startup footer += getattr(startup, 'mail_footer', '') - except ImportError, e: + except ImportError: pass return footer @@ -225,12 +227,12 @@ class EMail: except smtplib.SMTPSenderRefused: webnotes.msgprint("""Invalid Outgoing Mail Server's Login Id or Password. \ - Please rectify and try again.""", - raise_exception=webnotes.OutgoingEmailError) + Please rectify and try again.""") + raise except smtplib.SMTPRecipientsRefused: webnotes.msgprint("""Invalid Recipient (To) Email Address. \ - Please rectify and try again.""", - raise_exception=webnotes.OutgoingEmailError) + Please rectify and try again.""") + raise class SMTPServer: def __init__(self, login=None, password=None, server=None, port=None, use_ssl=None): @@ -308,17 +310,16 @@ class SMTPServer: return self._sess - except _socket.error, e: + except _socket.error: # Invalid mail server -- due to refusing connection webnotes.msgprint('Invalid Outgoing Mail Server or Port. Please rectify and try again.') - raise webnotes.OutgoingEmailError, e - except smtplib.SMTPAuthenticationError, e: + raise + except smtplib.SMTPAuthenticationError: webnotes.msgprint("Invalid Outgoing Mail Server's Login Id or Password. \ Please rectify and try again.") - raise webnotes.OutgoingEmailError, e - except smtplib.SMTPException, e: + raise + except smtplib.SMTPException: webnotes.msgprint('There is something wrong with your Outgoing Mail Settings. \ Please contact us at support@erpnext.com') - raise webnotes.OutgoingEmailError, e - + raise diff --git a/webnotes/webutils.py b/webnotes/webutils.py index a6ab8590c4..604cdca505 100644 --- a/webnotes/webutils.py +++ b/webnotes/webutils.py @@ -14,12 +14,14 @@ class PageNotFoundError(Exception): pass def render(page_name): """render html page""" + if not page_name: + page_name = "index" try: - html = render_page(page_name or "index") + html = render_page(page_name) except PageNotFoundError: html = render_page("404") except webnotes.DoesNotExistError: - if not page_name or page_name=="index": + if page_name in ("index", "index.html"): html = render_page("login") else: html = render_page("404") diff --git a/website/doctype/web_page/templates/generators/web_page.html b/website/doctype/web_page/templates/generators/web_page.html index 2804683f6b..7529e8e23c 100644 --- a/website/doctype/web_page/templates/generators/web_page.html +++ b/website/doctype/web_page/templates/generators/web_page.html @@ -17,7 +17,7 @@ {% include "lib/website/doctype/website_slideshow/templates/includes/slideshow.html" %}