From 3aaea724b2d05126e90773895f65fd62bbe1b747 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 1 Apr 2013 16:40:19 +0530 Subject: [PATCH] [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