updates to website: removed webnotes.cms
This commit is contained in:
parent
571377a313
commit
a494b88ad8
@ -179,7 +179,7 @@ def import_vouchers(common_values, data, start_idx, import_type):
|
||||
|
||||
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 @@ def get_data(rows, company_abbr):
|
||||
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]
|
||||
|
||||
|
@ -37,7 +37,7 @@ class TaxController(TransactionController):
|
||||
{"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({
|
||||
|
@ -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 @@ class TransactionController(DocListController):
|
||||
@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 @@ class TransactionController(DocListController):
|
||||
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 @@ class TransactionController(DocListController):
|
||||
"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 @@ class TransactionController(DocListController):
|
||||
"rate": "rate"
|
||||
})
|
||||
|
||||
return self._fmap or webnotes.DictObj()
|
||||
return self._fmap or webnotes._dict()
|
@ -45,6 +45,5 @@ class DocType:
|
||||
|
||||
def on_update(self):
|
||||
"""rebuild pages"""
|
||||
from webnotes.cms.make import make_web_core
|
||||
make_web_core()
|
||||
|
||||
from website.helpers.make_web_include_files import make
|
||||
make()
|
@ -24,8 +24,8 @@ class DocType:
|
||||
|
||||
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
|
||||
|
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
|
||||
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('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())
|
@ -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
|
||||
|
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) {
|
||||
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) {
|
||||
|
@ -52,7 +52,7 @@ erpnext.blog.render_recent_list = function(wrapper) {
|
||||
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 @@ erpnext.blog.add_comment = function(wrapper) {
|
||||
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) {
|
||||
|
@ -15,7 +15,7 @@ wn.provide('erpnext.blog');
|
||||
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) {
|
||||
|
@ -6,7 +6,7 @@ erpnext.products.make_product_categories = function(wrapper) {
|
||||
|
||||
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(
|
||||
|
@ -53,7 +53,7 @@ erpnext.products.make_similar_products = function(wrapper) {
|
||||
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,
|
||||
|
@ -45,7 +45,7 @@ erpnext.products.make_product_list = function(wrapper) {
|
||||
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() || '',
|
||||
|
@ -21,10 +21,19 @@ import conf
|
||||
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 @@ def prepare_args(page_name):
|
||||
|
||||
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_template_pages():
|
||||
|
||||
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():
|
||||
|
Loading…
Reference in New Issue
Block a user