Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
2af5832bf3
@ -179,7 +179,7 @@ def import_vouchers(common_values, data, start_idx, import_type):
|
|||||||
|
|
||||||
def get_common_values(rows):
|
def get_common_values(rows):
|
||||||
start = False
|
start = False
|
||||||
common_values = webnotes.DictObj()
|
common_values = webnotes._dict()
|
||||||
|
|
||||||
for r in rows:
|
for r in rows:
|
||||||
if start:
|
if start:
|
||||||
@ -200,7 +200,7 @@ def get_data(rows, company_abbr):
|
|||||||
if r[0]:
|
if r[0]:
|
||||||
if start_row and i >= start_row:
|
if start_row and i >= start_row:
|
||||||
if not start_row_idx: start_row_idx = i
|
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)):
|
for cidx in xrange(len(columns)):
|
||||||
d[columns[cidx]] = r[cidx]
|
d[columns[cidx]] = r[cidx]
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class TaxController(TransactionController):
|
|||||||
{"parentfield": self.fmap.taxes_and_charges})
|
{"parentfield": self.fmap.taxes_and_charges})
|
||||||
|
|
||||||
for base_tax in master_tax_list:
|
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
|
for field in base_tax.fields
|
||||||
if field not in webnotes.model.default_fields])
|
if field not in webnotes.model.default_fields])
|
||||||
tax.update({
|
tax.update({
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
import webnotes.model
|
import webnotes.model
|
||||||
from webnotes import _, DictObj
|
from webnotes import _, _dict
|
||||||
from webnotes.utils import cint
|
from webnotes.utils import cint
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ class TransactionController(DocListController):
|
|||||||
@property
|
@property
|
||||||
def precision(self):
|
def precision(self):
|
||||||
if not hasattr(self, "_precision"):
|
if not hasattr(self, "_precision"):
|
||||||
self._precision = DictObj()
|
self._precision = _dict()
|
||||||
self._precision.main = self.meta.get_precision_map()
|
self._precision.main = self.meta.get_precision_map()
|
||||||
self._precision.item = self.meta.get_precision_map(parentfield = \
|
self._precision.item = self.meta.get_precision_map(parentfield = \
|
||||||
self.item_table_field)
|
self.item_table_field)
|
||||||
@ -69,7 +69,7 @@ class TransactionController(DocListController):
|
|||||||
if not hasattr(self, "_fmap"):
|
if not hasattr(self, "_fmap"):
|
||||||
if self.doc.doctype in ["Lead", "Quotation", "Sales Order", "Sales Invoice",
|
if self.doc.doctype in ["Lead", "Quotation", "Sales Order", "Sales Invoice",
|
||||||
"Delivery Note"]:
|
"Delivery Note"]:
|
||||||
self._fmap = webnotes.DictObj( {
|
self._fmap = webnotes._dict( {
|
||||||
"exchange_rate": "conversion_rate",
|
"exchange_rate": "conversion_rate",
|
||||||
"taxes_and_charges": "other_charges",
|
"taxes_and_charges": "other_charges",
|
||||||
"taxes_and_charges_master": "charge",
|
"taxes_and_charges_master": "charge",
|
||||||
@ -93,7 +93,7 @@ class TransactionController(DocListController):
|
|||||||
"cost_center": "cost_center_other_charges",
|
"cost_center": "cost_center_other_charges",
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
self._fmap = webnotes.DictObj({
|
self._fmap = webnotes._dict({
|
||||||
"exchange_rate": "conversion_rate",
|
"exchange_rate": "conversion_rate",
|
||||||
"taxes_and_charges": "purchase_tax_details",
|
"taxes_and_charges": "purchase_tax_details",
|
||||||
"taxes_and_charges_master": "purchase_other_charges",
|
"taxes_and_charges_master": "purchase_other_charges",
|
||||||
@ -120,4 +120,4 @@ class TransactionController(DocListController):
|
|||||||
"rate": "rate"
|
"rate": "rate"
|
||||||
})
|
})
|
||||||
|
|
||||||
return self._fmap or webnotes.DictObj()
|
return self._fmap or webnotes._dict()
|
@ -45,6 +45,5 @@ class DocType:
|
|||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
"""rebuild pages"""
|
"""rebuild pages"""
|
||||||
from webnotes.cms.make import make_web_core
|
from website.helpers.make_web_include_files import make
|
||||||
make_web_core()
|
make()
|
||||||
|
|
@ -24,8 +24,8 @@ class DocType:
|
|||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
# make js and css
|
# make js and css
|
||||||
from webnotes.cms.make import make_web_core
|
from website.helpers.make_web_include_files import make
|
||||||
make_web_core()
|
make()
|
||||||
|
|
||||||
# clear web cache (for menus!)
|
# clear web cache (for menus!)
|
||||||
from website.utils import clear_cache
|
from website.utils import clear_cache
|
||||||
|
0
website/helpers/__init__.py
Normal file
0
website/helpers/__init__.py
Normal file
@ -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
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
79
website/helpers/blog_feed.py
Normal file
79
website/helpers/blog_feed.py
Normal file
@ -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')
|
32
website/helpers/make_web_include_files.py
Normal file
32
website/helpers/make_web_include_files.py
Normal file
@ -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()
|
||||||
|
|
||||||
|
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())
|
@ -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
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
38
website/helpers/sitemap.py
Normal file
38
website/helpers/sitemap.py
Normal file
@ -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
|
@ -18,7 +18,7 @@
|
|||||||
wn.pages['{{ name }}'].onload = function(wrapper) {
|
wn.pages['{{ name }}'].onload = function(wrapper) {
|
||||||
erpnext.blog_list = new wn.ui.Listing({
|
erpnext.blog_list = new wn.ui.Listing({
|
||||||
parent: $(wrapper).find('#blog-list').get(0),
|
parent: $(wrapper).find('#blog-list').get(0),
|
||||||
method: 'website.blog.get_blog_list',
|
method: 'website.helpers.blog.get_blog_list',
|
||||||
hide_refresh: true,
|
hide_refresh: true,
|
||||||
no_toolbar: true,
|
no_toolbar: true,
|
||||||
render_row: function(parent, data) {
|
render_row: function(parent, data) {
|
||||||
|
@ -52,7 +52,7 @@ erpnext.blog.render_recent_list = function(wrapper) {
|
|||||||
wrapper.recent_list = new wn.ui.Listing({
|
wrapper.recent_list = new wn.ui.Listing({
|
||||||
parent: $(wrapper).find('.recent-posts'),
|
parent: $(wrapper).find('.recent-posts'),
|
||||||
no_toolbar: true,
|
no_toolbar: true,
|
||||||
method: 'website.blog.get_recent_blog_list',
|
method: 'website.helpers.blog.get_recent_blog_list',
|
||||||
get_args: function() {
|
get_args: function() {
|
||||||
return { name: '{{ name }}' }
|
return { name: '{{ name }}' }
|
||||||
},
|
},
|
||||||
@ -139,7 +139,7 @@ erpnext.blog.add_comment = function(wrapper) {
|
|||||||
args.page_name = '{{ page_name }}';
|
args.page_name = '{{ page_name }}';
|
||||||
|
|
||||||
wn.call({
|
wn.call({
|
||||||
method: 'website.blog.add_comment',
|
method: 'website.helpers.blog.add_comment',
|
||||||
args: args,
|
args: args,
|
||||||
btn: this,
|
btn: this,
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
|
@ -15,7 +15,7 @@ wn.provide('erpnext.blog');
|
|||||||
var args = d.get_values();
|
var args = d.get_values();
|
||||||
if(!args) return;
|
if(!args) return;
|
||||||
wn.call({
|
wn.call({
|
||||||
method: 'website.blog.add_subscriber',
|
method: 'website.helpers.blog.add_subscriber',
|
||||||
args: args,
|
args: args,
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(r.exc) {
|
if(r.exc) {
|
||||||
|
@ -6,7 +6,7 @@ erpnext.products.make_product_categories = function(wrapper) {
|
|||||||
|
|
||||||
wrapper.category_list = new wn.ui.Listing({
|
wrapper.category_list = new wn.ui.Listing({
|
||||||
parent: $(wrapper).find('.more-categories').get(0),
|
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,
|
hide_refresh: true,
|
||||||
render_row: function(parent, data) {
|
render_row: function(parent, data) {
|
||||||
parent.innerHTML = repl(
|
parent.innerHTML = repl(
|
||||||
|
@ -53,7 +53,7 @@ erpnext.products.make_similar_products = function(wrapper) {
|
|||||||
parent: $(wrapper).find('.similar-products').get(0),
|
parent: $(wrapper).find('.similar-products').get(0),
|
||||||
hide_refresh: true,
|
hide_refresh: true,
|
||||||
page_length: 5,
|
page_length: 5,
|
||||||
method: 'website.product.get_similar_product_list',
|
method: 'website.helpers.product.get_similar_product_list',
|
||||||
get_args: function() {
|
get_args: function() {
|
||||||
return {
|
return {
|
||||||
product_group: wrapper.product_group,
|
product_group: wrapper.product_group,
|
||||||
|
@ -45,7 +45,7 @@ erpnext.products.make_product_list = function(wrapper) {
|
|||||||
parent: $(wrapper).find('#products-list').get(0),
|
parent: $(wrapper).find('#products-list').get(0),
|
||||||
run_btn: $(wrapper).find('.products-search .btn').get(0),
|
run_btn: $(wrapper).find('.products-search .btn').get(0),
|
||||||
no_toolbar: true,
|
no_toolbar: true,
|
||||||
method: 'website.product.get_product_list',
|
method: 'website.helpers.product.get_product_list',
|
||||||
get_args: function() {
|
get_args: function() {
|
||||||
return {
|
return {
|
||||||
search: $('input[name="products-search"]').val() || '',
|
search: $('input[name="products-search"]').val() || '',
|
||||||
|
@ -21,10 +21,19 @@ import conf
|
|||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.utils import cstr
|
from webnotes.utils import cstr
|
||||||
|
|
||||||
template_map = {
|
page_map = {
|
||||||
'Web Page': 'html/web_page.html',
|
'Web Page': webnotes._dict({
|
||||||
'Blog': 'html/blog_page.html',
|
"template": 'html/web_page.html',
|
||||||
'Item': 'html/product_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):
|
def render(page_name):
|
||||||
@ -51,11 +60,12 @@ def get_html(page_name):
|
|||||||
# load from cache, if auto cache clear is falsy
|
# load from cache, if auto cache clear is falsy
|
||||||
if not (hasattr(conf, 'auto_cache_clear') and conf.auto_cache_clear or 0):
|
if not (hasattr(conf, 'auto_cache_clear') and conf.auto_cache_clear or 0):
|
||||||
html = webnotes.cache().get_value("page:" + page_name)
|
html = webnotes.cache().get_value("page:" + page_name)
|
||||||
comments += "\nload status: fresh"
|
|
||||||
|
|
||||||
if not html:
|
if html:
|
||||||
html = load_into_cache(page_name)
|
|
||||||
comments += "\nload status: cache"
|
comments += "\nload status: cache"
|
||||||
|
else:
|
||||||
|
html = load_into_cache(page_name)
|
||||||
|
comments += "\nload status: fresh"
|
||||||
|
|
||||||
# insert comments
|
# insert comments
|
||||||
html += """\n<!-- %s -->""" % webnotes.utils.cstr(comments)
|
html += """\n<!-- %s -->""" % webnotes.utils.cstr(comments)
|
||||||
@ -142,26 +152,24 @@ def get_template_pages():
|
|||||||
|
|
||||||
def get_doc_fields(page_name):
|
def get_doc_fields(page_name):
|
||||||
doc_type, doc_name = get_source_doc(page_name)
|
doc_type, doc_name = get_source_doc(page_name)
|
||||||
|
|
||||||
obj = webnotes.get_obj(doc_type, doc_name)
|
obj = webnotes.get_obj(doc_type, doc_name)
|
||||||
|
|
||||||
if hasattr(obj, 'prepare_template_args'):
|
if hasattr(obj, 'prepare_template_args'):
|
||||||
obj.prepare_template_args()
|
obj.prepare_template_args()
|
||||||
|
|
||||||
args = obj.doc.fields
|
args = obj.doc.fields
|
||||||
args['template'] = template_map[doc_type]
|
args['template'] = page_map[doc_type].template
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def get_source_doc(page_name):
|
def get_source_doc(page_name):
|
||||||
"""get source doc for the given page name"""
|
"""get source doc for the given page name"""
|
||||||
for doctype in [('Web Page', 'published'), ('Blog', 'published'),
|
for doctype in page_map:
|
||||||
('Item', 'show_in_website')]:
|
|
||||||
name = webnotes.conn.sql("""select name from `tab%s` where
|
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=%s and ifnull(%s, 0)=1""" % (doctype, "%s",
|
||||||
page_name)
|
page_map[doctype].condition_field), page_name)
|
||||||
if name:
|
if name:
|
||||||
return doctype[0], name[0][0]
|
return doctype, name[0][0]
|
||||||
|
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
@ -205,7 +213,7 @@ def get_home_page():
|
|||||||
|
|
||||||
return page_name
|
return page_name
|
||||||
|
|
||||||
def clear_cache(page_name):
|
def clear_cache(page_name=None):
|
||||||
if page_name:
|
if page_name:
|
||||||
delete_page_cache(page_name)
|
delete_page_cache(page_name)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user