From 4b1fe0528ad3d10ae4244f5f7f9bc6b846297a6f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 25 Jan 2012 15:06:28 +0530 Subject: [PATCH] added home template --- blank.html | 0 erpnext/patches/jan_mar_2012/website.py | 7 +++ erpnext/startup/event_handlers.py | 2 +- erpnext/website/css/website.css | 12 ++++ .../doctype/home_settings/home_settings.py | 26 ++++++++ .../doctype/home_settings/home_settings.txt | 59 ++++++++++++++++--- .../doctype/home_settings/template.html | 17 ++++++ erpnext/website/page/home/home.html | 17 ------ index.html | 2 +- version.num | 2 +- 10 files changed, 116 insertions(+), 28 deletions(-) create mode 100644 blank.html create mode 100644 erpnext/website/doctype/home_settings/home_settings.py create mode 100644 erpnext/website/doctype/home_settings/template.html delete mode 100644 erpnext/website/page/home/home.html diff --git a/blank.html b/blank.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/patches/jan_mar_2012/website.py b/erpnext/patches/jan_mar_2012/website.py index a19cd447dd5..ad60cc58e44 100644 --- a/erpnext/patches/jan_mar_2012/website.py +++ b/erpnext/patches/jan_mar_2012/website.py @@ -2,6 +2,8 @@ import webnotes def execute(): + cleanup_file_data() + return update_patch_log() from webnotes.modules import reload_doc reload_doc('website', 'Module Def', 'Website') @@ -11,6 +13,11 @@ def execute(): reload_doc('website', 'doctype', 'top_bar_item') reload_doc('website', 'page', 'home') +def cleanup_file_data(): + webnotes.conn.commit() + webnotes.conn.sql("""alter table `tabFile Data` drop column blob_content""") + webnotes.conn.begin() + def update_patch_log(): webnotes.conn.commit() webnotes.conn.sql("""alter table __PatchLog engine=InnoDB""") diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index 02752623a3d..8b1a7cfe8dc 100644 --- a/erpnext/startup/event_handlers.py +++ b/erpnext/startup/event_handlers.py @@ -50,4 +50,4 @@ def get_letter_heads(): """load letter heads with startup""" import webnotes ret = webnotes.conn.sql("select name, content from `tabLetter Head` where ifnull(disabled,0)=0") - dict(ret) + return dict(ret) diff --git a/erpnext/website/css/website.css b/erpnext/website/css/website.css index 025856de1b4..bdef882b648 100644 --- a/erpnext/website/css/website.css +++ b/erpnext/website/css/website.css @@ -6,4 +6,16 @@ header .topbar .container { width: 900px; margin: auto; +} + +.web-main-section { + width: 65%; + float: left; + margin-bottom: 20px; +} + +.web-side-section { + width: 30%; + float: right; + margin-bottom: 20px; } \ No newline at end of file diff --git a/erpnext/website/doctype/home_settings/home_settings.py b/erpnext/website/doctype/home_settings/home_settings.py new file mode 100644 index 00000000000..3ceea169180 --- /dev/null +++ b/erpnext/website/doctype/home_settings/home_settings.py @@ -0,0 +1,26 @@ +""" +generate home html +""" + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl + + def on_update(self): + """make home html""" + import os, jinja2, markdown2 + import webnotes + + # markdown + self.doc.main_section_html = markdown2.markdown(self.doc.main_section or '', \ + extras=["wiki-tables"]) + self.doc.side_section_html = markdown2.markdown(self.doc.side_section or '', \ + extras=["wiki-tables"]) + + # write template + with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f: + temp = jinja2.Template(f.read()) + + html = temp.render(doc = self.doc.fields) + webnotes.conn.set_value('Page', 'Home', 'content', html) + \ No newline at end of file diff --git a/erpnext/website/doctype/home_settings/home_settings.txt b/erpnext/website/doctype/home_settings/home_settings.txt index b95be64be04..413f63fcc4c 100644 --- a/erpnext/website/doctype/home_settings/home_settings.txt +++ b/erpnext/website/doctype/home_settings/home_settings.txt @@ -5,31 +5,29 @@ { 'creation': '2012-01-24 15:56:06', 'docstatus': 0, - 'modified': '2012-01-24 15:56:06', + 'modified': '2012-01-25 13:31:56', 'modified_by': 'Administrator', 'owner': 'Administrator' }, # These values are common for all DocType { + '_last_update': '1327476129', + 'allow_attach': 1, 'colour': 'White:FFF', 'doctype': 'DocType', 'issingle': 1, + 'max_attachments': 5, 'module': 'Website', 'name': '__common__', 'section_style': 'Simple', 'show_in_menu': 0, - 'version': 1 + 'version': 4 }, # These values are common for all DocField { - 'colour': 'White:FFF', - 'description': 'HTML that will appear on the top part of the home page. Usually should contain a headline and image.', 'doctype': 'DocField', - 'fieldname': 'banner_html', - 'fieldtype': 'Code', - 'label': 'Banner HTML', 'name': '__common__', 'parent': 'Home Settings', 'parentfield': 'fields', @@ -70,6 +68,51 @@ # DocField { - 'doctype': 'DocField' + 'colour': 'White:FFF', + 'description': 'HTML that will appear on the top part of the home page. For no headline, leave blank', + 'doctype': 'DocField', + 'fieldname': 'headline', + 'fieldtype': 'Text', + 'label': 'Headline' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'banner', + 'fieldtype': 'Select', + 'label': 'Banner', + 'options': 'attach_files:' + }, + + # DocField + { + 'colour': 'White:FFF', + 'description': 'For formatting, use \nmarkdown', + 'doctype': 'DocField', + 'fieldname': 'main_section', + 'fieldtype': 'Code', + 'label': 'Main Section' + }, + + # DocField + { + 'colour': 'White:FFF', + 'description': 'For formatting, use \nmarkdown', + 'doctype': 'DocField', + 'fieldname': 'side_section', + 'fieldtype': 'Code', + 'label': 'Side Section' + }, + + # DocField + { + 'doctype': 'DocField', + 'fieldname': 'file_list', + 'fieldtype': 'Text', + 'hidden': 1, + 'label': 'File List', + 'no_copy': 1, + 'print_hide': 1 } ] \ No newline at end of file diff --git a/erpnext/website/doctype/home_settings/template.html b/erpnext/website/doctype/home_settings/template.html new file mode 100644 index 00000000000..424489a4cc3 --- /dev/null +++ b/erpnext/website/doctype/home_settings/template.html @@ -0,0 +1,17 @@ +
+
+ {% if doc.headline %} +

{{ doc.headline }}

+ {% endif %} + {% if doc.banner %} + + {% endif %} +
+ {{ doc.main_section_html }} +
+
+ {{ doc.side_section_html }} +
+
+
+
\ No newline at end of file diff --git a/erpnext/website/page/home/home.html b/erpnext/website/page/home/home.html deleted file mode 100644 index a07fe939b54..00000000000 --- a/erpnext/website/page/home/home.html +++ /dev/null @@ -1,17 +0,0 @@ -#!python - -from webnotes.model.doc import getsingle -from jinja2 import Template - - -temp = Template(""" -
-
- {{ home_settings.banner_html }} -
-
-""") - -out = { - "content": temp.render(home_settings = getsingle('Home Settings')) -} \ No newline at end of file diff --git a/index.html b/index.html index 6302c4d739f..dacded50693 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ ERPNext -