From 7edf8997060718ffcb90ff49bd7b6efe80b4683c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 25 Dec 2012 18:18:17 +0530 Subject: [PATCH] added wesite slideshow and attributions on website --- home/page/attributions/attributions.css | 3 - home/page/attributions/attributions.html | 11 +- setup/doctype/item_group/item_group.py | 7 +- stock/doctype/item/item.py | 15 ++- website/css/website.css | 9 -- website/doctype/web_page/web_page.py | 9 +- website/doctype/web_page/web_page.txt | 59 +++------ .../website_settings/website_settings.txt | 5 +- website/doctype/website_slideshow/__init__.py | 0 .../website_slideshow/website_slideshow.js | 9 ++ .../website_slideshow/website_slideshow.py | 8 ++ .../website_slideshow/website_slideshow.txt | 85 +++++++++++++ .../website_slideshow_item/__init__.py | 0 .../website_slideshow_item.py | 8 ++ .../website_slideshow_item.txt | 59 +++++++++ website/helpers/product.py | 7 +- website/page/website_home/website_home.html | 11 +- website/templates/html/outer.html | 9 +- website/templates/html/web_page.html | 35 ++++-- website/templates/pages/attributions.html | 112 ++++++++++++++++++ website/utils.py | 18 ++- 21 files changed, 383 insertions(+), 96 deletions(-) create mode 100644 website/doctype/website_slideshow/__init__.py create mode 100644 website/doctype/website_slideshow/website_slideshow.js create mode 100644 website/doctype/website_slideshow/website_slideshow.py create mode 100644 website/doctype/website_slideshow/website_slideshow.txt create mode 100644 website/doctype/website_slideshow_item/__init__.py create mode 100644 website/doctype/website_slideshow_item/website_slideshow_item.py create mode 100644 website/doctype/website_slideshow_item/website_slideshow_item.txt create mode 100644 website/templates/pages/attributions.html diff --git a/home/page/attributions/attributions.css b/home/page/attributions/attributions.css index 68ec5160ee..1de05eec8e 100644 --- a/home/page/attributions/attributions.css +++ b/home/page/attributions/attributions.css @@ -1,6 +1,3 @@ -.layout-attributions table { - width: 70%; -} .layout-attributions td:first-child { width: 30%; } \ No newline at end of file diff --git a/home/page/attributions/attributions.html b/home/page/attributions/attributions.html index 84f25c47bb..7efeb1b8a4 100644 --- a/home/page/attributions/attributions.html +++ b/home/page/attributions/attributions.html @@ -6,12 +6,13 @@ - - + + - - + + @@ -93,7 +94,7 @@

ERPNext License: GNU/General Public License

-
+

ERPNext - Open Source, web based ERP

Copyright © 2012, Web Notes Technologies Pvt Ltd, India

