From e41bceb3dfd0e529b6798649d765286e02e3e7b6 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 10 Jul 2013 20:42:44 +0530 Subject: [PATCH 1/4] [feature] [website] Create Default Home Page --- public/js/complete_setup.js | 11 ++++-- setup/doctype/company/company.py | 39 +++++++++++++++++++ setup/doctype/company/sample_home_page.html | 22 +++++++++++ .../notification_control.txt | 3 +- setup/doctype/setup_control/setup_control.py | 7 ++-- startup/install.py | 20 ++++------ website/css/website.css | 4 ++ .../style_settings/custom_template.css | 2 +- .../website_settings/website_settings.js | 2 +- .../website_settings/website_settings.txt | 2 +- website/templates/html/navbar.html | 2 +- 11 files changed, 91 insertions(+), 23 deletions(-) create mode 100644 setup/doctype/company/sample_home_page.html diff --git a/public/js/complete_setup.js b/public/js/complete_setup.js index 4fb29e30fc..a93aae6ce1 100644 --- a/public/js/complete_setup.js +++ b/public/js/complete_setup.js @@ -75,6 +75,7 @@ $.extend(erpnext.complete_setup, { if(!data) return; $(this).set_working(); $c_obj('Setup Control','setup_account',data,function(r, rt){ + $(this).done_working(); if(!r.exc) { sys_defaults = r.message; user_fullname = r.message.user_fullname; @@ -84,12 +85,16 @@ $.extend(erpnext.complete_setup, { wn.container.wntoolbar.set_user_name(); setTimeout(function() { window.location.reload(); }, 3000); - } else { - $(this).done_working(); } }); }; - + + d.fields_dict.company_name.input.onchange = function() { + var parts = d.get_input("company_name").val().split(" "); + var abbr = $.map(parts, function(p) { return p ? p.substr(0,1) : null }).join(""); + d.get_input("company_abbr").val(abbr.toUpperCase()); + } + d.fields_dict.country.input.onchange = function() { var country = d.fields_dict.country.input.value; var $timezone = $(d.fields_dict.timezone.input); diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py index ea3d1b9cf0..968296c901 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -39,6 +39,7 @@ class DocType: where company=%s and docstatus<2 limit 1""", self.doc.name): self.create_default_accounts() self.create_default_warehouses() + self.create_default_web_page() if not self.doc.cost_center: self.create_default_cost_center() @@ -52,8 +53,46 @@ class DocType: for whname in ("Stores", "Work In Progress", "Finished Goods"): webnotes.bean({ "doctype":"Warehouse", + "warehouse_name": whname, "company": self.doc.name }).insert() + + def create_default_web_page(self): + if not webnotes.conn.get_value("Website Settings", None, "home_page"): + import os + with open(os.path.join(os.path.dirname(__file__), "sample_home_page.html"), "r") as webfile: + webpage = webnotes.bean({ + "doctype": "Web Page", + "title": self.doc.name + " Home", + "published": 1, + "description": "Standard Home Page for " + self.doc.company, + "main_section": webfile.read() % self.doc.fields + }).insert() + + # update in home page in settings + website_settings = webnotes.bean("Website Settings", "Website Settings") + website_settings.doc.home_page = webpage.doc.name + website_settings.doc.banner_html = """

""" + self.doc.name + "

" + website_settings.doc.copyright = self.doc.name + website_settings.doclist.append({ + "doctype": "Top Bar Item", + "parentfield": "top_bar_items", + "label":"Home", + "url": webpage.doc.name + }) + website_settings.doclist.append({ + "doctype": "Top Bar Item", + "parentfield": "top_bar_items", + "label":"Contact", + "url": "contact" + }) + website_settings.doclist.append({ + "doctype": "Top Bar Item", + "parentfield": "top_bar_items", + "label":"Blog", + "url": "blog" + }) + website_settings.save() def create_default_accounts(self): self.fld_dict = {'account_name':0,'parent_account':1,'group_or_ledger':2,'is_pl_account':3,'account_type':4,'debit_or_credit':5,'company':6,'tax_rate':7} diff --git a/setup/doctype/company/sample_home_page.html b/setup/doctype/company/sample_home_page.html new file mode 100644 index 0000000000..32e58bd540 --- /dev/null +++ b/setup/doctype/company/sample_home_page.html @@ -0,0 +1,22 @@ +

Sample Home Page

+
+

This is a sample home page for your company %(name)s's website. This was + created from the Website Module inside ERPNext. ERPNext provides you with simple + tools to build and update your website. You can add sections like your Product Catalog, + Blog, Contact Us, About Us and so on. Messages entered in the "Contact" page are + automatically added as Leads in the system. + +

What you can do with your website:
+ + + +

Infact, + erpnext.com + website is built on ERPNext itself.

+ +

For more help, click here

diff --git a/setup/doctype/notification_control/notification_control.txt b/setup/doctype/notification_control/notification_control.txt index c1f559b99b..81e08a552e 100644 --- a/setup/doctype/notification_control/notification_control.txt +++ b/setup/doctype/notification_control/notification_control.txt @@ -2,7 +2,7 @@ { "creation": "2012-07-12 23:29:45", "docstatus": 0, - "modified": "2013-07-10 14:54:11", + "modified": "2013-07-10 19:24:07", "modified_by": "Administrator", "owner": "Administrator" }, @@ -12,6 +12,7 @@ "allow_print": 1, "description": "Send automatic emails to Contacts on Submitting transactions.", "doctype": "DocType", + "icon": "icon-envelope", "issingle": 1, "module": "Setup", "name": "__common__" diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py index c6b0b6ce28..a85384b202 100644 --- a/setup/doctype/setup_control/setup_control.py +++ b/setup/doctype/setup_control/setup_control.py @@ -65,7 +65,7 @@ class DocType: webnotes.bean([{ "doctype":"Fiscal Year", 'year': curr_fiscal_year, - 'year_start_date': fy_start_date, + 'year_start_date': fy_start_date }]).insert() curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start')) @@ -79,9 +79,10 @@ class DocType: # Company webnotes.bean([{ "doctype":"Company", + 'domain': args.get("industry"), 'company_name':args.get('company_name'), 'abbr':args.get('company_abbr'), - 'default_currency':args.get('currency') + 'default_currency':args.get('currency'), }]).insert() self.curr_fiscal_year = curr_fiscal_year @@ -148,7 +149,7 @@ class DocType: # control panel cp = webnotes.doc("Control Panel", "Control Panel") - for k in ['industry', 'country', 'timezone', 'company_name']: + for k in ['country', 'timezone', 'company_name']: cp.fields[k] = args[k] cp.save() diff --git a/startup/install.py b/startup/install.py index 5b948a9d28..896a6cdc72 100644 --- a/startup/install.py +++ b/startup/install.py @@ -146,9 +146,6 @@ def import_defaults(): {'doctype': 'Supplier Type', 'supplier_type': 'Hardware'}, {'doctype': 'Supplier Type', 'supplier_type': 'Pharmaceutical'}, {'doctype': 'Supplier Type', 'supplier_type': 'Distributor'}, - - # Workstation - {'doctype': 'Workstation', 'name': 'Default Workstation', 'workstation_name': 'Default Workstation', 'warehouse': 'Default Warehouse'}, # Sales Person {'doctype': 'Sales Person', 'sales_person_name': 'Sales Team', 'is_group': "Yes", "parent_sales_person": ""}, @@ -166,12 +163,11 @@ def import_defaults(): from webnotes.modules import scrub for r in records: - if not webnotes.conn.exists(r['doctype'], r['name']): - bean = webnotes.bean(r) - - # ignore mandatory for root - parent_link_field = ("parent_" + scrub(bean.doc.doctype)) - if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field): - bean.ignore_mandatory = True - - bean.insert() \ No newline at end of file + bean = webnotes.bean(r) + + # ignore mandatory for root + parent_link_field = ("parent_" + scrub(bean.doc.doctype)) + if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field): + bean.ignore_mandatory = True + + bean.insert() \ No newline at end of file diff --git a/website/css/website.css b/website/css/website.css index 816b3efd9d..21e1cb2d25 100644 --- a/website/css/website.css +++ b/website/css/website.css @@ -41,6 +41,10 @@ img { margin-left: 5px; } +div.web-footer { + border-top: 1px solid #dddddd; + padding-top: 10px; +} .web-footer-menu ul { list-style: none; diff --git a/website/doctype/style_settings/custom_template.css b/website/doctype/style_settings/custom_template.css index 996774eaea..eb422c96b1 100644 --- a/website/doctype/style_settings/custom_template.css +++ b/website/doctype/style_settings/custom_template.css @@ -9,7 +9,7 @@ body { background-color: #{{ doc.background_color }}; background-image: none; {% else %} - background-color: #edede7; + background-color: #ffffff; {% endif %} {% if doc.font or doc.google_web_font_for_text %} font-family: '{{ doc.google_web_font_for_text or doc.font }}', 'Helvetica Neue', Arial, Sans !important; diff --git a/website/doctype/website_settings/website_settings.js b/website/doctype/website_settings/website_settings.js index 57c32e90cc..2322b7cbf4 100644 --- a/website/doctype/website_settings/website_settings.js +++ b/website/doctype/website_settings/website_settings.js @@ -34,7 +34,7 @@ $.extend(cur_frm.cscript, { url: function(doc, cdt, cdn) { this.label(doc, cdt, cdn); - } + }, set_parent_label_options: function() { wn.meta.get_docfield("Top Bar Item", "parent_label", cur_frm.docname).options = diff --git a/website/doctype/website_settings/website_settings.txt b/website/doctype/website_settings/website_settings.txt index b3828a22f4..f8ceafe162 100644 --- a/website/doctype/website_settings/website_settings.txt +++ b/website/doctype/website_settings/website_settings.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-30 12:58:46", "docstatus": 0, - "modified": "2013-07-05 15:02:50", + "modified": "2013-07-10 20:37:38", "modified_by": "Administrator", "owner": "Administrator" }, diff --git a/website/templates/html/navbar.html b/website/templates/html/navbar.html index 635cf349cc..11f2fb000a 100644 --- a/website/templates/html/navbar.html +++ b/website/templates/html/navbar.html @@ -1,4 +1,4 @@ - -{% endblock %} +{% endblock %} \ No newline at end of file