diff --git a/config.json b/config.json index c9d1aa71f8..5412b017b2 100644 --- a/config.json +++ b/config.json @@ -1,4 +1,5 @@ { + "app_name": "ERPNext", "modules": { "Selling": { "link": "selling-home", diff --git a/utilities/demo/__init__.py b/utilities/demo/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utilities/demo/demo-login.css b/utilities/demo/demo-login.css new file mode 100644 index 0000000000..f3464a3a2d --- /dev/null +++ b/utilities/demo/demo-login.css @@ -0,0 +1,3 @@ +body, #container, .outer { + background-color: #888 !important; +} \ No newline at end of file diff --git a/utilities/demo/demo-login.html b/utilities/demo/demo-login.html new file mode 100644 index 0000000000..ef24678e27 --- /dev/null +++ b/utilities/demo/demo-login.html @@ -0,0 +1,25 @@ +
+
+
+
+
+ Start ERPNext Demo +
+
+

+ +

+

+ +

+
+

Some functionality is disabled for the demo app. The demo data will be cleared regulary. To start your own ERPNext Trial, click here

+
+
+
+
+
+
+
diff --git a/utilities/demo/demo-login.js b/utilities/demo/demo-login.js new file mode 100644 index 0000000000..229d1690e5 --- /dev/null +++ b/utilities/demo/demo-login.js @@ -0,0 +1,27 @@ +$(document).ready(function() { + $(".navbar, footer, .banner, #user-tools").toggle(false); + + $("#login_btn").click(function() { + var me = this; + $(this).html("Logging In...").attr("disabled", "disabled"); + wn.call({ + "method": "login", + args: { + usr: "demo@erpnext.com", + pwd: "demo", + lead_email: $("#lead-email").val(), + }, + callback: function(r) { + $(me).attr("disabled", false); + if(r.exc) { + alert("Error, please contact support@erpnext.com"); + } else { + console.log("Logged In"); + window.location.href = "app.html"; + } + } + }) + return false; + }) + .attr("disabled", false); +}) \ No newline at end of file diff --git a/utilities/demo/demo_control_panel.py b/utilities/demo/demo_control_panel.py new file mode 100644 index 0000000000..c70913ee68 --- /dev/null +++ b/utilities/demo/demo_control_panel.py @@ -0,0 +1,13 @@ + + def on_login(self): + from webnotes.utils import validate_email_add + import conf + if hasattr(conf, "demo_notify_url"): + if webnotes.form_dict.lead_email and validate_email_add(webnotes.form_dict.lead_email): + import requests + response = requests.post(conf.demo_notify_url, data={ + "cmd":"website.helpers.contact.send_message", + "subject":"Logged into Demo", + "sender": webnotes.form_dict.lead_email, + "message": "via demo.erpnext.com" + }) diff --git a/utilities/demo_docs/Address.csv b/utilities/demo/demo_docs/Address.csv similarity index 100% rename from utilities/demo_docs/Address.csv rename to utilities/demo/demo_docs/Address.csv diff --git a/utilities/demo_docs/BOM.csv b/utilities/demo/demo_docs/BOM.csv similarity index 100% rename from utilities/demo_docs/BOM.csv rename to utilities/demo/demo_docs/BOM.csv diff --git a/utilities/demo_docs/Contact.csv b/utilities/demo/demo_docs/Contact.csv similarity index 100% rename from utilities/demo_docs/Contact.csv rename to utilities/demo/demo_docs/Contact.csv diff --git a/utilities/demo_docs/Customer.csv b/utilities/demo/demo_docs/Customer.csv similarity index 100% rename from utilities/demo_docs/Customer.csv rename to utilities/demo/demo_docs/Customer.csv diff --git a/utilities/demo_docs/Employee.csv b/utilities/demo/demo_docs/Employee.csv similarity index 100% rename from utilities/demo_docs/Employee.csv rename to utilities/demo/demo_docs/Employee.csv diff --git a/utilities/demo_docs/Fiscal_Year.csv b/utilities/demo/demo_docs/Fiscal_Year.csv similarity index 100% rename from utilities/demo_docs/Fiscal_Year.csv rename to utilities/demo/demo_docs/Fiscal_Year.csv diff --git a/utilities/demo_docs/Item.csv b/utilities/demo/demo_docs/Item.csv similarity index 100% rename from utilities/demo_docs/Item.csv rename to utilities/demo/demo_docs/Item.csv diff --git a/utilities/demo_docs/Item_Price.csv b/utilities/demo/demo_docs/Item_Price.csv similarity index 100% rename from utilities/demo_docs/Item_Price.csv rename to utilities/demo/demo_docs/Item_Price.csv diff --git a/utilities/demo_docs/Lead.csv b/utilities/demo/demo_docs/Lead.csv similarity index 100% rename from utilities/demo_docs/Lead.csv rename to utilities/demo/demo_docs/Lead.csv diff --git a/utilities/demo_docs/Profile.csv b/utilities/demo/demo_docs/Profile.csv similarity index 100% rename from utilities/demo_docs/Profile.csv rename to utilities/demo/demo_docs/Profile.csv diff --git a/utilities/demo_docs/Salary_Structure.csv b/utilities/demo/demo_docs/Salary_Structure.csv similarity index 100% rename from utilities/demo_docs/Salary_Structure.csv rename to utilities/demo/demo_docs/Salary_Structure.csv diff --git a/utilities/demo_docs/Stock Reconcilation Template.csv b/utilities/demo/demo_docs/Stock Reconcilation Template.csv similarity index 100% rename from utilities/demo_docs/Stock Reconcilation Template.csv rename to utilities/demo/demo_docs/Stock Reconcilation Template.csv diff --git a/utilities/demo_docs/Supplier.csv b/utilities/demo/demo_docs/Supplier.csv similarity index 100% rename from utilities/demo_docs/Supplier.csv rename to utilities/demo/demo_docs/Supplier.csv diff --git a/utilities/demo_docs/bearing-block.png b/utilities/demo/demo_docs/bearing-block.png similarity index 100% rename from utilities/demo_docs/bearing-block.png rename to utilities/demo/demo_docs/bearing-block.png diff --git a/utilities/demo_docs/wind-turbine.png b/utilities/demo/demo_docs/wind-turbine.png similarity index 100% rename from utilities/demo_docs/wind-turbine.png rename to utilities/demo/demo_docs/wind-turbine.png diff --git a/utilities/make_demo.py b/utilities/demo/make_demo.py similarity index 93% rename from utilities/make_demo.py rename to utilities/demo/make_demo.py index 2884144135..fc0776740e 100644 --- a/utilities/make_demo.py +++ b/utilities/demo/make_demo.py @@ -19,9 +19,9 @@ company_abbr = "WP" country = "United States" currency = "USD" time_zone = "America/New York" -start_date = '2010-01-01' +start_date = '2013-01-01' bank_name = "Citibank" -runs_for = 20 +runs_for = None prob = { "default": { "make": 0.6, "qty": (1,5) }, "Sales Order": { "make": 0.4, "qty": (1,3) }, @@ -50,21 +50,24 @@ def setup(): # make_opening_accounts() def simulate(): - current_date = None - for i in xrange(runs_for): - if not current_date: - # get last stock ledger posting date or use default - last_posting = webnotes.conn.sql("""select max(posting_date) from `tabStock Ledger Entry`""") - if last_posting[0][0]: - current_date = webnotes.utils.add_days(last_posting[0][0], 1) - else: - current_date = webnotes.utils.getdate(start_date) - else: - current_date = webnotes.utils.add_days(current_date, 1) - + global runs_for + current_date = webnotes.utils.getdate(start_date) + + # continue? + last_posting = webnotes.conn.sql("""select max(posting_date) from `tabStock Ledger Entry`""") + if last_posting[0][0]: + current_date = webnotes.utils.add_days(last_posting[0][0], 1) + + # run till today + if not runs_for: + runs_for = webnotes.utils.date_diff(webnotes.utils.nowdate(), current_date) + + for i in xrange(runs_for): print current_date.strftime("%Y-%m-%d") + webnotes.utils.current_date = current_date if current_date.weekday() in (5, 6): + current_date = webnotes.utils.add_days(current_date, 1) continue run_sales(current_date) @@ -72,6 +75,8 @@ def simulate(): run_manufacturing(current_date) run_stock(current_date) run_accounts(current_date) + + current_date = webnotes.utils.add_days(current_date, 1) def run_sales(current_date): if can_make("Quotation"): @@ -136,7 +141,7 @@ def run_stock(current_date): for po in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Purchase Receipt")]: pr = webnotes.bean(make_purchase_receipt(po)) pr.doc.posting_date = current_date - pr.doc.fiscal_year = "2010" + pr.doc.fiscal_year = "2013" pr.insert() pr.submit() webnotes.conn.commit() @@ -150,7 +155,7 @@ def run_stock(current_date): for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Delivery Note")]: dn = webnotes.bean(make_delivery_note(so)) dn.doc.posting_date = current_date - dn.doc.fiscal_year = "2010" + dn.doc.fiscal_year = "2013" dn.insert() try: dn.submit() @@ -173,7 +178,7 @@ def run_purchase(current_date): mr = webnotes.new_bean("Material Request") mr.doc.material_request_type = "Purchase" mr.doc.transaction_date = current_date - mr.doc.fiscal_year = "2010" + mr.doc.fiscal_year = "2013" mr.doclist.append({ "doctype": "Material Request Item", "parentfield": "indent_details", @@ -192,7 +197,7 @@ def run_purchase(current_date): if row[0] != "Total": sq = webnotes.bean(make_supplier_quotation(row[0])) sq.doc.transaction_date = current_date - sq.doc.fiscal_year = "2010" + sq.doc.fiscal_year = "2013" sq.insert() sq.submit() webnotes.conn.commit() @@ -205,7 +210,7 @@ def run_purchase(current_date): if row[0] != "Total": po = webnotes.bean(make_purchase_order(row[0])) po.doc.transaction_date = current_date - po.doc.fiscal_year = "2010" + po.doc.fiscal_year = "2013" po.insert() po.submit() webnotes.conn.commit() @@ -263,7 +268,7 @@ def make_stock_entry_from_pro(pro_id, purpose, current_date): st = webnotes.bean(make_stock_entry(pro_id, purpose)) st.doc.posting_date = current_date - st.doc.fiscal_year = "2010" + st.doc.fiscal_year = "2013" st.doc.expense_adjustment_account = "Stock in Hand - WP" try: st.insert() @@ -282,7 +287,7 @@ def make_quotation(current_date): "customer": get_random("Customer"), "order_type": "Sales", "transaction_date": current_date, - "fiscal_year": "2010" + "fiscal_year": "2013" }]) add_random_children(b, { @@ -349,8 +354,9 @@ def how_many(doctype): def install(): print "Creating Fresh Database..." from webnotes.install_lib.install import Installer + import conf inst = Installer('root') - inst.import_from_db("demo", verbose = 1) + inst.import_from_db(conf.demo_db_name, verbose = 1) def complete_setup(): print "Complete Setup..." @@ -392,6 +398,7 @@ def make_bank_account(): }).insert() webnotes.set_value("Company", company, "default_bank_account", ba.doc.name) + webnotes.conn.commit() def import_data(dt, submit=False): if not isinstance(dt, (tuple, list)): diff --git a/utilities/demo/make_erpnext_demo.py b/utilities/demo/make_erpnext_demo.py new file mode 100644 index 0000000000..fde05f6a9b --- /dev/null +++ b/utilities/demo/make_erpnext_demo.py @@ -0,0 +1,77 @@ +import webnotes, os + +def make_demo_app(): + import utilities.demo.make_demo + utilities.demo.make_demo.make(reset=True) + +def make_demo_user(): + if webnotes.conn.exists("Profile", "demo@erpnext.com"): + webnotes.delete_doc("Profile", "demo@erpnext.com") + + p = webnotes.new_bean("Profile") + p.doc.email = "demo@erpnext.com" + p.doc.first_name = "Demo" + p.doc.last_name = "User" + p.doc.enabled = 1 + p.doc.user_type = "ERPNext Demo" + p.doc.send_invite_email = 0 + p.doc.new_password = "demo" + p.insert() + + for role in ("Accounts Manager", "Analytics", "Expense Approver", "Accounts User", + "Leave Approver", "Blogger", "Customer", "Sales Manager", "Employee", "Support Manager", + "HR Manager", "HR User", "Maintenance Manager", "Maintenance User", "Material Manager", + "Material Master Manager", "Material User", "Partner", "Manufacturing Manager", + "Manufacturing User", "Projects User", "Purchase Manager", "Purchase Master Manager", + "Purchase User", "Quality Manager", "Report Manager", "Sales Master Manager", "Sales User", + "Supplier", "Support Team"): + p.doclist.append({ + "doctype": "UserRole", + "parentfield": "user_roles", + "role": role + }) + + p.save() + webnotes.conn.commit() + +def make_demo_login_page(): + webnotes.conn.set_value("Website Settings", None, "home_page", "") + + webnotes.conn.sql("""delete from `tabWeb Page` where name='demo-login'""") + p = webnotes.new_bean("Web Page") + p.doc.title = "Demo Login" + p.doc.published = 1 + p.doc.description = "ERPNext Demo Login" + + with open(os.path.join(os.path.dirname(__file__), "demo-login.html"), "r") as dfile: + p.doc.main_section = dfile.read() + + p.doc.insert_code = 1 + with open(os.path.join(os.path.dirname(__file__), "demo-login.js"), "r") as dfile: + p.doc.javascript = dfile.read() + + p.doc.insert_style = 1 + with open(os.path.join(os.path.dirname(__file__), "demo-login.css"), "r") as dfile: + p.doc.css = dfile.read() + + p.insert() + + webnotes.conn.set_value("Website Settings", None, "home_page", "demo-login") + + webnotes.conn.commit() + +def make_demo_on_login_script(): + webnotes.conn.sql("""delete from `tabCustom Script` where dt='Control Panel'""") + s = webnotes.new_bean("Custom Script") + s.doc.dt = "Control Panel" + s.doc.script_type = "Server" + with open(os.path.join(os.path.dirname(__file__), "demo_control_panel.py"), "r") as dfile: + s.doc.script = dfile.read() + +if __name__=="__main__": + webnotes.connect() + webnotes.mute_emails = 1 + make_demo_app() + make_demo_user() + make_demo_login_page() + make_demo_on_login_script() \ No newline at end of file diff --git a/website/doctype/website_settings/website_settings.js b/website/doctype/website_settings/website_settings.js index 0d0dab68c0..21b55be5ea 100644 --- a/website/doctype/website_settings/website_settings.js +++ b/website/doctype/website_settings/website_settings.js @@ -4,6 +4,14 @@ // update parent select $.extend(cur_frm.cscript, { + refresh: function(doc) { + cur_frm.add_custom_button("Auto Build Website", function() { + cur_frm.call({ + doc: cur_frm.doc, + method: "make_website" + }) + }, 'icon-magic') + }, onload_post_render: function(doc) { this.set_parent_label_options(); }, diff --git a/website/doctype/website_settings/website_settings.py b/website/doctype/website_settings/website_settings.py index 3b27c7ccc1..5d6c874d70 100644 --- a/website/doctype/website_settings/website_settings.py +++ b/website/doctype/website_settings/website_settings.py @@ -13,6 +13,26 @@ class DocType: self.set_home_page() self.validate_top_bar_items() self.validate_footer_items() + + def make_website(self): + # set item pages + for name in webnotes.conn.sql_list("""select name from tabItem where + ifnull(show_in_website, 0)=0 and is_sales_item ='Yes' """): + webnotes.msgprint("Setting 'Show in Website' for:" + name) + item = webnotes.bean("Item", name) + item.doc.show_in_website = 1 + item.doc.website_warehouse = item.doc.default_warehouse + item.doc.website_image = item.doc.image + item.save() + + # set item group pages + for name in webnotes.conn.sql_list("""select name from `tabItem Group` where + ifnull(show_in_website, 0)=0 and exists (select name from tabItem where + ifnull(show_in_website, 0)=1)"""): + webnotes.msgprint("Setting 'Show in Website' for:" + name) + item_group = webnotes.bean("Item Group", name) + item_group.doc.show_in_website = 1 + item_group.save() def validate_top_bar_items(self): """validate url in top bar items"""