updates to website: removed webnotes.cms
diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py
index 4afa41a..ab81801 100644
--- a/accounts/page/voucher_import_tool/voucher_import_tool.py
+++ b/accounts/page/voucher_import_tool/voucher_import_tool.py
@@ -179,7 +179,7 @@
def get_common_values(rows):
start = False
- common_values = webnotes.DictObj()
+ common_values = webnotes._dict()
for r in rows:
if start:
@@ -200,7 +200,7 @@
if r[0]:
if start_row and i >= start_row:
if not start_row_idx: start_row_idx = i
- d, acc_dict = webnotes.DictObj(), webnotes.DictObj()
+ d, acc_dict = webnotes._dict(), webnotes._dict()
for cidx in xrange(len(columns)):
d[columns[cidx]] = r[cidx]
diff --git a/controllers/tax_controller.py b/controllers/tax_controller.py
index d70ba3e..009ab31 100644
--- a/controllers/tax_controller.py
+++ b/controllers/tax_controller.py
@@ -37,7 +37,7 @@
{"parentfield": self.fmap.taxes_and_charges})
for base_tax in master_tax_list:
- tax = DictObj([[field, base_tax.fields.get(field)]
+ tax = _dict([[field, base_tax.fields.get(field)]
for field in base_tax.fields
if field not in webnotes.model.default_fields])
tax.update({
diff --git a/controllers/transaction_controller.py b/controllers/transaction_controller.py
index 07fdc67..3e4d62e 100644
--- a/controllers/transaction_controller.py
+++ b/controllers/transaction_controller.py
@@ -17,7 +17,7 @@
from __future__ import unicode_literals
import webnotes
import webnotes.model
-from webnotes import _, DictObj
+from webnotes import _, _dict
from webnotes.utils import cint
import json
@@ -32,7 +32,7 @@
@property
def precision(self):
if not hasattr(self, "_precision"):
- self._precision = DictObj()
+ self._precision = _dict()
self._precision.main = self.meta.get_precision_map()
self._precision.item = self.meta.get_precision_map(parentfield = \
self.item_table_field)
@@ -69,7 +69,7 @@
if not hasattr(self, "_fmap"):
if self.doc.doctype in ["Lead", "Quotation", "Sales Order", "Sales Invoice",
"Delivery Note"]:
- self._fmap = webnotes.DictObj( {
+ self._fmap = webnotes._dict( {
"exchange_rate": "conversion_rate",
"taxes_and_charges": "other_charges",
"taxes_and_charges_master": "charge",
@@ -93,7 +93,7 @@
"cost_center": "cost_center_other_charges",
})
else:
- self._fmap = webnotes.DictObj({
+ self._fmap = webnotes._dict({
"exchange_rate": "conversion_rate",
"taxes_and_charges": "purchase_tax_details",
"taxes_and_charges_master": "purchase_other_charges",
@@ -120,4 +120,4 @@
"rate": "rate"
})
- return self._fmap or webnotes.DictObj()
\ No newline at end of file
+ return self._fmap or webnotes._dict()
\ No newline at end of file
diff --git a/website/doctype/style_settings/style_settings.py b/website/doctype/style_settings/style_settings.py
index bf39c8d..113dbf8 100644
--- a/website/doctype/style_settings/style_settings.py
+++ b/website/doctype/style_settings/style_settings.py
@@ -45,6 +45,5 @@
def on_update(self):
"""rebuild pages"""
- from webnotes.cms.make import make_web_core
- make_web_core()
-
\ No newline at end of file
+ from website.helpers.make_web_include_files import make
+ make()
\ No newline at end of file
diff --git a/website/doctype/website_settings/website_settings.py b/website/doctype/website_settings/website_settings.py
index 577e8d5..88af634 100644
--- a/website/doctype/website_settings/website_settings.py
+++ b/website/doctype/website_settings/website_settings.py
@@ -24,8 +24,8 @@
def on_update(self):
# make js and css
- from webnotes.cms.make import make_web_core
- make_web_core()
+ from website.helpers.make_web_include_files import make
+ make()
# clear web cache (for menus!)
from website.utils import clear_cache
diff --git a/website/helpers/__init__.py b/website/helpers/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/website/helpers/__init__.py
diff --git a/website/blog.py b/website/helpers/blog.py
similarity index 96%
rename from website/blog.py
rename to website/helpers/blog.py
index f3102f2..b294f90 100644
--- a/website/blog.py
+++ b/website/helpers/blog.py
@@ -1,3 +1,6 @@
+# Copyright (c) 2012 Web Notes Technologies Pvt Ltd.
+# License: GNU General Public License (v3). For more information see license.txt
+
from __future__ import unicode_literals
import webnotes
diff --git a/website/helpers/blog_feed.py b/website/helpers/blog_feed.py
new file mode 100644
index 0000000..20c78ca
--- /dev/null
+++ b/website/helpers/blog_feed.py
@@ -0,0 +1,79 @@
+# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
+#
+# MIT License (MIT)
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+from __future__ import unicode_literals
+"""
+Generate RSS feed for blog
+"""
+
+rss = u"""<?xml version="1.0" encoding="UTF-8" ?>
+<rss version="2.0">
+<channel>
+ <title>%(title)s</title>
+ <description>%(description)s</description>
+ <link>%(link)s</link>
+ <lastBuildDate>%(modified)s</lastBuildDate>
+ <pubDate>%(modified)s</pubDate>
+ <ttl>1800</ttl>
+ %(items)s
+</channel>
+</rss>"""
+
+rss_item = u"""
+<item>
+ <title>%(title)s</title>
+ <description>%(content)s</description>
+ <link>%(link)s</link>
+ <guid>%(name)s</guid>
+ <pubDate>%(creation)s</pubDate>
+</item>"""
+
+def generate():
+ """generate rss feed"""
+ import webnotes, os
+ from webnotes.model.doc import Document
+ from website.helpers.blog import get_blog_content
+
+ host = (os.environ.get('HTTPS') and 'https://' or 'http://') + os.environ.get('HTTP_HOST')
+
+ items = ''
+ blog_list = webnotes.conn.sql("""\
+ select page_name as name, modified, creation, title from tabBlog
+ where ifnull(published,0)=1
+ order by creation desc, modified desc, name asc limit 100""", as_dict=1)
+
+ for blog in blog_list:
+ blog.link = host + '/' + blog.name + '.html'
+ blog.content = get_blog_content(blog.name)
+
+ items += rss_item % blog
+
+ modified = max((blog['modified'] for blog in blog_list))
+
+ ws = Document('Website Settings', 'Website Settings')
+ return (rss % {
+ 'title': ws.title_prefix,
+ 'description': ws.description or (ws.title_prefix + ' Blog'),
+ 'modified': modified,
+ 'items': items,
+ 'link': host + '/blog.html'
+ }).encode('utf-8', 'ignore')
diff --git a/website/helpers/make_web_include_files.py b/website/helpers/make_web_include_files.py
new file mode 100644
index 0000000..fc834e8
--- /dev/null
+++ b/website/helpers/make_web_include_files.py
@@ -0,0 +1,32 @@
+# Copyright (c) 2012 Web Notes Technologies Pvt Ltd.
+# License: GNU General Public License (v3). For more information see license.txt
+
+def make():
+ import os
+ import webnotes
+ import website.utils
+ import startup.event_handlers
+
+ if not webnotes.conn:
+ webnotes.connect()
+
+ home_page = website.utils.get_home_page('Guest')
+
+ fname = 'js/wn-web.js'
+ if os.path.basename(os.path.abspath('.'))!='public':
+ fname = os.path.join('public', fname)
+
+ if hasattr(startup.event_handlers, 'get_web_script'):
+ with open(fname, 'w') as f:
+ script = 'window.home_page = "%s";\n' % home_page
+ script += startup.event_handlers.get_web_script()
+ f.write(script)
+
+ fname = 'css/wn-web.css'
+ if os.path.basename(os.path.abspath('.'))!='public':
+ fname = os.path.join('public', fname)
+
+ # style - wn.css
+ if hasattr(startup.event_handlers, 'get_web_style'):
+ with open(fname, 'w') as f:
+ f.write(startup.event_handlers.get_web_style())
\ No newline at end of file
diff --git a/website/product.py b/website/helpers/product.py
similarity index 95%
rename from website/product.py
rename to website/helpers/product.py
index fd471cb..6bafc2b 100644
--- a/website/product.py
+++ b/website/helpers/product.py
@@ -1,3 +1,6 @@
+# Copyright (c) 2012 Web Notes Technologies Pvt Ltd.
+# License: GNU General Public License (v3). For more information see license.txt
+
from __future__ import unicode_literals
import webnotes
diff --git a/website/helpers/sitemap.py b/website/helpers/sitemap.py
new file mode 100644
index 0000000..23008af
--- /dev/null
+++ b/website/helpers/sitemap.py
@@ -0,0 +1,38 @@
+# Copyright (c) 2012 Web Notes Technologies Pvt Ltd.
+# License: GNU General Public License (v3). For more information see license.txt
+
+from __future__ import unicode_literals
+frame_xml = """<?xml version="1.0" encoding="UTF-8"?>
+<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">%s
+</urlset>"""
+
+link_xml = """\n<url><loc>%s</loc><lastmod>%s</lastmod></url>"""
+
+# generate the sitemap XML
+def generate(domain):
+ global frame_xml, link_xml
+ import urllib, os
+ import webnotes
+ import website.utils
+
+ # settings
+ max_doctypes = 10
+ max_items = 1000
+
+ site_map = ''
+ page_list = []
+
+ if domain:
+ # list of all pages in web cache
+ for doctype in website.utils.page_map:
+ d = website.utils.page_map[doctype];
+ pages = webnotes.conn.sql("""select page_name, `modified`
+ from `tab%s` where ifnull(%s,0)=1
+ order by modified desc""" % (doctype, d.condition_field))
+
+ for p in pages:
+ page_url = os.path.join(domain, urllib.quote(p[0]) + '.html')
+ modified = p[1].strftime('%Y-%m-%d')
+ site_map += link_xml % (page_url, modified)
+
+ return frame_xml % site_map
diff --git a/website/templates/js/blog.js b/website/templates/js/blog.js
index 8c9b9d7..a5ade31 100644
--- a/website/templates/js/blog.js
+++ b/website/templates/js/blog.js
@@ -18,7 +18,7 @@
wn.pages['{{ name }}'].onload = function(wrapper) {
erpnext.blog_list = new wn.ui.Listing({
parent: $(wrapper).find('#blog-list').get(0),
- method: 'website.blog.get_blog_list',
+ method: 'website.helpers.blog.get_blog_list',
hide_refresh: true,
no_toolbar: true,
render_row: function(parent, data) {
diff --git a/website/templates/js/blog_page.js b/website/templates/js/blog_page.js
index 617993c..524de8e 100644
--- a/website/templates/js/blog_page.js
+++ b/website/templates/js/blog_page.js
@@ -52,7 +52,7 @@
wrapper.recent_list = new wn.ui.Listing({
parent: $(wrapper).find('.recent-posts'),
no_toolbar: true,
- method: 'website.blog.get_recent_blog_list',
+ method: 'website.helpers.blog.get_recent_blog_list',
get_args: function() {
return { name: '{{ name }}' }
},
@@ -139,7 +139,7 @@
args.page_name = '{{ page_name }}';
wn.call({
- method: 'website.blog.add_comment',
+ method: 'website.helpers.blog.add_comment',
args: args,
btn: this,
callback: function(r) {
diff --git a/website/templates/js/blog_subscribe.js b/website/templates/js/blog_subscribe.js
index b3e10a7..cdc0130 100644
--- a/website/templates/js/blog_subscribe.js
+++ b/website/templates/js/blog_subscribe.js
@@ -15,7 +15,7 @@
var args = d.get_values();
if(!args) return;
wn.call({
- method: 'website.blog.add_subscriber',
+ method: 'website.helpers.blog.add_subscriber',
args: args,
callback: function(r) {
if(r.exc) {
diff --git a/website/templates/js/product_category.js b/website/templates/js/product_category.js
index 4229d00..2b34708 100644
--- a/website/templates/js/product_category.js
+++ b/website/templates/js/product_category.js
@@ -6,7 +6,7 @@
wrapper.category_list = new wn.ui.Listing({
parent: $(wrapper).find('.more-categories').get(0),
- method: 'website.product.get_product_category_list',
+ method: 'website.helpers.product.get_product_category_list',
hide_refresh: true,
render_row: function(parent, data) {
parent.innerHTML = repl(
diff --git a/website/templates/js/product_page.js b/website/templates/js/product_page.js
index 0c4abb4..f462033 100644
--- a/website/templates/js/product_page.js
+++ b/website/templates/js/product_page.js
@@ -53,7 +53,7 @@
parent: $(wrapper).find('.similar-products').get(0),
hide_refresh: true,
page_length: 5,
- method: 'website.product.get_similar_product_list',
+ method: 'website.helpers.product.get_similar_product_list',
get_args: function() {
return {
product_group: wrapper.product_group,
diff --git a/website/templates/js/products.js b/website/templates/js/products.js
index f4c68cb..720d192 100644
--- a/website/templates/js/products.js
+++ b/website/templates/js/products.js
@@ -45,7 +45,7 @@
parent: $(wrapper).find('#products-list').get(0),
run_btn: $(wrapper).find('.products-search .btn').get(0),
no_toolbar: true,
- method: 'website.product.get_product_list',
+ method: 'website.helpers.product.get_product_list',
get_args: function() {
return {
search: $('input[name="products-search"]').val() || '',
diff --git a/website/utils.py b/website/utils.py
index 70b05ed..a201f43 100644
--- a/website/utils.py
+++ b/website/utils.py
@@ -21,10 +21,19 @@
import webnotes
from webnotes.utils import cstr
-template_map = {
- 'Web Page': 'html/web_page.html',
- 'Blog': 'html/blog_page.html',
- 'Item': 'html/product_page.html',
+page_map = {
+ 'Web Page': webnotes._dict({
+ "template": 'html/web_page.html',
+ "condition_field": "published"
+ }),
+ 'Blog': webnotes._dict({
+ "template": 'html/blog_page.html',
+ "condition_field": "published",
+ }),
+ 'Item': webnotes._dict({
+ "template": 'html/product_page.html',
+ "condition_field": "show_in_website",
+ })
}
def render(page_name):
@@ -131,7 +140,7 @@
return args
-def get_template_pages():
+def get_template_pages():
pages_path = os.path.join(os.path.dirname(conf.__file__), 'app',
'website', 'templates', 'pages')
page_list = []
@@ -142,27 +151,25 @@
def get_doc_fields(page_name):
doc_type, doc_name = get_source_doc(page_name)
-
obj = webnotes.get_obj(doc_type, doc_name)
-
+
if hasattr(obj, 'prepare_template_args'):
obj.prepare_template_args()
-
+
args = obj.doc.fields
- args['template'] = template_map[doc_type]
+ args['template'] = page_map[doc_type].template
return args
def get_source_doc(page_name):
"""get source doc for the given page name"""
- for doctype in [('Web Page', 'published'), ('Blog', 'published'),
- ('Item', 'show_in_website')]:
+ for doctype in page_map:
name = webnotes.conn.sql("""select name from `tab%s` where
- page_name=%s and ifnull(`%s`, 0)=1""" % (doctype[0], "%s", doctype[1]),
- page_name)
+ page_name=%s and ifnull(%s, 0)=1""" % (doctype, "%s",
+ page_map[doctype].condition_field), page_name)
if name:
- return doctype[0], name[0][0]
-
+ return doctype, name[0][0]
+
return None, None
def get_outer_env():