diff --git a/erpnext/config/__init__.py b/erpnext/config/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/desktop.json b/erpnext/config/desktop.py similarity index 91% rename from erpnext/desktop.json rename to erpnext/config/desktop.py index 67c4f998842..62013af8da7 100644 --- a/erpnext/desktop.json +++ b/erpnext/config/desktop.py @@ -1,4 +1,6 @@ -{ +from webnotes import _ + +data = { "Accounts": { "color": "#3498db", "icon": "icon-money", @@ -8,7 +10,7 @@ "Activity": { "color": "#e67e22", "icon": "icon-play", - "label": "Activity", + "label": _("Activity"), "link": "activity", "type": "page" }, @@ -21,7 +23,7 @@ "HR": { "color": "#2ecc71", "icon": "icon-group", - "label": "Human Resources", + "label": _("Human Resources"), "link": "hr-home", "type": "module" }, @@ -35,7 +37,7 @@ "color": "#95a5a6", "doctype": "Note", "icon": "icon-file-alt", - "label": "Notes", + "label": _("Notes"), "link": "List/Note", "type": "list" }, diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 026276365b3..ff65fb340f4 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -18,4 +18,5 @@ execute:webnotes.reload_doc('selling', 'doctype', 'customer') # 2014-01-29 execute:webnotes.reload_doc('buying', 'doctype', 'supplier') # 2014-01-29 erpnext.patches.4_0.map_charge_to_taxes_and_charges execute:webnotes.reload_doc('support', 'doctype', 'newsletter') # 2014-01-31 -execute:webnotes.reload_doc('hr', 'doctype', 'employee') # 2014-02-03 \ No newline at end of file +execute:webnotes.reload_doc('hr', 'doctype', 'employee') # 2014-02-03 +execute:webnotes.conn.sql("update tabPage set module='Core' where name='Setup'") diff --git a/erpnext/setup/page/setup/setup.js b/erpnext/setup/page/setup/setup.js index fdde6934e52..9c7395d4f7d 100644 --- a/erpnext/setup/page/setup/setup.js +++ b/erpnext/setup/page/setup/setup.js @@ -11,195 +11,20 @@ wn.pages['Setup'].onload = function(wrapper) { wrapper.appframe.add_module_icon("Setup"); wrapper.appframe.set_title_right(wn._("Refresh"), function() { - wn.pages.Setup.make(wrapper); + wn.setup.make(wrapper); }); - wn.pages.Setup.make(wrapper); + wn.setup.make(wrapper); } -wn.pages.Setup.make = function(wrapper) { - var body = $(wrapper).find(".layout-main"), - total = 0, - completed = 0; - - body.html('
\ -
'); - - var render_item = function(item, dependency) { - if(item.type==="Section") { - $("

") - .css({"margin": "20px 0px 15px 0px"}) - .html(' ' + item.title).appendTo(body); - return; - } - var row = $('
') - .css({ - "margin-bottom": "7px", - "padding-bottom": "7px", - "border-bottom": "1px solid #eee" - }) - .appendTo(body); - - $('
').appendTo(row); - - if(item.type==="Link") { - var col = $('').appendTo(row); - - } else { - var col = $(repl('
\ - %(count)s\ - \ - %(title)s\ -
', { - count: item.count, - title: item.title || wn._(item.doctype), - icon: wn.boot.doctype_icons[item.doctype] - })) - .appendTo(row); - - col.find(".badge") - .css({ - "background-color": (item.count ? "green" : "orange"), - "display": "inline-block", - "min-width": "40px" - }); - - total += 1; - if(item.count) - completed += 1; - } - - if(dependency) - col.addClass("col-md-offset-1"); - else - $('
').appendTo(row); - - if(item.doctype) { - var badge = col.find(".badge, .data-link") - .attr("data-doctype", item.doctype) - .css({"cursor": "pointer"}) - - if(item.single) { - badge.click(function() { - wn.set_route("Form", $(this).attr("data-doctype")) - }) - } else { - badge.click(function() { - wn.set_route(item.tree || "List", $(this).attr("data-doctype")) - }) +wn.setup = { + make: function(wrapper) { + wn.call({ + method: "webnotes.core.page.setup.setup.get", + callback: function(r) { + wrapper.find(".layout-main").empty().html(r.message); } - } - - // tree - $links = $('
').appendTo(row); - - if(item.tree) { - $(' Browse\ - | \ - Import') - .appendTo($links) - - var mylink = $links.find(".view-link") - .attr("data-doctype", item.doctype) - - mylink.click(function() { - wn.set_route(item.tree, item.doctype); - }) - - } else if(item.single) { - $(''+wn._('Edit')+'') - .appendTo($links) - - $links.find(".view-link") - .attr("data-doctype", item.doctype) - .click(function() { - wn.set_route("Form", $(this).attr("data-doctype")); - }) - } else if(item.type !== "Link"){ - $(''+wn._('New')+' \ - | \ - '+wn._('View')+' \ - | \ - '+wn._('Import')+'') - .appendTo($links) - - $links.find(".view-link") - .attr("data-doctype", item.doctype) - .click(function() { - if($(this).attr("data-filter")) { - wn.route_options = JSON.parse($(this).attr("data-filter")); - } - wn.set_route("List", $(this).attr("data-doctype")); - }) - - if(item.filter) - $links.find(".view-link").attr("data-filter", JSON.stringify(item.filter)) - - if(wn.model.can_create(item.doctype)) { - $links.find(".new-link") - .attr("data-doctype", item.doctype) - .click(function() { - new_doc($(this).attr("data-doctype")) - }) - } else { - $links.find(".new-link").remove(); - $links.find(".text-muted:first").remove(); - } - - } - - $links.find(".import-link") - .attr("data-doctype", item.doctype) - .click(function() { - wn.route_options = {doctype:$(this).attr("data-doctype")} - wn.set_route("data-import-tool"); - }) - - if(item.links) { - $.each(item.links, function(i, link) { - var newlinks = $(' | \ - '+link.title+'') - .appendTo($links) - }) - } - - if(item.dependencies) { - $.each(item.dependencies, function(i, d) { - render_item(d, true); - }) - } + }) } - - return wn.call({ - method: "erpnext.setup.page.setup.setup.get", - callback: function(r) { - if(r.message) { - body.empty(); - if(wn.boot.expires_on) { - $(body).prepend("
"+wn._("Account expires on") - + wn.datetime.global_date_format(wn.boot.expires_on) + "
"); - } - - $completed = $('

'+wn._("Setup Completed")+'

\ -
') - .appendTo(body); - - $.each(r.message, function(i, item) { - render_item(item) - }); - - var completed_percent = cint(flt(completed) / total * 100) + "%"; - $completed - .find(".progress-bar") - .css({"width": completed_percent}); - $(body) - .find(".completed-percent") - .html("(" + completed_percent + ")"); - } - } - }); -} \ No newline at end of file +} diff --git a/erpnext/setup/page/setup/setup.py b/erpnext/setup/page/setup/setup.py index 11025c96070..5e66d0a4698 100644 --- a/erpnext/setup/page/setup/setup.py +++ b/erpnext/setup/page/setup/setup.py @@ -2,9 +2,21 @@ # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals -import webnotes +import webnotes, json from webnotes import _ +@webnotes.whitelist() +def get(): + setup = [] + for app in webnotes.get_installed_apps(): + setupfilename = webnotes.get_app_path(app, "setup.json") + if os.path.exists(setupfilename): + with open(setupfilename, "r") as f: + setup.append(json.loads(f)) + + return setup + + items = [ { "type": "Section", @@ -233,28 +245,31 @@ items = [ "route": "Report/Scheduler Log", "type": "Link", "icon": "icon-exclamation-sign" }, ] -@webnotes.whitelist() -def get(): - webnotes.only_for("System Manager") - for item in items: - if item.get("type")=="Section": - continue - set_count(item) - - if item.get("dependencies"): - for d in item["dependencies"]: - set_count(d) - - return items -def set_count(item): - if "query" in item: - item["count"] = webnotes.conn.sql(item["query"])[0][0] - elif "filter" in item: - key = item["filter"].keys()[0] - item["count"] = webnotes.conn.sql("""select count(*) from `tab%s` where - %s = %s and docstatus < 2""" % (item["doctype"], key, "%s"), - item["filter"][key])[0][0] - elif "doctype" in item: - item["count"] = webnotes.conn.sql("select count(*) from `tab%s` where docstatus<2" \ - % item["doctype"])[0][0] + + +# @webnotes.whitelist() +# def get(): +# webnotes.only_for("System Manager") +# for item in items: +# if item.get("type")=="Section": +# continue +# set_count(item) +# +# if item.get("dependencies"): +# for d in item["dependencies"]: +# set_count(d) +# +# return items +# +# def set_count(item): +# if "query" in item: +# item["count"] = webnotes.conn.sql(item["query"])[0][0] +# elif "filter" in item: +# key = item["filter"].keys()[0] +# item["count"] = webnotes.conn.sql("""select count(*) from `tab%s` where +# %s = %s and docstatus < 2""" % (item["doctype"], key, "%s"), +# item["filter"][key])[0][0] +# elif "doctype" in item: +# item["count"] = webnotes.conn.sql("select count(*) from `tab%s` where docstatus<2" \ +# % item["doctype"])[0][0]