From 3931f4c84bad72153b6a76969ca01c00e01018c9 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 3 Sep 2013 11:45:25 +0530 Subject: [PATCH 1/6] [fix] [minor] clear filters in query report --- public/js/wn/views/query_report.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/wn/views/query_report.js b/public/js/wn/views/query_report.js index e1664969fb..99de477e32 100644 --- a/public/js/wn/views/query_report.js +++ b/public/js/wn/views/query_report.js @@ -124,7 +124,7 @@ wn.views.QueryReport = Class.extend({ }, clear_filters: function() { this.filters = []; - this.appframe.$w.find('.navbar .filters').remove(); + this.appframe.$w.find('.appframe-form .filters').remove(); }, set_filters_by_name: function() { this.filters_by_name = {}; From 3c527d2af2a512b736cb18b29d944ddb376fbe43 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 3 Sep 2013 15:33:50 +0530 Subject: [PATCH 2/6] [fix] [minor] profile query --- core/doctype/profile/profile.py | 18 ++++++++++++++++++ public/js/wn/form/assign_to.js | 12 +----------- webnotes/widgets/reportview.py | 10 ++++++++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/core/doctype/profile/profile.py b/core/doctype/profile/profile.py index d6a6f409b8..b3e52b667f 100644 --- a/core/doctype/profile/profile.py +++ b/core/doctype/profile/profile.py @@ -322,3 +322,21 @@ def sign_up(email, full_name): profile.insert() return _("Registration Details Emailed.") +def profile_query(doctype, txt, searchfield, start, page_len, filters): + from webnotes.widgets.reportview import get_match_cond + return webnotes.conn.sql("""select name, concat_ws(' ', first_name, middle_name, last_name) + from `tabProfile` + where ifnull(enabled, 0)=1 + and docstatus < 2 + and name not in ('Administrator', 'Guest') + and user_type != 'Website User' + and (%(key)s like "%(txt)s" + or concat_ws(' ', first_name, middle_name, last_name) like "%(txt)s") + %(mcond)s + order by + case when name like "%(txt)s" then 0 else 1 end, + case when concat_ws(' ', first_name, middle_name, last_name) like "%(txt)s" + then 0 else 1 end, + name asc + limit %(start)s, %(page_len)s""" % {'key': searchfield, 'txt': "%%%s%%" % txt, + 'mcond':get_match_cond(doctype, searchfield), 'start': start, 'page_len': page_len}) diff --git a/public/js/wn/form/assign_to.js b/public/js/wn/form/assign_to.js index 56d47d1e9a..0d5ed4696e 100644 --- a/public/js/wn/form/assign_to.js +++ b/public/js/wn/form/assign_to.js @@ -116,17 +116,7 @@ wn.ui.form.AssignTo = Class.extend({ }); } } - me.dialog.fields_dict.assign_to.get_query = function() { - return "select name, concat_ws(' ', first_name, middle_name, last_name) \ - from `tabProfile` where ifnull(enabled, 0)=1 and docstatus < 2 and \ - name not in ('Administrator', 'Guest') and (%(key)s like \"%s\" or \ - concat_ws(' ', first_name, middle_name, last_name) like \"%%%s\") \ - order by \ - case when name like \"%s%%\" then 0 else 1 end, \ - case when concat_ws(' ', first_name, middle_name, last_name) \ - like \"%s%%\" then 0 else 1 end, \ - name asc limit 50"; - }; + me.dialog.fields_dict.assign_to.get_query = "core.doctype.profile.profile.profile_query"; } me.dialog.clear(); me.dialog.show(); diff --git a/webnotes/widgets/reportview.py b/webnotes/widgets/reportview.py index 0b816f9a51..3570f7c34d 100644 --- a/webnotes/widgets/reportview.py +++ b/webnotes/widgets/reportview.py @@ -386,3 +386,13 @@ def scrub_user_tags(tagcount): def get_table_columns(table): res = webnotes.conn.sql("DESC `tab%s`" % table, as_dict=1) if res: return [r['Field'] for r in res] + +# used in building query in queries.py +def get_match_cond(doctype, searchfield = 'name'): + cond = build_match_conditions(doctype) + + if cond: + cond = ' and ' + cond + else: + cond = '' + return cond \ No newline at end of file From 51f274d7735b1ab12ba66f150bacacdb798d9948 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 3 Sep 2013 17:04:04 +0530 Subject: [PATCH 3/6] [docs] custom script examples, [build] move CMS make to app via event_handlers.on_build --- webnotes/build.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/webnotes/build.py b/webnotes/build.py index 66f46bbdd1..44021b454f 100644 --- a/webnotes/build.py +++ b/webnotes/build.py @@ -21,10 +21,12 @@ def bundle(no_compress, cms_make=True): bundle.make() if cms_make: - # build index.html and app.html - from website.helpers.make_web_include_files import make - make() - + try: + from startup.event_handlers import on_build + on_build() + except ImportError, e: + pass + if not no_compress: from home.page.latest_updates import latest_updates latest_updates.make() From e7c00d657f00bb20b1421e7901d4e7caa79189ec Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 3 Sep 2013 17:13:50 +0530 Subject: [PATCH 4/6] [build] move latest update to app via event_handlers.on_build --- webnotes/build.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/webnotes/build.py b/webnotes/build.py index 44021b454f..921f99584c 100644 --- a/webnotes/build.py +++ b/webnotes/build.py @@ -26,11 +26,7 @@ def bundle(no_compress, cms_make=True): on_build() except ImportError, e: pass - - if not no_compress: - from home.page.latest_updates import latest_updates - latest_updates.make() - + def watch(no_compress): """watch and rebuild if necessary""" import time From 4179c3f257a08b02a9ffec2c3a1223af46e5eaee Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 3 Sep 2013 17:36:41 +0530 Subject: [PATCH 5/6] [minor] [boot] moved load_country_and_currency to framework --- webnotes/boot.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/webnotes/boot.py b/webnotes/boot.py index 213a7f6af2..ac7f8251ca 100644 --- a/webnotes/boot.py +++ b/webnotes/boot.py @@ -46,7 +46,6 @@ def get_bootinfo(): add_home_page(bootinfo, doclist) add_allowed_pages(bootinfo) load_translations(bootinfo) - load_country_and_currency(bootinfo, doclist) # ipinfo if webnotes.session['data'].get('ipinfo'): @@ -67,14 +66,6 @@ def get_bootinfo(): return bootinfo -def load_country_and_currency(bootinfo, doclist): - if bootinfo.control_panel.country and \ - webnotes.conn.exists("Country", bootinfo.control_panel.country): - doclist += [webnotes.doc("Country", bootinfo.control_panel.country)] - - doclist += webnotes.conn.sql("""select * from tabCurrency - where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"}) - def add_allowed_pages(bootinfo): bootinfo.page_info = dict(webnotes.conn.sql("""select distinct parent, modified from `tabPage Role` where role in ('%s')""" % "', '".join(webnotes.get_roles()))) From 3ef51a236a3e04b132e11b434160789158bb33b0 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 4 Sep 2013 11:56:54 +0530 Subject: [PATCH 6/6] [fix] [email] [minor] invalid recipient error message --- webnotes/utils/email_lib/smtp.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webnotes/utils/email_lib/smtp.py b/webnotes/utils/email_lib/smtp.py index 90fd0fb053..0a2e53cd6c 100644 --- a/webnotes/utils/email_lib/smtp.py +++ b/webnotes/utils/email_lib/smtp.py @@ -11,7 +11,6 @@ import webnotes import conf from webnotes import msgprint from webnotes.utils import cint -import email def get_email(recipients, sender='', msg='', subject='[No Subject]', text_content = None): """send an html email as multipart with attachments and all""" @@ -227,10 +226,14 @@ class EMail: smtpserver.sess.sendmail(self.sender, self.recipients + (self.cc or []), self.as_string()) - except smtplib.SMTPSenderRefused, e: + except smtplib.SMTPSenderRefused: webnotes.msgprint("""Invalid Outgoing Mail Server's Login Id or Password. \ Please rectify and try again.""", raise_exception=webnotes.OutgoingEmailError) + except smtplib.SMTPRecipientsRefused: + webnotes.msgprint("""Invalid Recipient (To) Email Address. \ + Please rectify and try again.""", + raise_exception=webnotes.OutgoingEmailError) class SMTPServer: def __init__(self, login=None, password=None, server=None, port=None, use_ssl=None):