From 8253169d453e0ea66ebe1fe0ff9da341102e41b2 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 3 Dec 2013 18:10:12 +0530 Subject: [PATCH 1/7] [minor] website - if no page_name, show login --- webnotes/webutils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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") From 1f5aff790349d999fb570decc871c158a105fd78 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Dec 2013 11:17:13 +0530 Subject: [PATCH 2/7] [fix] [minor] fix in getseries --- webnotes/model/doc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 03adcd8da162eb5fc899e8b20651c8dd692a60f9 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 4 Dec 2013 11:26:46 +0530 Subject: [PATCH 3/7] [patch] Added option to hide spinner / progress in ajax call --- website/js/website.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/website/js/website.js b/website/js/website.js index 6418e36faa..8034fd9d93 100644 --- a/website/js/website.js +++ b/website/js/website.js @@ -42,7 +42,7 @@ $.extend(wn, { wn.process_response(opts, data); }, error: function(response) { - NProgress.done(); + if(!opts.no_spinner) NProgress.done(); console.error ? console.error(response) : console.log(response); } }); @@ -75,7 +75,9 @@ $.extend(wn, { } }); - NProgress.start(); + if(!opts.no_spinner) { + NProgress.start(); + } }, process_response: function(opts, data) { NProgress.done(); From f0d564538e10906a909d7a28f7f3866bcd8a7308 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 4 Dec 2013 11:29:09 +0530 Subject: [PATCH 4/7] [patch] No spinner in has_permission --- website/js/website.js | 1 + 1 file changed, 1 insertion(+) diff --git a/website/js/website.js b/website/js/website.js index 8034fd9d93..5cd7ef80ca 100644 --- a/website/js/website.js +++ b/website/js/website.js @@ -160,6 +160,7 @@ $.extend(wn, { has_permission: function(doctype, docname, perm_type, callback) { return wn.call({ method: "webnotes.client.has_permission", + no_spinner: true, args: {doctype: doctype, docname: docname, perm_type: perm_type}, callback: function(r) { if(!r.exc && r.message.has_permission) { From 48c5ab5b19ad0554bdd2294b450a0e286e223203 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 4 Dec 2013 13:13:58 +0530 Subject: [PATCH 5/7] [patch] web_page generator, fix "None" error if no page content --- website/doctype/web_page/templates/generators/web_page.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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" %}
- {{ main_section }} + {{ main_section or "" }}
{# toc, parent, child, next sibling #} @@ -64,4 +64,4 @@ $(function() { } }); -{% endblock %} \ No newline at end of file +{% endblock %} From d425a208de0fbc8aefce6c2cb8689eac6d6279b7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Dec 2013 13:22:47 +0530 Subject: [PATCH 6/7] [fix] [minor] call autoname through controller while called from bean --- webnotes/model/bean.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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": From f88a0fbafb331bf309f707b422a76e2ba78a3fbe Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 4 Dec 2013 16:27:59 +0530 Subject: [PATCH 7/7] [minor] [smtp] propagate exceptions --- webnotes/__init__.py | 1 - webnotes/utils/email_lib/smtp.py | 25 +++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) 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/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