diff --git a/setup/doctype/item_group/item_group.py b/setup/doctype/item_group/item_group.py index 01790eb77b..b2a0843af4 100644 --- a/setup/doctype/item_group/item_group.py +++ b/setup/doctype/item_group/item_group.py @@ -37,7 +37,10 @@ class DocType(DocTypeNestedSet): page_name = "products" update_page_name(self.doc, self.doc.name) - + + from website.helpers.product import invalidate_cache_for + invalidate_cache_for(self.doc.name) + def prepare_template_args(self): from website.helpers.product import get_product_list_for_group, \ get_parent_item_groups, get_group_item_count @@ -51,4 +54,4 @@ class DocType(DocTypeNestedSet): self.doc.items = get_product_list_for_group(product_group = self.doc.name, limit=20) self.parent_groups = get_parent_item_groups(self.doc.name) - \ No newline at end of file + \ No newline at end of file diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index 7f17a3b830..7db903d9a3 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -40,9 +40,8 @@ class DocType: def on_update(self): if self.doc.show_in_website: # webpage updates - from website.utils import update_page_name - update_page_name(self.doc, self.doc.item_name) - + self.update_website() + bin = sql("select stock_uom from `tabBin` where item_code = '%s' " % self.doc.item_code) if bin and cstr(bin[0][0]) != cstr(self.doc.stock_uom): msgprint("Please Update Stock UOM with the help of Stock UOM Replace Utility.") @@ -76,6 +75,16 @@ class DocType: child.conversion_factor = 1 child.save() + def update_website(self): + from website.utils import update_page_name + update_page_name(self.doc, self.doc.item_name) + + from website.helpers.product import invalidate_cache_for + invalidate_cache_for(self.doc.item_group) + + [invalidate_cache_for(d.item_group) for d in \ + self.doclist.get({"doctype":"Website Item Group"})] + # On delete 1. Delete BIN (if none of the corrosponding transactions present, it gets deleted. if present, rolled back due to exception) def on_trash(self): sql("""delete from tabBin where item_code=%s""", self.doc.item_code) diff --git a/website/css/website.css b/website/css/website.css index a633be4b1e..b392f5e79a 100644 --- a/website/css/website.css +++ b/website/css/website.css @@ -36,10 +36,6 @@ p, li { padding: 8px; } -footer { - -} - .web-footer-menu { margin-bottom: 7px; } @@ -64,11 +60,6 @@ footer { border-right: 0px solid #777 !important; } -.web-footer-powered, .web-footer-powered a { - color: #888; - margin-top: 20px; -} - .two-column { width: 50%; float: left; diff --git a/website/doctype/web_page/web_page.py b/website/doctype/web_page/web_page.py index 8a0016b326..324893dcc6 100644 --- a/website/doctype/web_page/web_page.py +++ b/website/doctype/web_page/web_page.py @@ -41,5 +41,10 @@ class DocType(): clear_cache('index') def prepare_template_args(self): - self.doc.main_section_html = self.doc.main_section - self.doc.side_section_html = self.doc.side_section \ No newline at end of file + if self.doc.slideshow: + slideshow = webnotes.model_wrapper("Website Slideshow", self.doc.slideshow) + self.slides = slideshow.doclist.get({"doctype":"Website Slideshow Item"}) + self.doc.slideshow_header = slideshow.doc.header or "" + for s in self.slides: + if s.image and not s.image.lower().startswith("http"): + s.image = "files/" + s.image diff --git a/website/doctype/web_page/web_page.txt b/website/doctype/web_page/web_page.txt index 527b24fcab..56c7344322 100644 --- a/website/doctype/web_page/web_page.txt +++ b/website/doctype/web_page/web_page.txt @@ -2,9 +2,9 @@ { "owner": "Administrator", "docstatus": 0, - "creation": "2012-11-30 18:14:18", + "creation": "2012-12-07 15:15:17", "modified_by": "Administrator", - "modified": "2012-12-06 15:59:02" + "modified": "2012-12-25 17:04:19" }, { "allow_attach": 1, @@ -26,9 +26,7 @@ "name": "__common__", "parent": "Web Page", "read": 1, - "submit": 0, "doctype": "DocPerm", - "amend": 0, "parenttype": "DocType", "role": "Website Manager", "parentfield": "permissions" @@ -37,16 +35,8 @@ "name": "Web Page", "doctype": "DocType" }, - { - "doctype": "DocField", - "label": "Title and Style", - "fieldname": "sb0", - "fieldtype": "Section Break", - "permlevel": 0 - }, { "description": "Title / headline of your page", - "colour": "White:FFF", "doctype": "DocField", "label": "Title", "fieldname": "title", @@ -54,15 +44,6 @@ "reqd": 1, "permlevel": 0 }, - { - "description": "Page url name (auto-generated) ", - "colour": "White:FFF", - "doctype": "DocField", - "label": "Page Name", - "fieldname": "page_name", - "fieldtype": "Data", - "permlevel": 1 - }, { "doctype": "DocField", "width": "50%", @@ -78,43 +59,40 @@ "permlevel": 0 }, { + "description": "Page url name (auto-generated) (add \".html\")", "doctype": "DocField", - "label": "Layout", - "options": "Single column\nTwo column", - "fieldname": "layout", - "fieldtype": "Select", - "permlevel": 0 + "label": "Page Name", + "fieldname": "page_name", + "fieldtype": "Data", + "permlevel": 1 }, { "description": "Page content", - "colour": "White:FFF", "doctype": "DocField", "label": "Content", "fieldname": "sb1", "fieldtype": "Section Break", "permlevel": 0 }, + { + "description": "Begin this page with a slideshow of images", + "doctype": "DocField", + "label": "Slideshow", + "options": "Website Slideshow", + "fieldname": "slideshow", + "fieldtype": "Link", + "permlevel": 0 + }, { "description": "Content in markdown format that appears on the main side of your page", - "colour": "White:FFF", "doctype": "DocField", "label": "Main Section", "fieldname": "main_section", "fieldtype": "Text Editor", "permlevel": 0 }, - { - "description": "Content in markdown format that appears on the right side", - "colour": "White:FFF", - "doctype": "DocField", - "label": "Side Section", - "fieldname": "side_section", - "fieldtype": "Text Editor", - "permlevel": 0 - }, { "description": "Link to other pages in the side bar and next section", - "colour": "White:FFF", "doctype": "DocField", "label": "More", "fieldname": "sb2", @@ -131,7 +109,6 @@ }, { "description": "Add code as <script>", - "colour": "White:FFF", "doctype": "DocField", "label": "Insert Code", "fieldname": "insert_code", @@ -175,14 +152,10 @@ "create": 1, "doctype": "DocPerm", "write": 1, - "cancel": 1, "permlevel": 0 }, { - "create": 0, "doctype": "DocPerm", - "write": 0, - "cancel": 0, "permlevel": 1 } ] \ No newline at end of file diff --git a/website/doctype/website_settings/website_settings.txt b/website/doctype/website_settings/website_settings.txt index b02b55e44c..4ef8addde5 100644 --- a/website/doctype/website_settings/website_settings.txt +++ b/website/doctype/website_settings/website_settings.txt @@ -4,7 +4,7 @@ "docstatus": 0, "creation": "2012-07-12 23:29:36", "modified_by": "Administrator", - "modified": "2012-12-20 14:28:46" + "modified": "2012-12-25 15:41:48" }, { "issingle": 1, @@ -104,10 +104,11 @@ "permlevel": 0 }, { + "description": "Address and other legal information you may want to put in the footer.", "doctype": "DocField", "label": "Address", "fieldname": "address", - "fieldtype": "Text", + "fieldtype": "Text Editor", "permlevel": 0 }, { diff --git a/website/doctype/website_slideshow/__init__.py b/website/doctype/website_slideshow/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/website/doctype/website_slideshow/website_slideshow.js b/website/doctype/website_slideshow/website_slideshow.js new file mode 100644 index 0000000000..bde6d26ea1 --- /dev/null +++ b/website/doctype/website_slideshow/website_slideshow.js @@ -0,0 +1,9 @@ +cur_frm.cscript.refresh = function(doc) { + cur_frm.set_intro(""); + if(doc.__islocal) { + cur_frm.set_intro("First set the name and save the record."); + } + else { + cur_frm.set_intro("Attach files / urls and add in table."); + } +} \ No newline at end of file diff --git a/website/doctype/website_slideshow/website_slideshow.py b/website/doctype/website_slideshow/website_slideshow.py new file mode 100644 index 0000000000..928aa9ff9f --- /dev/null +++ b/website/doctype/website_slideshow/website_slideshow.py @@ -0,0 +1,8 @@ +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/website/doctype/website_slideshow/website_slideshow.txt b/website/doctype/website_slideshow/website_slideshow.txt new file mode 100644 index 0000000000..0097665a8e --- /dev/null +++ b/website/doctype/website_slideshow/website_slideshow.txt @@ -0,0 +1,85 @@ +[ + { + "owner": "Administrator", + "docstatus": 0, + "creation": "2012-12-25 16:47:53", + "modified_by": "Administrator", + "modified": "2012-12-25 16:56:34" + }, + { + "autoname": "field:slideshow_name", + "allow_attach": 1, + "name": "__common__", + "doctype": "DocType", + "module": "Website", + "max_attachments": 10, + "document_type": "Transaction", + "description": "Slideshow like display for the website" + }, + { + "name": "__common__", + "parent": "Website Slideshow", + "doctype": "DocField", + "parenttype": "DocType", + "permlevel": 0, + "parentfield": "fields" + }, + { + "parent": "Website Slideshow", + "read": 1, + "cancel": 1, + "name": "__common__", + "create": 1, + "doctype": "DocPerm", + "write": 1, + "parenttype": "DocType", + "role": "Website Manager", + "permlevel": 0, + "parentfield": "permissions" + }, + { + "name": "Website Slideshow", + "doctype": "DocType" + }, + { + "read_only": 0, + "doctype": "DocField", + "label": "Slideshow Name", + "fieldname": "slideshow_name", + "fieldtype": "Data", + "reqd": 1 + }, + { + "depends_on": "eval:!doc.__islocal", + "doctype": "DocField", + "label": "Slideshow Items", + "fieldname": "sb0", + "fieldtype": "Section Break" + }, + { + "depends_on": "eval:!doc.__islocal", + "doctype": "DocField", + "label": "Slideshow Items", + "fieldname": "slideshow_items", + "fieldtype": "Table", + "options": "Website Slideshow Item" + }, + { + "description": "This goes above the slideshow.", + "depends_on": "eval:!doc.__islocal", + "doctype": "DocField", + "label": "Header", + "fieldname": "header", + "fieldtype": "Text Editor" + }, + { + "doctype": "DocField", + "label": "File List", + "fieldname": "file_list", + "fieldtype": "Text", + "hidden": 1 + }, + { + "doctype": "DocPerm" + } +] \ No newline at end of file diff --git a/website/doctype/website_slideshow_item/__init__.py b/website/doctype/website_slideshow_item/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/website/doctype/website_slideshow_item/website_slideshow_item.py b/website/doctype/website_slideshow_item/website_slideshow_item.py new file mode 100644 index 0000000000..928aa9ff9f --- /dev/null +++ b/website/doctype/website_slideshow_item/website_slideshow_item.py @@ -0,0 +1,8 @@ +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/website/doctype/website_slideshow_item/website_slideshow_item.txt b/website/doctype/website_slideshow_item/website_slideshow_item.txt new file mode 100644 index 0000000000..d74005e6c3 --- /dev/null +++ b/website/doctype/website_slideshow_item/website_slideshow_item.txt @@ -0,0 +1,59 @@ +[ + { + "owner": "Administrator", + "docstatus": 0, + "creation": "2012-12-25 16:48:49", + "modified_by": "Administrator", + "modified": "2012-12-25 16:55:40" + }, + { + "istable": 1, + "allow_attach": 0, + "doctype": "DocType", + "module": "Website", + "max_attachments": 10, + "name": "__common__" + }, + { + "name": "__common__", + "parent": "Website Slideshow Item", + "doctype": "DocField", + "parenttype": "DocType", + "permlevel": 0, + "parentfield": "fields" + }, + { + "name": "Website Slideshow Item", + "doctype": "DocType" + }, + { + "doctype": "DocField", + "label": "Image", + "fieldname": "image", + "fieldtype": "Select", + "options": "attach_files:" + }, + { + "doctype": "DocField", + "label": "Heading", + "width": "200px", + "fieldname": "heading", + "fieldtype": "Data" + }, + { + "doctype": "DocField", + "label": "Description", + "width": "200px", + "fieldname": "description", + "fieldtype": "Text" + }, + { + "print_hide": 1, + "no_copy": 1, + "doctype": "DocField", + "label": "File List", + "fieldname": "file_list", + "fieldtype": "Text", + "hidden": 1 + } +] \ No newline at end of file diff --git a/website/helpers/product.py b/website/helpers/product.py index 6fa422d72a..0497124c17 100644 --- a/website/helpers/product.py +++ b/website/helpers/product.py @@ -99,4 +99,9 @@ def get_parent_item_groups(item_group_name): return webnotes.conn.sql("""select name, page_name from `tabItem Group` where lft <= %s and rgt >= %s and ifnull(show_in_website,0)=1 - order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True) \ No newline at end of file + order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True) + +def invalidate_cache_for(item_group): + from website.utils import delete_page_cache + for i in get_parent_item_groups(item_group): + delete_page_cache(i.page_name) \ No newline at end of file diff --git a/website/page/website_home/website_home.html b/website/page/website_home/website_home.html index a8d2bb1abf..8c986cc697 100644 --- a/website/page/website_home/website_home.html +++ b/website/page/website_home/website_home.html @@ -3,17 +3,20 @@
Web Page
-

