From 3479be78099781a6d02e7a8f01153a8cd14ce73f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 1 Apr 2013 15:04:27 +0530 Subject: [PATCH 1/5] [framework] [fix] don't clear in sync if no docs --- conf/Framework.sql | 1 - public/js/wn/model/sync.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/Framework.sql b/conf/Framework.sql index acb7b4c6c0..f02690fe17 100644 --- a/conf/Framework.sql +++ b/conf/Framework.sql @@ -42,7 +42,6 @@ CREATE TABLE `tabDocField` ( `in_list_view` int(1) DEFAULT NULL, `no_column` int(1) DEFAULT NULL, `read_only` int(1) DEFAULT NULL, - `print_width` varchar(180) DEFAULT NULL, PRIMARY KEY (`name`), KEY `parent` (`parent`), KEY `label` (`label`), diff --git a/public/js/wn/model/sync.js b/public/js/wn/model/sync.js index bf7cf0ecf5..82c7a94a46 100644 --- a/public/js/wn/model/sync.js +++ b/public/js/wn/model/sync.js @@ -27,7 +27,7 @@ $.extend(wn.model, { if(doclist._kl) doclist = wn.model.expand(doclist); - if(doclist && sync_in==locals) + if(doclist && doclist.length && sync_in==locals) wn.model.clear_doclist(doclist[0].doctype, doclist[0].name) $.each(doclist, function(i, d) { From 5f71497d48b0ae3a287e86b0b164f3feb4cc95eb Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 1 Apr 2013 16:07:31 +0530 Subject: [PATCH 2/5] [framework/cookies] [update] we don't need root path cookies anymore --- webnotes/auth.py | 1 - 1 file changed, 1 deletion(-) diff --git a/webnotes/auth.py b/webnotes/auth.py index e5d9df3c81..46a8d13fce 100644 --- a/webnotes/auth.py +++ b/webnotes/auth.py @@ -258,7 +258,6 @@ class CookieManager: webnotes.cookies[b'sid'] = webnotes.session['sid'].encode('utf-8') webnotes.cookies[b'sid'][b'expires'] = expires.encode('utf-8') - webnotes.cookies[b'sid'][b'path'] = b'/' def set_remember_me(self): from webnotes.utils import cint From 3aaea724b2d05126e90773895f65fd62bbe1b747 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 1 Apr 2013 16:40:19 +0530 Subject: [PATCH 3/5] [setup] [feature] Update Manager for self hosted applications based on wnframework --- core/page/update_this_app/__init__.py | 0 core/page/update_this_app/update_this_app.js | 51 +++++++++++++++++++ core/page/update_this_app/update_this_app.py | 17 +++++++ core/page/update_this_app/update_this_app.txt | 36 +++++++++++++ public/js/wn/ui/appframe.js | 12 +++-- webnotes/__init__.py | 2 +- 6 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 core/page/update_this_app/__init__.py create mode 100644 core/page/update_this_app/update_this_app.js create mode 100644 core/page/update_this_app/update_this_app.py create mode 100644 core/page/update_this_app/update_this_app.txt diff --git a/core/page/update_this_app/__init__.py b/core/page/update_this_app/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/core/page/update_this_app/update_this_app.js b/core/page/update_this_app/update_this_app.js new file mode 100644 index 0000000000..f639b92e56 --- /dev/null +++ b/core/page/update_this_app/update_this_app.js @@ -0,0 +1,51 @@ +wn.pages['update-this-app'].onload = function(wrapper) { + wn.ui.make_app_page({ + parent: wrapper, + title: 'Update This Application', + single_column: true + }); + + wrapper.update_this_app = new wn.UpdateThisApp(wrapper); +}; + +wn.UpdateThisApp = Class.extend({ + init: function(wrapper) { + this.wrapper = wrapper; + this.body = $(this.wrapper).find(".layout-main"); + this.wrapper.appframe.add_home_breadcrumb(); + this.wrapper.appframe.add_module_breadcrumb("Setup"); + this.wrapper.appframe.add_breadcrumb("icon-magnet"); + this.make(); + }, + + make: function() { + var me = this; + + if(wn.boot && wn.boot.expires_on) { + wn.utils.set_intro(this.wrapper, $("
").appendTo(this.body), + wn._('This feature is only applicable to self hosted instances')); + + } else { + this.wrapper.appframe.add_button("Get Latest Updates", + function() { me.update_this_app(this); }, "icon-rss"); + + this.wrapper.update_output = $('
')
+				.appendTo(this.body.append("
")); + this.wrapper.update_output.text("Click - Get Latest Updates"); + } + + }, + + update_this_app: function(btn) { + var me = this; + wn.call({ + module: "core", + page: "update_this_app", + method: "update_this_app", + callback: function(r) { + me.wrapper.update_output.text(r.message); + }, + btn: btn, + }); + }, +}); diff --git a/core/page/update_this_app/update_this_app.py b/core/page/update_this_app/update_this_app.py new file mode 100644 index 0000000000..e876cb4d55 --- /dev/null +++ b/core/page/update_this_app/update_this_app.py @@ -0,0 +1,17 @@ +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes import _ + +@webnotes.whitelist(allow_roles=["System Manager", "Administrator"]) +def update_this_app(): + import conf + if hasattr(conf, "expires_on"): + return _("This feature is only applicable to self hosted instances") + + from webnotes.utils import execute_in_shell, cstr, get_base_path + err, out = execute_in_shell("cd %s && exec ssh-agent lib/wnf.py --update origin master" % \ + (get_base_path(),)) + + return "\n".join(filter(None, [cstr(err), cstr(out)])) diff --git a/core/page/update_this_app/update_this_app.txt b/core/page/update_this_app/update_this_app.txt new file mode 100644 index 0000000000..5a0e021f33 --- /dev/null +++ b/core/page/update_this_app/update_this_app.txt @@ -0,0 +1,36 @@ +[ + { + "creation": "2013-04-01 11:07:42", + "docstatus": 0, + "modified": "2013-04-01 11:07:42", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Page", + "module": "Core", + "name": "__common__", + "page_name": "update-this-app", + "standard": "Yes", + "title": "Update This Application" + }, + { + "doctype": "Page Role", + "name": "__common__", + "parent": "update-this-app", + "parentfield": "roles", + "parenttype": "Page" + }, + { + "doctype": "Page", + "name": "update-this-app" + }, + { + "doctype": "Page Role", + "role": "System Manager" + }, + { + "doctype": "Page Role", + "role": "Administrator" + } +] \ No newline at end of file diff --git a/public/js/wn/ui/appframe.js b/public/js/wn/ui/appframe.js index 99cdc4cd22..fb48434015 100644 --- a/public/js/wn/ui/appframe.js +++ b/public/js/wn/ui/appframe.js @@ -83,28 +83,32 @@ wn.ui.AppFrame = Class.extend({ new_doc(doctype); } } - }] + }]; + if(!locals.DocType[doctype].issingle) { views.push({ icon: "icon-list", route: "List/" + doctype, type: "list" }); - }; + } + if(locals.DocType[doctype].__calendar_js) { views.push({ icon: "icon-calendar", route: "Calendar/" + doctype, type: "calendar" - }) + }); } + if(wn.model.can_get_report(doctype)) { views.push({ icon: "icon-table", route: "Report2/" + doctype, type: "report" - }) + }); } + this.set_views(views, active_view); }, diff --git a/webnotes/__init__.py b/webnotes/__init__.py index 31f5ce0809..838055e0cc 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -182,7 +182,7 @@ def get_db_password(db_name): whitelisted = [] guest_methods = [] -def whitelist(allow_guest=False, allow_roles=[]): +def whitelist(allow_guest=False, allow_roles=None): """ decorator for whitelisting a function From 4b189d497ef13447d0bd3c5073cf2ee07711fe38 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 1 Apr 2013 16:51:33 +0530 Subject: [PATCH 4/5] [setup] [update manager] renamed update-this-app page to update-manager --- core/page/{update_this_app => update_manager}/__init__.py | 0 .../update_manager.js} | 8 ++++---- .../update_manager.py} | 0 .../update_manager.txt} | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) rename core/page/{update_this_app => update_manager}/__init__.py (100%) rename core/page/{update_this_app/update_this_app.js => update_manager/update_manager.js} (83%) rename core/page/{update_this_app/update_this_app.py => update_manager/update_manager.py} (100%) rename core/page/{update_this_app/update_this_app.txt => update_manager/update_manager.txt} (85%) diff --git a/core/page/update_this_app/__init__.py b/core/page/update_manager/__init__.py similarity index 100% rename from core/page/update_this_app/__init__.py rename to core/page/update_manager/__init__.py diff --git a/core/page/update_this_app/update_this_app.js b/core/page/update_manager/update_manager.js similarity index 83% rename from core/page/update_this_app/update_this_app.js rename to core/page/update_manager/update_manager.js index f639b92e56..24a29853d1 100644 --- a/core/page/update_this_app/update_this_app.js +++ b/core/page/update_manager/update_manager.js @@ -1,4 +1,4 @@ -wn.pages['update-this-app'].onload = function(wrapper) { +wn.pages['update-manager'].onload = function(wrapper) { wn.ui.make_app_page({ parent: wrapper, title: 'Update This Application', @@ -26,12 +26,12 @@ wn.UpdateThisApp = Class.extend({ wn._('This feature is only applicable to self hosted instances')); } else { - this.wrapper.appframe.add_button("Get Latest Updates", + this.wrapper.appframe.add_button(wn._("Get Latest Updates"), function() { me.update_this_app(this); }, "icon-rss"); this.wrapper.update_output = $('
')
 				.appendTo(this.body.append("
")); - this.wrapper.update_output.text("Click - Get Latest Updates"); + this.wrapper.update_output.text(wn._('Click on "Get Latest Updates"')); } }, @@ -40,7 +40,7 @@ wn.UpdateThisApp = Class.extend({ var me = this; wn.call({ module: "core", - page: "update_this_app", + page: "update_manager", method: "update_this_app", callback: function(r) { me.wrapper.update_output.text(r.message); diff --git a/core/page/update_this_app/update_this_app.py b/core/page/update_manager/update_manager.py similarity index 100% rename from core/page/update_this_app/update_this_app.py rename to core/page/update_manager/update_manager.py diff --git a/core/page/update_this_app/update_this_app.txt b/core/page/update_manager/update_manager.txt similarity index 85% rename from core/page/update_this_app/update_this_app.txt rename to core/page/update_manager/update_manager.txt index 5a0e021f33..82fab61b65 100644 --- a/core/page/update_this_app/update_this_app.txt +++ b/core/page/update_manager/update_manager.txt @@ -10,20 +10,20 @@ "doctype": "Page", "module": "Core", "name": "__common__", - "page_name": "update-this-app", + "page_name": "update-manager", "standard": "Yes", "title": "Update This Application" }, { "doctype": "Page Role", "name": "__common__", - "parent": "update-this-app", + "parent": "update-manager", "parentfield": "roles", "parenttype": "Page" }, { "doctype": "Page", - "name": "update-this-app" + "name": "update-manager" }, { "doctype": "Page Role", From 1c2860c9d189957a9f7938e2e42cc2f5ecbf8ccb Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 1 Apr 2013 19:17:45 +0530 Subject: [PATCH 5/5] [doc] [fix] getchildren injection issue --- webnotes/model/doc.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/webnotes/model/doc.py b/webnotes/model/doc.py index 1e3385fee7..e2a654cdcd 100755 --- a/webnotes/model/doc.py +++ b/webnotes/model/doc.py @@ -593,15 +593,18 @@ def getchildren(name, childtype, field='', parenttype='', from_doctype=0, prefix import webnotes from webnotes.model.doclist import DocList - tmp = '' + condition = "" + values = [] if field: - tmp = ' and parentfield="%s" ' % field + condition += ' and parentfield=%s ' + values.append(field) if parenttype: - tmp = ' and parenttype="%s" ' % parenttype + condition += ' and parenttype=%s ' + values.append(parenttype) - dataset = webnotes.conn.sql("select * from `%s%s` where parent='%s' %s order by idx" \ - % (prefix, childtype, name, tmp)) + dataset = webnotes.conn.sql("""select * from `%s%s` where parent=%s %s order by idx""" \ + % (prefix, childtype, "%s", condition), tuple([name]+values)) desc = webnotes.conn.get_description() l = DocList()