Static (content) web page

+

Static (content) web page.


Blog
-

Weblog (blog) entry

+

Weblog (blog) entr.y

+
+
Website Slideshow
+

Slideshows for adding in website pages.

Website Settings
-

Setup of top navigation bar, footer and logo

+

Setup of top navigation bar, footer and logo.


Style Settings
-

Setup of fonts and background

+

Setup of fonts and background.


Product Settings

Settings for Product Catalog on the website.

diff --git a/website/templates/html/outer.html b/website/templates/html/outer.html index fcd65f955f..aef91a9d55 100644 --- a/website/templates/html/outer.html +++ b/website/templates/html/outer.html @@ -1,5 +1,5 @@ {# - requires, brand, top_bar_items, footer_items, copyright, content + requires, brand_html, top_bar_items, footer_items, copyright, content, address #} {% extends "html/base.html" %} @@ -13,7 +13,7 @@ style="margin-bottom: 0px;">
wnframeworkThe full stack Python + Javascript web application framework on which ERPNext is built.ERPNextWeb based, Open Source ERP.
+ Get top class hosting and support at ERPNext.com
ERPNextWeb based, Open Source ERP.wnframeworkThe full stack Python + Javascript web application framework on which ERPNext is built.
Linux Operating System
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERPNextWeb based, Open Source ERP.
+ Get top class hosting and support at ERPNext.com
wnframeworkThe full stack Python + Javascript web application framework on which ERPNext is built.
Linux Operating SystemThe operating system that brought a revolution in Open Source software.
MySQL DatabaseThe world's most popular Open Source Database.
Apache HTTPD web serverThe Number One HTTP Server On The Internet.
Python Programming LanguageThe "batteries included" language that lets you write elegant code, quickly.

Python Libraries: +
    +
  • MySQLdb +
  • pytz +
  • jinja2 +
  • markdown2 +
  • dateutil +
  • termcolor +
  • python-memcached +
+
Git - Source Code ManagementGit is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

+ Kindly hosted on the web by GitHub: The service that makes it easier for individuals and teams to write better code, faster.
JQuery Javascript LibaryThe write less, do more Javascript Library.
JQuery UI - User Interface LibraryA curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.
Bootstrap CSS FrameworkSleek, intuitive, and powerful front-end framework for faster and easier web development.
Font Awesome - IconsThe iconic font designed for use with Twitter Bootstrap.
TinyMCE Rich Text EditorTinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under LGPL by Moxiecode Systems AB.
SlickGridA lightning fast JavaScript grid/spreadsheet.
Flot Charting LibraryAttractive JavaScript plotting for jQuery.
Ace Code EditorHigh Performance Code Editor for the web.
JQuery.Gantt - Gantt ChartsDraw Gantt charts with the famous jQuery ease of development.
JSColor - Color PickerHTML/Javascript Color Picker.
Downloadify - Flash Download WidgetA tiny javascript + Flash library that enables the creation and download of text files without server interaction.
+ +

Note: A link to this page must be easily accessible.

+ + +{% endblock %} \ No newline at end of file diff --git a/website/utils.py b/website/utils.py index ef73672d81..4af498159e 100644 --- a/website/utils.py +++ b/website/utils.py @@ -73,7 +73,7 @@ def get_html(page_name): html = get_html("404") if page_name=="error": - html = html % {"error": webnotes.getTraceback()} + html = html.replace("%(error)s", webnotes.getTraceback()) else: comments = "\n\npage:"+page_name+\ "\nload status: " + (from_cache and "cache" or "fresh") @@ -215,18 +215,24 @@ def get_outer_env(): products_item = filter(lambda d: d.url and d.url.split(".")[0]=="products", top_items)[0] products_item.child_items = products - return { + ret = webnotes._dict({ 'top_bar_items': top_items, 'footer_items': webnotes.conn.sql("""\ select * from `tabTop Bar Item` where parent='Website Settings' and parentfield='footer_items' order by idx asc""", as_dict=1), - 'brand': webnotes.conn.get_value('Website Settings', None, 'brand_html') or 'ERPNext', - 'copyright': webnotes.conn.get_value('Website Settings', None, 'copyright'), - 'favicon': webnotes.conn.get_value('Website Settings', None, 'favicon'), 'int':int - } + }) + + settings = webnotes.doc("Website Settings", "Website Settings") + for k in ["brand_html", "copyright", "address"]: + if k in settings.fields: + ret[k] = settings.fields[k] + + if not ret.brand_html: + ret.brand_html = "ERPNext" + return ret def get_home_page(): doc_name = webnotes.conn.get_value('Website Settings', None, 'home_page')