Merge branch 'master' into dev
This commit is contained in:
commit
2fef0ee4e1
@ -23,7 +23,4 @@
|
||||
"public/js/complete_setup.js": [
|
||||
"erpnext/startup/js/complete_setup.js",
|
||||
],
|
||||
"public/js/product_category.js": [
|
||||
"erpnext/website/js/product_category.js",
|
||||
],
|
||||
}
|
Binary file not shown.
88
erpnext/patches/june_2012/cms2.py
Normal file
88
erpnext/patches/june_2012/cms2.py
Normal file
@ -0,0 +1,88 @@
|
||||
def execute():
|
||||
import webnotes
|
||||
import webnotes.model.sync
|
||||
|
||||
# sync doctypes required for the patch
|
||||
webnotes.model.sync.sync('website', 'web_cache')
|
||||
webnotes.model.sync.sync('website', 'web_page')
|
||||
webnotes.model.sync.sync('website', 'blog')
|
||||
webnotes.model.sync.sync('website', 'website_settings')
|
||||
webnotes.model.sync.sync('stock', 'item')
|
||||
|
||||
cleanup()
|
||||
|
||||
save_pages()
|
||||
|
||||
save_website_settings()
|
||||
|
||||
def cleanup():
|
||||
import webnotes
|
||||
|
||||
# delete pages from `tabPage` of module Website or of type Webpage
|
||||
webnotes.conn.sql("""\
|
||||
delete from `tabPage`
|
||||
where module='Website' and ifnull(web_page, 'No') = 'Yes'""")
|
||||
|
||||
# change show_in_website value in item table to 0 or 1
|
||||
webnotes.conn.sql("""\
|
||||
update `tabItem`
|
||||
set show_in_website = if(show_in_website = 'Yes', 1, 0)
|
||||
where show_in_website is not null""")
|
||||
|
||||
# move comments from comment_doctype Page to Blog
|
||||
webnotes.conn.sql("""\
|
||||
update `tabComment` comm, `tabBlog` blog
|
||||
set comm.comment_doctype = 'Blog', comm.comment_docname = blog.name
|
||||
where comm.comment_docname = blog.page_name""")
|
||||
|
||||
# delete deprecated pages
|
||||
import webnotes.model
|
||||
for page in ['products', 'contact', 'blog', 'about']:
|
||||
try:
|
||||
webnotes.model.delete_doc('Page', page)
|
||||
except Exception, e:
|
||||
webnotes.modules.patch_handler.log(unicode(e))
|
||||
|
||||
import os
|
||||
import conf
|
||||
# delete other html files
|
||||
exception_list = ['app.html', 'unsupported.html', 'blank.html']
|
||||
conf_dir = os.path.dirname(os.path.abspath(conf.__file__))
|
||||
public_path = os.path.join(conf_dir, 'public')
|
||||
for f in os.listdir(public_path):
|
||||
if f.endswith('.html') and f not in exception_list:
|
||||
os.remove(os.path.join(public_path, f))
|
||||
|
||||
def save_pages():
|
||||
"""save all web pages, blogs to create content"""
|
||||
query_map = {
|
||||
'Web Page': """select name from `tabWeb Page` where docstatus=0""",
|
||||
'Blog': """\
|
||||
select name from `tabBlog`
|
||||
where docstatus = 0 and ifnull(published, 0) = 1""",
|
||||
'Item': """\
|
||||
select name from `tabItem`
|
||||
where docstatus = 0 and ifnull(show_in_website, 0) = 1""",
|
||||
}
|
||||
|
||||
import webnotes
|
||||
from webnotes.model.doclist import DocList
|
||||
import webnotes.modules.patch_handler
|
||||
|
||||
for dt in query_map:
|
||||
for result in webnotes.conn.sql(query_map[dt], as_dict=1):
|
||||
try:
|
||||
DocList(dt, result['name'].encode('utf-8')).save()
|
||||
except Exception, e:
|
||||
webnotes.modules.patch_handler.log(unicode(e))
|
||||
|
||||
def save_website_settings():
|
||||
from webnotes.model.code import get_obj
|
||||
|
||||
# rewrite pages
|
||||
get_obj('Website Settings').on_update()
|
||||
|
||||
ss = get_obj('Style Settings')
|
||||
ss.validate()
|
||||
ss.doc.save()
|
||||
ss.on_update()
|
@ -1,12 +0,0 @@
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
from webnotes.model.code import get_obj
|
||||
|
||||
# rewrite pages
|
||||
get_obj('Website Settings').rewrite_pages()
|
||||
|
||||
ss = get_obj('Style Settings')
|
||||
ss.validate()
|
||||
ss.doc.save()
|
||||
ss.on_update()
|
@ -337,11 +337,6 @@ patch_list = [
|
||||
'patch_file': 'stock_reco_patch',
|
||||
'description': 'stock reco patch: store diff info in field'
|
||||
},
|
||||
{
|
||||
'patch_module': 'patches.may_2012',
|
||||
'patch_file': 'cms',
|
||||
'description': 'generate html pages'
|
||||
},
|
||||
{
|
||||
'patch_module': 'patches.may_2012',
|
||||
'patch_file': 'reload_reports',
|
||||
@ -487,4 +482,9 @@ patch_list = [
|
||||
'patch_file': 'deprecate_import_data_control',
|
||||
'description': "deprecate doctype - Import Data Control and page - Import Data"
|
||||
},
|
||||
{
|
||||
'patch_module': 'patches.june_2012',
|
||||
'patch_file': 'cms2',
|
||||
'description': 'cms2 release patches'
|
||||
},
|
||||
]
|
@ -3,21 +3,23 @@ wn.doclistviews['Sales Order'] = wn.views.ListView.extend({
|
||||
init: function(d) {
|
||||
this._super(d)
|
||||
this.fields = this.fields.concat([
|
||||
"`tabSales Order`.customer_name",
|
||||
"`tabSales Order`.customer_name",
|
||||
"`tabSales Order`.status",
|
||||
"`tabSales Order`.order_type",
|
||||
"ifnull(`tabSales Order`.per_delivered,0) as per_delivered",
|
||||
"ifnull(`tabSales Order`.per_billed,0) as per_billed",
|
||||
"`tabSales Order`.currency",
|
||||
"ifnull(`tabSales Order`.grand_total_export,0) as grand_total_export"
|
||||
]);
|
||||
this.stats = this.stats.concat(['status', 'company']);
|
||||
this.stats = this.stats.concat(['status', 'order_type', 'company']);
|
||||
},
|
||||
|
||||
columns: [
|
||||
{width: '3%', content: 'check'},
|
||||
{width: '5%', content:'avatar'},
|
||||
{width: '3%', content:'docstatus'},
|
||||
{width: '15%', content:'name'},
|
||||
{width: '32%', content:'customer_name+tags', css: {color:'#222'}},
|
||||
{width: '5%', content: 'avatar'},
|
||||
{width: '3%', content: 'docstatus'},
|
||||
{width: '15%', content: 'name'},
|
||||
{width: '29%', content: 'customer_name+tags', css: {color:'#222'}},
|
||||
{
|
||||
width: '18%',
|
||||
content: function(parent, data) {
|
||||
@ -25,7 +27,19 @@ wn.doclistviews['Sales Order'] = wn.views.ListView.extend({
|
||||
},
|
||||
css: {'text-align':'right'}
|
||||
},
|
||||
{width: '8%', content: 'per_delivered', type:'bar-graph', label:'Delivered'},
|
||||
{
|
||||
width: '11%',
|
||||
content: function(parent, data, me) {
|
||||
var order_type = data.order_type.toLowerCase();
|
||||
|
||||
if (order_type === 'sales') {
|
||||
me.render_icon(parent, 'icon-tag', data.order_type);
|
||||
me.render_bar_graph(parent, data, 'per_billed', 'Delivered');
|
||||
} else if (order_type === 'maintenance') {
|
||||
me.render_icon(parent, 'icon-wrench', data.order_type);
|
||||
}
|
||||
},
|
||||
},
|
||||
{width: '8%', content: 'per_billed', type:'bar-graph', label:'Billed'},
|
||||
{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
|
||||
]
|
||||
|
@ -138,7 +138,7 @@ $.extend(erpnext.complete_setup, {
|
||||
'Dominican Republic', 'East Timor', 'Ecuador', 'Egypt', 'El Salvador',
|
||||
'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', 'Federated States of Micronesia',
|
||||
'Fiji', 'Finland', 'France', 'Gabon', 'Georgia', 'Germany', 'Ghana', 'Greece',
|
||||
'Grenada', 'Guatemala', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Honduras',
|
||||
'Grenada', 'Guatemala', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Honduras', 'Hong Kong',
|
||||
'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran', 'Iraq', 'Israel', 'Italy',
|
||||
'Jamaica', 'Japan', 'Jordan', 'Kazakhstan', 'Kenya', 'Kingdom of the Netherlands',
|
||||
'Kiribati', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lebanon', 'Lesotho', 'Liberia',
|
||||
@ -147,7 +147,7 @@ $.extend(erpnext.complete_setup, {
|
||||
'Mexico', 'Moldova', 'Monaco', 'Mongolia', 'Montenegro', 'Morocco', 'Mozambique',
|
||||
'Myanmar', 'Namibia', 'Nauru', 'Nepal', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria',
|
||||
'North Korea', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Panama', 'Papua New Guinea',
|
||||
'Paraguay', "People's Republic of China", 'Peru', 'Philippines', 'Poland', 'Portugal',
|
||||
'Paraguay', "China", 'Peru', 'Philippines', 'Poland', 'Portugal',
|
||||
'Qatar', 'Republic of Ireland', 'Republic of the Congo', 'Romania', 'Russia', 'Rwanda',
|
||||
'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Vincent and the Grenadines', 'Samoa',
|
||||
'San Marino', 'Saudi Arabia', 'Senegal', 'Serbia', 'Seychelles', 'Sierra Leone',
|
||||
@ -252,6 +252,11 @@ $.extend(erpnext.complete_setup, {
|
||||
'Cape Verde': ['Atlantic/Cape_Verde'],
|
||||
'Central African Republic': ['Africa/Bangui'],
|
||||
'Chad': ['Africa/Ndjamena'],
|
||||
'China': ['Asia/Shanghai',
|
||||
'Asia/Harbin',
|
||||
'Asia/Chongqing',
|
||||
'Asia/Urumqi',
|
||||
'Asia/Kashgar'],
|
||||
'Chile': ['America/Santiago', 'Pacific/Easter'],
|
||||
'Colombia': ['America/Bogota'],
|
||||
'Comoros': ['Indian/Comoro'],
|
||||
@ -292,6 +297,7 @@ $.extend(erpnext.complete_setup, {
|
||||
'Guyana': ['America/Guyana'],
|
||||
'Haiti': ['America/Guatemala'],
|
||||
'Honduras': ['America/Tegucigalpa'],
|
||||
'Hong Kong': ['Asia/Hong_Kong'],
|
||||
'Hungary': ['Europe/Budapest'],
|
||||
'Iceland': ['Atlantic/Reykjavik'],
|
||||
'India': ['Asia/Calcutta'],
|
||||
@ -365,11 +371,6 @@ $.extend(erpnext.complete_setup, {
|
||||
'Panama': ['America/Panama'],
|
||||
'Papua New Guinea': ['Pacific/Port_Moresby'],
|
||||
'Paraguay': ['America/Asuncion'],
|
||||
"People's Republic of China": ['Asia/Shanghai',
|
||||
'Asia/Harbin',
|
||||
'Asia/Chongqing',
|
||||
'Asia/Urumqi',
|
||||
'Asia/Kashgar'],
|
||||
'Peru': ['America/Lima'],
|
||||
'Philippines': ['Asia/Manila'],
|
||||
'Poland': ['Europe/Warsaw'],
|
||||
|
@ -29,8 +29,23 @@ cur_frm.cscript.refresh = function(doc) {
|
||||
}
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'check_if_sle_exists','',callback);
|
||||
}
|
||||
|
||||
cur_frm.cscript.hide_website_fields(doc);
|
||||
}
|
||||
|
||||
cur_frm.cscript.hide_website_fields = function(doc) {
|
||||
var website_fields_list = ['page_name', 'website_image', 'web_short_description',
|
||||
'web_long_description']
|
||||
if (cint(doc.show_in_website)) {
|
||||
unhide_field(website_fields_list);
|
||||
} else {
|
||||
hide_field(website_fields_list);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.show_in_website = function(doc, dt, dn) {
|
||||
cur_frm.cscript.hide_website_fields(doc);
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['default_bom'].get_query = function(doc) {
|
||||
//var d = locals[this.doctype][this.docname];
|
||||
|
@ -46,6 +46,8 @@ class DocType:
|
||||
return ret
|
||||
|
||||
def on_update(self):
|
||||
self.update_page_name()
|
||||
|
||||
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.")
|
||||
@ -78,9 +80,13 @@ class DocType:
|
||||
child.conversion_factor = 1
|
||||
child.save()
|
||||
|
||||
self.clear_web_cache()
|
||||
|
||||
# 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))
|
||||
|
||||
self.delete_web_cache(self.doc.page_name)
|
||||
|
||||
# Check whether Ref Rate is not entered twice for same Price List and Currency
|
||||
def check_ref_rate_detail(self):
|
||||
@ -162,9 +168,9 @@ class DocType:
|
||||
if self.doc.has_serial_no == 'Yes' and self.doc.is_stock_item == 'No':
|
||||
msgprint("'Has Serial No' can not be 'Yes' for non-stock item", raise_exception=1)
|
||||
|
||||
# make product page
|
||||
self.make_page()
|
||||
|
||||
if self.doc.name:
|
||||
self.old_page_name = webnotes.conn.get_value('Item', self.doc.name, 'page_name')
|
||||
|
||||
def check_non_asset_warehouse(self):
|
||||
if self.doc.is_asset_item == "Yes":
|
||||
existing_qty = sql("select t1.warehouse, t1.actual_qty from tabBin t1, tabWarehouse t2 where t1.item_code=%s and (t2.warehouse_type!='Fixed Asset' or t2.warehouse_type is null) and t1.warehouse=t2.name and t1.actual_qty > 0", self.doc.name)
|
||||
@ -217,35 +223,38 @@ Total Available Qty: %s
|
||||
def on_rename(self,newdn,olddn):
|
||||
sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))
|
||||
|
||||
def make_page(self):
|
||||
if self.doc.show_in_website=='Yes':
|
||||
def delete_web_cache(self, page_name):
|
||||
import website.web_cache
|
||||
website.web_cache.delete_cache(page_name)
|
||||
|
||||
import website.utils
|
||||
def clear_web_cache(self):
|
||||
if hasattr(self, 'old_page_name') and self.old_page_name and \
|
||||
self.doc.page_name != self.old_page_name:
|
||||
self.delete_web_cache(self.doc.page_name)
|
||||
|
||||
if self.doc.show_in_website:
|
||||
import website.web_cache
|
||||
website.web_cache.create_cache(self.doc.page_name, self.doc.doctype, self.doc.name)
|
||||
website.web_cache.clear_cache(self.doc.page_name, self.doc.doctype, self.doc.name)
|
||||
else:
|
||||
self.delete_web_cache(self.doc.page_name)
|
||||
|
||||
def update_page_name(self):
|
||||
import website.utils
|
||||
|
||||
# if same name, do not repeat twice
|
||||
if self.doc.name == self.doc.item_name:
|
||||
page_name = self.doc.name
|
||||
else:
|
||||
page_name = self.doc.name + " " + self.doc.item_name
|
||||
|
||||
if self.doc.page_name:
|
||||
import webnotes.model
|
||||
webnotes.model.delete_doc('Page', self.doc.page_name)
|
||||
|
||||
p = website.utils.add_page("Product " + self.doc.item_name)
|
||||
self.doc.page_name = p.name
|
||||
self.doc.page_name = website.utils.page_name(page_name)
|
||||
|
||||
from jinja2 import Template
|
||||
import markdown2
|
||||
import os
|
||||
|
||||
|
||||
self.doc.long_description_html = markdown2.markdown(self.doc.description or '')
|
||||
|
||||
with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f:
|
||||
p.content = Template(f.read()).render(doc=self.doc)
|
||||
|
||||
with open(os.path.join(os.path.dirname(__file__), 'product_page.js'), 'r') as f:
|
||||
p.script = Template(f.read()).render(doc=self.doc)
|
||||
|
||||
p.save()
|
||||
|
||||
website.utils.add_guest_access_to_page(p.name)
|
||||
|
||||
del self.doc.fields['long_description_html']
|
||||
|
||||
|
||||
webnotes.conn.set_value('Item', self.doc.name, 'page_name', self.doc.page_name)
|
||||
|
||||
# no need to check for uniqueness, as name is unique
|
||||
|
||||
def prepare_template_args(self):
|
||||
import markdown2
|
||||
self.doc.web_description_html = markdown2.markdown(self.doc.description or '',
|
||||
extras=["wiki-tables"])
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-30 18:33:53',
|
||||
'creation': '2012-06-08 12:54:51',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-06-07 16:16:24',
|
||||
'modified': '2012-07-04 11:10:29',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
@ -57,73 +57,6 @@
|
||||
'name': u'Item'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Material Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Material Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Material User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Material User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Material Master Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Material Master Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
@ -134,6 +67,25 @@
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Material Master Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Material Master Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
@ -141,6 +93,54 @@
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Material Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Material Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Material User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Material User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
@ -731,26 +731,6 @@
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'show_in_website',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Show in Website',
|
||||
'options': u'No\nYes',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'website_image',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'website_image',
|
||||
'options': u'attach_files:',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
@ -794,17 +774,6 @@
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'website page link',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'page_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Page Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
@ -994,5 +963,63 @@
|
||||
'no_copy': 1,
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'website_section',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Website',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'show_in_website',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Show in Website',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'website page link',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'page_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Page Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'website_image',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Image',
|
||||
'options': u'attach_files:',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'web_short_description',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Short Description',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'web_long_description',
|
||||
'fieldtype': u'Code',
|
||||
'label': u'Long Description',
|
||||
'options': u'Markdown',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
@ -1,63 +0,0 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
wn.require('erpnext/website/js/product_category.js');
|
||||
|
||||
pscript["onload_{{ doc.page_name }}"] = function(wrapper) {
|
||||
wrapper.product_group = "{{ doc.item_group }}";
|
||||
wrapper.product_name = "{{ doc.name }}";
|
||||
erpnext.make_product_categories(wrapper);
|
||||
$(wrapper).find('.product-inquiry').click(function() {
|
||||
loadpage('contact', function() {
|
||||
$('#content-contact-us [name="contact-message"]').val("Hello,\n\n\
|
||||
Please send me more information on {{ doc.title }} (Item Code:{{ doc.item }})\n\n\
|
||||
My contact details are:\n\nThank you!\
|
||||
");
|
||||
})
|
||||
});
|
||||
|
||||
// similar products
|
||||
wrapper.similar = new wn.ui.Listing({
|
||||
parent: $(wrapper).find('.similar-products').get(0),
|
||||
hide_refresh: true,
|
||||
page_length: 5,
|
||||
get_query: function() {
|
||||
args = {
|
||||
cat: wrapper.product_group,
|
||||
name: wrapper.product_name
|
||||
};
|
||||
return repl('select t1.name, t1.title, t1.thumbnail_image, \
|
||||
t1.page_name, t1.short_description \
|
||||
from tabProduct t1, tabItem t2 \
|
||||
where t1.item = t2.name \
|
||||
and ifnull(t1.published,0)=1 \
|
||||
and t1.name != "%(name)s" \
|
||||
and t2.item_group="%(cat)s" order by t1.modified desc', args)
|
||||
},
|
||||
render_row: function(parent, data) {
|
||||
if(data.short_description.length > 100) {
|
||||
data.short_description = data.short_description.substr(0,100) + '...';
|
||||
}
|
||||
parent.innerHTML = repl('<div style="float:left; width: 60px;">\
|
||||
<img src="files/%(thumbnail_image)s" style="width:55px;"></div>\
|
||||
<div style="float:left; width: 180px">\
|
||||
<b><a href="#!%(page_name)s">%(title)s</a></b>\
|
||||
<p>%(short_description)s</p></div>\
|
||||
<div style="clear: both; margin-bottom: 15px;"></div>', data);
|
||||
}
|
||||
});
|
||||
wrapper.similar.run();
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="web-content" id="content-product-{{ doc.name }}">
|
||||
<div class="layout-main-section">
|
||||
<h1>{{ doc.item_name }}</h1>
|
||||
<div style="float: left;">
|
||||
<br><br>
|
||||
<image src="files/{{ doc.website_image }}" style="width: 300px;
|
||||
margin-left: 15px;" />
|
||||
<br><br>
|
||||
{{ doc.long_description_html }}
|
||||
<button class="btn primary product-inquiry"
|
||||
data-product="{{ doc.name }}"
|
||||
data-description="{{ doc.short_description }}">Send Inquiry</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout-side-section">
|
||||
<h4>More Categories</h4>
|
||||
<div class="more-categories"></div>
|
||||
<br>
|
||||
<h4>Similar Products</h4>
|
||||
<div class="similar-products"></div>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
</div>
|
128
erpnext/website/blog.py
Normal file
128
erpnext/website/blog.py
Normal file
@ -0,0 +1,128 @@
|
||||
import webnotes
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_blog_list(args=None):
|
||||
"""
|
||||
args = {
|
||||
'limit_start': 0,
|
||||
'limit_page_length': 10,
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
|
||||
query = """\
|
||||
select
|
||||
cache.name as name, cache.html as content,
|
||||
blog.owner as owner, blog.creation as published,
|
||||
blog.title as title
|
||||
from `tabWeb Cache` cache, `tabBlog` blog
|
||||
where cache.doc_type = 'Blog' and blog.page_name = cache.name
|
||||
order by published desc, name asc"""
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
result = webnotes.conn.sql(query, args, as_dict=1)
|
||||
|
||||
# strip html tags from content
|
||||
import webnotes.utils
|
||||
import website.web_cache
|
||||
|
||||
for res in result:
|
||||
from webnotes.utils import global_date_format, get_fullname
|
||||
res['full_name'] = get_fullname(res['owner'])
|
||||
res['published'] = global_date_format(res['published'])
|
||||
res['content'] = split_blog_content(res['content'])
|
||||
res['content'] = res['content'][:1000]
|
||||
|
||||
return result
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_recent_blog_list(args=None):
|
||||
"""
|
||||
args = {
|
||||
'limit_start': 0,
|
||||
'limit_page_length': 5,
|
||||
'name': '',
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
|
||||
query = """\
|
||||
select name, title, left(content, 100) as content
|
||||
from tabBlog
|
||||
where ifnull(published,0)=1 and
|
||||
name!=%(name)s order by creation desc"""
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
result = webnotes.conn.sql(query, args, as_dict=1)
|
||||
|
||||
# strip html tags from content
|
||||
import webnotes.utils
|
||||
for res in result:
|
||||
res['content'] = webnotes.utils.strip_html(res['content'])
|
||||
|
||||
return result
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def add_comment(args=None):
|
||||
"""
|
||||
args = {
|
||||
'comment': '',
|
||||
'comment_by': '',
|
||||
'comment_by_fullname': '',
|
||||
'comment_doctype': '',
|
||||
'comment_docname': '',
|
||||
'page_name': '',
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
|
||||
import webnotes.widgets.form.comments
|
||||
comment = webnotes.widgets.form.comments.add_comment(args)
|
||||
|
||||
# since comments are embedded in the page, clear the web cache
|
||||
import website.web_cache
|
||||
website.web_cache.clear_cache(args.get('page_name'),
|
||||
args.get('comment_doctype'), args.get('comment_docname'))
|
||||
|
||||
# loads fresh blog into cache
|
||||
get_blog_content(args.get('page_name'))
|
||||
|
||||
import webnotes.utils
|
||||
|
||||
comment['comment_date'] = webnotes.utils.pretty_date(comment['creation'])
|
||||
template_args = { 'comment_list': [comment], 'template': 'html/comment.html' }
|
||||
|
||||
# get html of comment row
|
||||
comment_html = website.web_cache.build_html(template_args)
|
||||
|
||||
return comment_html
|
||||
|
||||
def get_blog_content(blog_page_name):
|
||||
import website.web_cache
|
||||
content = website.web_cache.get_html(blog_page_name)
|
||||
|
||||
content = split_blog_content(content)
|
||||
|
||||
import webnotes.utils
|
||||
content = webnotes.utils.escape_html(content)
|
||||
|
||||
return content
|
||||
|
||||
def split_blog_content(content):
|
||||
content = content.split("<!-- begin blog content -->")
|
||||
content = len(content) > 1 and content[1] or content[0]
|
||||
|
||||
content = content.split("<!-- end blog content -->")
|
||||
content = content[0]
|
||||
|
||||
return content
|
@ -22,52 +22,40 @@ naming for same name files: file.gif, file-1.gif, file-2.gif etc
|
||||
|
||||
import webnotes
|
||||
import website.utils
|
||||
import website.web_page
|
||||
|
||||
class DocType():
|
||||
class DocType(website.web_page.Page):
|
||||
def __init__(self, d, dl):
|
||||
super(DocType, self).__init__('Blog')
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def autoname(self):
|
||||
"""save file by its name"""
|
||||
self.doc.name = website.utils.page_name(self.doc.title)
|
||||
|
||||
def validate(self):
|
||||
"""write/update 'Page' with the blog"""
|
||||
# we need the name for the templates
|
||||
if not self.doc.name:
|
||||
self.autoname()
|
||||
|
||||
if self.doc.page_name:
|
||||
webnotes.conn.sql("""delete from tabPage where name=%s""", self.doc.page_name)
|
||||
|
||||
p = website.utils.add_page(self.doc.title)
|
||||
|
||||
from jinja2 import Template
|
||||
import markdown2
|
||||
import os
|
||||
from webnotes.utils import global_date_format, get_fullname
|
||||
from webnotes.model.code import get_obj
|
||||
|
||||
self.doc.content_html = unicode(markdown2.markdown(self.doc.content or ''))
|
||||
self.doc.full_name = get_fullname(self.doc.owner)
|
||||
self.doc.updated = global_date_format(self.doc.modified)
|
||||
|
||||
with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f:
|
||||
p.content = Template(f.read()).render(doc=self.doc)
|
||||
|
||||
with open(os.path.join(os.path.dirname(__file__), 'blog_page.js'), 'r') as f:
|
||||
p.script = Template(f.read()).render(doc=self.doc)
|
||||
|
||||
p.web_page = 'Yes'
|
||||
p.save()
|
||||
get_obj(doc=p).write_cms_page()
|
||||
|
||||
website.utils.add_guest_access_to_page(p.name)
|
||||
self.doc.page_name = p.name
|
||||
|
||||
# cleanup
|
||||
for f in ['full_name', 'updated', 'content_html']:
|
||||
if f in self.doc.fields:
|
||||
del self.doc.fields[f]
|
||||
|
||||
|
||||
def on_update(self):
|
||||
super(DocType, self).on_update()
|
||||
if not webnotes.utils.cint(self.doc.published):
|
||||
self.delete_web_cache(self.doc.page_name)
|
||||
else:
|
||||
import website.blog
|
||||
website.blog.get_blog_content(self.doc.page_name)
|
||||
|
||||
def prepare_template_args(self):
|
||||
import webnotes.utils
|
||||
|
||||
# this is for double precaution. usually it wont reach this code if not published
|
||||
if not webnotes.utils.cint(self.doc.published):
|
||||
raise Exception, "This blog has not been published yet!"
|
||||
|
||||
# temp fields
|
||||
from webnotes.utils import global_date_format, get_fullname
|
||||
self.doc.full_name = get_fullname(self.doc.owner)
|
||||
self.doc.updated = global_date_format(self.doc.creation)
|
||||
|
||||
self.markdown_to_html(['content'])
|
||||
|
||||
comment_list = webnotes.conn.sql("""\
|
||||
select comment, comment_by_fullname, creation
|
||||
from `tabComment` where comment_doctype="Blog"
|
||||
and comment_docname=%s order by creation""", self.doc.name, as_dict=1)
|
||||
|
||||
self.doc.comment_list = comment_list or []
|
||||
for comment in self.doc.comment_list:
|
||||
comment['comment_date'] = webnotes.utils.pretty_date(comment['creation'])
|
@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-02 16:02:43',
|
||||
'creation': '2012-05-28 19:22:38',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-04-26 16:58:27',
|
||||
'modified': '2012-06-22 18:56:16',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
@ -21,7 +21,7 @@
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
@ -51,6 +51,7 @@
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
@ -71,7 +72,14 @@
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'All'
|
||||
'role': u'Website Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Blogger'
|
||||
},
|
||||
|
||||
# DocField
|
||||
@ -99,26 +107,19 @@
|
||||
'fieldname': u'content',
|
||||
'fieldtype': u'Code',
|
||||
'label': u'Content',
|
||||
'options': u'Markdown',
|
||||
'permlevel': 0,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'content_html',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Content HTML',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'page_name',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 1,
|
||||
'label': u'Page Name',
|
||||
'permlevel': 0
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
|
@ -1,83 +0,0 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// js inside blog page
|
||||
|
||||
pscript['onload_{{ doc.name }}'] = function(wrapper) {
|
||||
// sidebar
|
||||
wrapper.recent_list = new wn.ui.Listing({
|
||||
parent: $(wrapper).find('.recent-posts'),
|
||||
no_toolbar: true,
|
||||
query: 'select name, title, left(content, 100) as content from tabBlog\
|
||||
where ifnull(published,0)=1 and name!="{{ doc.name }}" order by creation desc',
|
||||
hide_refresh: true,
|
||||
render_row: function(parent, data) {
|
||||
//console.log(data);
|
||||
if(data.content && data.content.length==100) data.content += '...';
|
||||
parent.innerHTML = repl('<a href="%(name)s.html">%(title)s</a>\
|
||||
<div class="comment">%(content)s</div><br>', data);
|
||||
},
|
||||
page_length: 5,
|
||||
});
|
||||
wrapper.recent_list.run();
|
||||
|
||||
wrapper.comment_list = new wn.ui.Listing({
|
||||
parent: $(wrapper).find('.blog-comments').get(0),
|
||||
no_toolbar: true,
|
||||
query: 'select comment, comment_by_fullname, creation\
|
||||
from `tabComment` where comment_doctype="Page"\
|
||||
and comment_docname="{{ doc.name }}" order by creation desc',
|
||||
no_result_message: 'Be the first one to comment',
|
||||
render_row: function(parent, data) {
|
||||
data.comment_date = prettyDate(data.creation);
|
||||
$(parent).html(repl("<div style='color:#777'>\
|
||||
%(comment_by_fullname)s | %(comment_date)s:\
|
||||
</div>\
|
||||
<p style='margin-left: 20px;'>%(comment)s</p><br>", data))
|
||||
},
|
||||
hide_refresh: true
|
||||
});
|
||||
wrapper.comment_list.run();
|
||||
|
||||
// add comment
|
||||
$(wrapper).find('.layout-main-section').append('<br><button class="btn add-comment">\
|
||||
Add Comment</button>');
|
||||
$(wrapper).find('button.add-comment').click(function(){
|
||||
d = new wn.widgets.Dialog({
|
||||
title: 'Add Comment',
|
||||
fields: [
|
||||
{fieldname:'comment_by_fullname', label:'Your Name', reqd:1, fieldtype:'Data'},
|
||||
{fieldname:'comment_by', label:'Email Id', reqd:1, fieldtype:'Data'},
|
||||
{fieldname:'comment', label:'Comment', reqd:1, fieldtype:'Text'},
|
||||
{fieldname:'post', label:'Post', fieldtype:'Button'}
|
||||
]
|
||||
});
|
||||
d.fields_dict.post.input.onclick = function() {
|
||||
var btn = this;
|
||||
var args = d.get_values();
|
||||
if(!args) return;
|
||||
args.comment_doctype = 'Page';
|
||||
args.comment_docname = '{{ doc.name }}';
|
||||
$(btn).set_working();
|
||||
$c('webnotes.widgets.form.comments.add_comment', args, function(r) {
|
||||
$(btn).done_working();
|
||||
d.hide();
|
||||
wrapper.comment_list.refresh();
|
||||
})
|
||||
}
|
||||
d.show();
|
||||
})
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="web-content" id="blog-{{ doc.name }}">
|
||||
<div class="layout-main-section">
|
||||
<h2>{{ doc.title }}</h2>
|
||||
<div class="help">By {{ doc.full_name }} on {{ doc.updated }}</div>
|
||||
<br>
|
||||
{{ doc.content_html }}
|
||||
<hr><h3>Comments</h3>
|
||||
<br>
|
||||
<div class="blog-comments"></div>
|
||||
</div>
|
||||
<div class="layout-side-section">
|
||||
<p><a href="blog.html">All Blogs</a></p>
|
||||
<h4>Recent Posts</h4>
|
||||
<div class="recent-posts" style="min-height: 100px;"></div>
|
||||
<h4>Subscribe</h4>
|
||||
<p>
|
||||
<img src="images/feed.png" style="margin-right: 4px; margin-bottom: -4px">
|
||||
<a href="rss.xml" target="_blank">RSS Feed</a>
|
||||
</p>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
</div>
|
99
erpnext/website/doctype/web_cache/web_cache.txt
Normal file
99
erpnext/website/doctype/web_cache/web_cache.txt
Normal file
@ -0,0 +1,99 @@
|
||||
# DocType, Web Cache
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-06-21 12:01:17',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-06-21 17:25:52',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'System',
|
||||
'module': u'Website',
|
||||
'name': '__common__',
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Web Cache',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Web Cache',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Web Cache
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Web Cache'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'All'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Website Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Blogger'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'doc_type',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'DocType',
|
||||
'options': u'DocType',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'doc_name',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 0,
|
||||
'label': u'DocName',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'html',
|
||||
'fieldtype': u'Long Text',
|
||||
'label': u'HTML'
|
||||
}
|
||||
]
|
@ -1,30 +0,0 @@
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="web-content"
|
||||
style="text-align: {{ doc.text_align }};">
|
||||
|
||||
{% if doc.layout and doc.layout.startswith('Two column') %}
|
||||
<div class="layout-main-section">
|
||||
{% else %}
|
||||
<div class="layout-main">
|
||||
{% endif %}
|
||||
{{ doc.main_section_html }}
|
||||
{% if doc.next_page_html %}
|
||||
{{ doc.next_page_html }}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
{% if doc.layout and doc.layout.startswith('Two column') %}
|
||||
<div class="layout-side-section">
|
||||
{{ doc.side_section_html }}
|
||||
{% if doc.see_also %}
|
||||
<div class="info-box">
|
||||
<h4>See Also</h4>
|
||||
{{ doc.see_also }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
</div>
|
@ -16,82 +16,25 @@
|
||||
|
||||
import webnotes
|
||||
import website.utils
|
||||
import website.web_page
|
||||
|
||||
class DocType:
|
||||
class DocType(website.web_page.Page):
|
||||
def __init__(self, d, dl):
|
||||
super(DocType, self).__init__('Web Page')
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def autoname(self):
|
||||
"""name from title"""
|
||||
self.doc.name = website.utils.page_name(self.doc.title)
|
||||
|
||||
def on_update(self):
|
||||
"""make page for this product"""
|
||||
from jinja2 import Template
|
||||
from webnotes.utils import global_date_format
|
||||
from webnotes.model.code import get_obj
|
||||
import os
|
||||
|
||||
# we need the name for the templates
|
||||
if self.doc.name.startswith('New Web Page'):
|
||||
self.autoname()
|
||||
|
||||
if self.doc.page_name:
|
||||
webnotes.conn.sql("""delete from tabPage where name=%s""", self.doc.page_name)
|
||||
|
||||
p = website.utils.add_page(self.doc.name)
|
||||
self.doc.page_name = p.name
|
||||
|
||||
self.doc.updated = global_date_format(self.doc.modified)
|
||||
website.utils.markdown(self.doc, ['head_section','main_section', 'side_section'])
|
||||
|
||||
with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f:
|
||||
p.content = Template(f.read()).render(doc=self.doc)
|
||||
|
||||
p.title = self.doc.title
|
||||
p.web_page = 'Yes'
|
||||
|
||||
if self.doc.insert_code:
|
||||
p.script = self.doc.javascript
|
||||
|
||||
if self.doc.insert_style:
|
||||
p.style = self.doc.css
|
||||
|
||||
p.save()
|
||||
get_obj(doc=p).write_cms_page()
|
||||
|
||||
website.utils.add_guest_access_to_page(p.name)
|
||||
self.cleanup_temp()
|
||||
|
||||
self.doc.save()
|
||||
|
||||
super(DocType, self).on_update()
|
||||
self.if_home_clear_cache()
|
||||
|
||||
def add_page_links(self):
|
||||
"""add links for next_page and see_also"""
|
||||
if self.doc.next_page:
|
||||
self.doc.next_page_html = """<div class="info-box round" style="text-align: right">
|
||||
<b>Next:</b>
|
||||
<a href="#!%(name)s">%(title)s</a></div>""" % {"name":self.doc.next_page, \
|
||||
"title": webnotes.conn.get_value("Page", self.doc.next_page, "title")}
|
||||
|
||||
self.doc.see_also = ''
|
||||
for d in self.doclist:
|
||||
if d.doctype=='Related Page':
|
||||
tmp = {"page":d.page, "title":webnotes.conn.get_value('Page', d.page, 'title')}
|
||||
self.doc.see_also += """<div><a href="#!%(page)s">%(title)s</a></div>""" % tmp
|
||||
|
||||
def cleanup_temp(self):
|
||||
"""cleanup temp fields"""
|
||||
fl = ['main_section_html', 'side_section_html', 'see_also', \
|
||||
'next_page_html', 'head_section_html', 'updated']
|
||||
for f in fl:
|
||||
if f in self.doc.fields:
|
||||
del self.doc.fields[f]
|
||||
|
||||
def if_home_clear_cache(self):
|
||||
"""if home page, clear cache"""
|
||||
if webnotes.conn.get_value("Website Settings", None, "home_page")==self.doc.name:
|
||||
from webnotes.session_cache import clear_cache
|
||||
clear_cache('Guest')
|
||||
|
||||
clear_cache('Guest')
|
||||
import website.web_cache
|
||||
website.web_cache.clear_cache(self.doc.page_name)
|
||||
website.web_cache.clear_cache('index')
|
||||
|
||||
def prepare_template_args(self):
|
||||
self.markdown_to_html(['head_section','main_section', 'side_section'])
|
@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-02 16:02:43',
|
||||
'creation': '2012-06-19 15:02:20',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-05-02 15:24:31',
|
||||
'modified': '2012-06-22 18:49:02',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
@ -36,13 +36,15 @@
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Web Page',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1,
|
||||
'role': u'Website Manager'
|
||||
'role': u'Website Manager',
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocType, Web Page
|
||||
@ -53,6 +55,7 @@
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
@ -61,8 +64,11 @@
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1
|
||||
'permlevel': 1,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
@ -86,6 +92,17 @@
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Page url name (auto-generated) ',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'page_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Page Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
@ -101,7 +118,7 @@
|
||||
'fieldname': u'layout',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Layout',
|
||||
'options': u'Two column with header\nTwo column\nSingle column',
|
||||
'options': u'Single column\nTwo column\nTwo column with header',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
@ -176,6 +193,7 @@
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Add code as <script>',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'insert_code',
|
||||
'fieldtype': u'Check',
|
||||
@ -212,15 +230,6 @@
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'page_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Page Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
|
@ -28,38 +28,17 @@ class DocType:
|
||||
self.validate_domain_list()
|
||||
|
||||
def on_update(self):
|
||||
self.rewrite_pages()
|
||||
|
||||
from webnotes.session_cache import clear_cache
|
||||
clear_cache('Guest')
|
||||
|
||||
def rewrite_pages(self):
|
||||
"""rewrite all web pages"""
|
||||
import webnotes
|
||||
from webnotes.model.doclist import DocList
|
||||
from webnotes.model.code import get_obj
|
||||
|
||||
# rewrite all web pages
|
||||
for name in webnotes.conn.sql("""select name, modified from `tabWeb Page`
|
||||
where docstatus=0"""):
|
||||
DocList('Web Page', name[0]).save()
|
||||
webnotes.conn.set_value('Web Page', name[0], 'modified', name[1])
|
||||
|
||||
# rewrite all blog pages
|
||||
for name in webnotes.conn.sql("""select name, modified from `tabBlog`
|
||||
where docstatus=0 and ifnull(published,0)=1"""):
|
||||
DocList('Blog', name[0]).save()
|
||||
webnotes.conn.set_value('Blog', name[0], 'modified', name[1])
|
||||
|
||||
# make js and css
|
||||
from webnotes.cms.make import make_web_core
|
||||
make_web_core()
|
||||
|
||||
get_obj('Page', 'blog').write_cms_page(force=True)
|
||||
get_obj('Page', 'Login Page').write_cms_page(force=True)
|
||||
|
||||
webnotes.msgprint('Rebuilt all blogs and pages')
|
||||
|
||||
|
||||
# clear web cache
|
||||
import website.web_cache
|
||||
website.web_cache.refresh_cache(build=['Blog'])
|
||||
|
||||
from webnotes.session_cache import clear_cache
|
||||
clear_cache('Guest')
|
||||
|
||||
def set_home_page(self):
|
||||
|
||||
import webnotes
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-05-03 18:43:46',
|
||||
'creation': '2012-05-21 15:54:09',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-05-21 14:59:25',
|
||||
'modified': '2012-07-09 16:20:58',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
@ -18,7 +18,7 @@
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Other',
|
||||
'issingle': 1,
|
||||
'max_attachments': 1,
|
||||
'max_attachments': 10,
|
||||
'module': u'Website',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
@ -180,21 +180,21 @@
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'file_list',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'File List',
|
||||
'no_copy': 1,
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
'fieldname': u'misc_section',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Misc',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'An icon file with .ico extension. Should be 16 x 16 px. Generated using a favicon generator. [<a href="http://favicon-generator.org/" target="_blank">favicon-generator.org</a>]',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'domains',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Domains',
|
||||
'fieldname': u'favicon',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'FavIcon',
|
||||
'options': u'attach_files:',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
@ -221,6 +221,18 @@
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'file_list',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'File List',
|
||||
'no_copy': 1,
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
|
@ -1,130 +0,0 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
wn.provide('erpnext.navbar');
|
||||
|
||||
/*
|
||||
<li class="dropdown">\
|
||||
<a class="dropdown-toggle" href="#" onclick="return false;"></a>\
|
||||
<ul class="dropdown-menu" id="toolbar-user">\
|
||||
</ul>\
|
||||
</li>\
|
||||
*/
|
||||
|
||||
erpnext.navbar.Navbar = Class.extend({
|
||||
init: function() {
|
||||
this.make();
|
||||
$('.brand').html(wn.boot.website_settings.brand_html || sys_defaults.company);
|
||||
this.make_items();
|
||||
$('.dropdown-toggle').dropdown();
|
||||
},
|
||||
make: function() {
|
||||
$('header').append('<div class="navbar navbar-fixed-top">\
|
||||
<div class="navbar-inner">\
|
||||
<div class="container">\
|
||||
<a class="brand">[brand]</a>\
|
||||
<ul class="nav">\
|
||||
</ul>\
|
||||
<img src="images/lib/ui/spinner.gif" id="spinner"/>\
|
||||
<ul class="nav pull-right">\
|
||||
<li id="login-topbar-item"><a href="#!Login Page">Login</a></li>\
|
||||
</ul>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>');
|
||||
$('.brand').attr('href', '#!' + (wn.boot.website_settings.home_page || 'Login Page'))
|
||||
},
|
||||
make_items: function() {
|
||||
var items = wn.boot.website_menus;
|
||||
|
||||
// parent labels
|
||||
for(var i=0;i<items.length;i++) {
|
||||
var item = items[i];
|
||||
if(!item.parent_label && item.parentfield=='top_bar_items') {
|
||||
erpnext.header_link_settings(item);
|
||||
$('header .nav:first').append(repl('<li data-label="%(label)s">\
|
||||
<a href="%(route)s" %(target)s>%(label)s</a></li>', item));
|
||||
}
|
||||
}
|
||||
|
||||
// child labels
|
||||
for(var i=0;i<items.length;i++) {
|
||||
var item = items[i];
|
||||
if(item.parent_label && item.parentfield=='top_bar_items') {
|
||||
// check if parent label has class "dropdown"
|
||||
$parent_li = $(repl('header li[data-label="%(parent_label)s"]', item));
|
||||
if(!$parent_li.hasClass('dropdown')) {
|
||||
$parent_li.addClass('dropdown');
|
||||
$parent_li.find('a:first').addClass('dropdown-toggle')
|
||||
.attr('data-toggle', 'dropdown')
|
||||
.attr('href', '')
|
||||
.append('<b class="caret"></b>')
|
||||
.click(function() {
|
||||
return false;
|
||||
});
|
||||
$parent_li.append('');
|
||||
}
|
||||
erpnext.header_link_settings(item);
|
||||
$parent_li.find('.dropdown-menu').append(repl('<li data-label="%(label)s">\
|
||||
<a href="%(route)s" %(target)s>%(label)s</a></li>', item))
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// footer
|
||||
erpnext.Footer = Class.extend({
|
||||
init: function() {
|
||||
if(!wn.boot.website_settings.copyright) {
|
||||
wn.boot.website_settings.copyright = sys_defaults.company;
|
||||
}
|
||||
if(!wn.boot.website_settings.address) {
|
||||
wn.boot.website_settings.address = '';
|
||||
}
|
||||
$('footer').html(repl('<div class="web-footer">\
|
||||
<div class="web-footer-menu"><ul></ul></div>\
|
||||
<div class="web-footer-copyright">© %(copyright)s</div>\
|
||||
</div>', wn.boot.website_settings));
|
||||
this.make_items();
|
||||
},
|
||||
make_items: function() {
|
||||
var items = wn.boot.website_menus
|
||||
for(var i=0;i<items.length;i++) {
|
||||
var item = items[i];
|
||||
if(!item.parent_label && item.parentfield=='footer_items') {
|
||||
erpnext.header_link_settings(item);
|
||||
$('.web-footer-menu ul').append(repl('<li><a href="%(route)s" %(target)s\
|
||||
data-label="%(label)s">%(label)s</a></li>', item))
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// customize hard / soft links
|
||||
erpnext.header_link_settings = function(item) {
|
||||
item.route = item.url || item.custom_page;
|
||||
if(item.route && item.route.substr(0,4)=='http') {
|
||||
item.target = 'target="_blank"';
|
||||
} else {
|
||||
item.target = '';
|
||||
item.route = '#!' + item.route;
|
||||
}
|
||||
}
|
||||
|
||||
$(document).bind('startup', function() {
|
||||
erpnext.footer = new erpnext.Footer();
|
||||
//erpnext.navbar.navbar = new erpnext.navbar.Navbar();
|
||||
})
|
@ -1,43 +0,0 @@
|
||||
# Page, about
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-01-27 11:37:57',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-01-27 13:26:42',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': 'Website',
|
||||
'name': '__common__',
|
||||
'page_name': 'about',
|
||||
'standard': 'Yes',
|
||||
'title': 'About Us'
|
||||
},
|
||||
|
||||
# These values are common for all Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'name': '__common__',
|
||||
'parent': 'about',
|
||||
'parentfield': 'roles',
|
||||
'parenttype': 'Page',
|
||||
'role': 'Guest'
|
||||
},
|
||||
|
||||
# Page, about
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'about'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role'
|
||||
}
|
||||
]
|
@ -1,23 +0,0 @@
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="web-content" id="content-blog">
|
||||
<div class="layout-main-section">
|
||||
<h1>Blog</h1>
|
||||
<br>
|
||||
<div id="blog-list"></div>
|
||||
</div>
|
||||
<div class="layout-side-section">
|
||||
<!-- for later
|
||||
<h4>Get Updates</h4>
|
||||
<p>
|
||||
<input name="blog-subscribe">
|
||||
<button class="btn" id="blog-subscribe">Subscribe</button>
|
||||
</p>-->
|
||||
<h4>Subscribe</h4>
|
||||
<p>
|
||||
<img src="images/feed.png" style="margin-right: 4px; margin-bottom: -4px">
|
||||
<a href="rss.xml" target="_blank">RSS Feed</a>
|
||||
</p>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
</div>
|
@ -1,59 +0,0 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
pscript.onload_blog = function(wrapper) {
|
||||
wrapper.blog_list = new wn.ui.Listing({
|
||||
parent: $(wrapper).find('#blog-list').get(0),
|
||||
query: 'select tabBlog.name, title, left(content, 1000) as content, tabBlog.creation, \
|
||||
ifnull(first_name, "") as first_name, ifnull(last_name, "") as last_name \
|
||||
from tabProfile, tabBlog\
|
||||
where ifnull(published,0)=1 and tabBlog.owner = tabProfile.name \
|
||||
order by tabBlog.creation desc',
|
||||
hide_refresh: true,
|
||||
no_toolbar: true,
|
||||
render_row: function(parent, data) {
|
||||
if(data.content && data.content.length==1000) data.content += '... (read on)';
|
||||
data.content = wn.markdown(data.content);
|
||||
if(data.last_name) data.last_name = ' ' + data.last_name;
|
||||
data.date = prettyDate(data.creation);
|
||||
parent.innerHTML = repl('<h2>%(title)s</h2>\
|
||||
<p><div class="help">By %(first_name)s%(last_name)s, %(date)s</div></p>\
|
||||
<p>%(content)s</p>\
|
||||
<a href="%(name)s.html">Read Full Text</a><br>', data);
|
||||
},
|
||||
page_length: 10
|
||||
});
|
||||
wrapper.blog_list.run();
|
||||
|
||||
// subscribe button
|
||||
$('#blog-subscribe').click(function() {
|
||||
var email = $(wrapper).find('input[name="blog-subscribe"]').val();
|
||||
if(!validate_email(email)) {
|
||||
msgprint('Please enter a valid email!');
|
||||
}
|
||||
wn.call({
|
||||
module:'website',
|
||||
page:'blog',
|
||||
method:'subscribe',
|
||||
args:email,
|
||||
btn: this,
|
||||
callback: function() {
|
||||
$(wrapper).find('input[name="blog-subscribe"]').val('');
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import webnotes
|
||||
|
||||
@webnotes.whitelist()
|
||||
def subscribe(arg):
|
||||
"""subscribe to blog (blog_subscriber)"""
|
||||
if webnotes.conn.sql("""select name from `tabBlog Subscriber` where name=%s""", arg):
|
||||
webnotes.msgprint("Already a subscriber. Thanks!")
|
||||
else:
|
||||
from webnotes.model.doc import Document
|
||||
d = Document('Blog Subscriber')
|
||||
d.name = arg
|
||||
d.save()
|
||||
webnotes.msgprint("Thank you for subscribing!")
|
@ -1,44 +0,0 @@
|
||||
# Page, blog
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-01-27 15:47:52',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-01-27 15:47:52',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': 'Website',
|
||||
'name': '__common__',
|
||||
'page_name': 'blog',
|
||||
'standard': 'Yes',
|
||||
'title': 'Blog'
|
||||
},
|
||||
|
||||
# These values are common for all Page Role
|
||||
{
|
||||
'__islocal': 1,
|
||||
'doctype': 'Page Role',
|
||||
'name': '__common__',
|
||||
'parent': 'blog',
|
||||
'parentfield': 'roles',
|
||||
'parenttype': 'Page',
|
||||
'role': 'Guest'
|
||||
},
|
||||
|
||||
# Page, blog
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'blog'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role'
|
||||
}
|
||||
]
|
@ -1,46 +0,0 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pscript.onload_contact = function(wrapper) {
|
||||
$('#content-contact-us .btn.primary').click(function() {
|
||||
var me = this;
|
||||
var args = {};
|
||||
args.name = $('#content-contact-us [name="contact-name"]').val();
|
||||
args.email = $('#content-contact-us [name="contact-email"]').val();
|
||||
args.message = $('#content-contact-us [name="contact-message"]').val();
|
||||
|
||||
if(!validate_email(args.email)) {
|
||||
msgprint('Please enter a valid email id');
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.name && args.email && args.message) {
|
||||
$(this).set_working();
|
||||
$c_page('website', 'contact', 'send', args, function(r) {
|
||||
$('#content-contact-us [name*="contact"]').val('');
|
||||
$(me).done_working();
|
||||
});
|
||||
} else {
|
||||
msgprint("Please enter info in all the fields.")
|
||||
}
|
||||
});
|
||||
|
||||
$('#content-contact-us :input').keyup(function(ev) {
|
||||
if(ev.which == 13) {
|
||||
$('#content-contact-us .btn.primary').click();
|
||||
}
|
||||
});
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import json, webnotes
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def send(args):
|
||||
"""create support ticket"""
|
||||
args = json.loads(args)
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
d = Document('Support Ticket')
|
||||
d.raised_by = args['email']
|
||||
d.description = 'From: ' + args['name'] + '\n\n' + args['message']
|
||||
d.subject = 'Website Query'
|
||||
d.status = 'Open'
|
||||
d.owner = 'Guest'
|
||||
d.save(1)
|
||||
webnotes.msgprint("Thank you for your query. We will respond as soon as we can.")
|
@ -1,42 +0,0 @@
|
||||
# Page, contact
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-01-25 16:02:15',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-01-25 16:02:15',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': 'Website',
|
||||
'name': '__common__',
|
||||
'page_name': 'contact',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# These values are common for all Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'name': '__common__',
|
||||
'parent': 'contact',
|
||||
'parentfield': 'roles',
|
||||
'parenttype': 'Page',
|
||||
'role': 'Guest'
|
||||
},
|
||||
|
||||
# Page, contact
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'contact'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role'
|
||||
}
|
||||
]
|
@ -1,27 +0,0 @@
|
||||
## Products
|
||||
|
||||
Contains
|
||||
|
||||
- List of Products tagged by Item master
|
||||
- image
|
||||
- short description (md)
|
||||
- pricing info (if public) (public pricelist)
|
||||
- stock info (website warehouse)
|
||||
- Search
|
||||
- Sidebar contains categories (# of items in each category)
|
||||
|
||||
When Item is Saved, a page for that item is created with
|
||||
|
||||
- Large image
|
||||
- Smaller images
|
||||
- Long Description
|
||||
- Pricing info
|
||||
- Stock info
|
||||
- Contact Button (instead of Buy / Add to cart)
|
||||
|
||||
### Steps
|
||||
|
||||
- update item master
|
||||
- update item category (show in web + priority) (or in a products settings page)
|
||||
- # of public items in each category
|
||||
- validation - item cannot have show in item if parent does not have it
|
@ -1,14 +0,0 @@
|
||||
<div class="layout-wrapper layout-wrapper-background" id="content-products">
|
||||
<div class="layout-main-section">
|
||||
<h1 class="products-category"></h1>
|
||||
<div class="products-search" style="margin-bottom: 15px;">
|
||||
<input name="products-search" /><button class="btn" style="margin-left: 7px">Search</button>
|
||||
</div>
|
||||
<div class="products-list"></div>
|
||||
</div>
|
||||
<div class="layout-side-section">
|
||||
<h3>Categories</h3>
|
||||
<div class="more-categories"></div>
|
||||
</div>
|
||||
<div style="clear:both;">
|
||||
</div>
|
@ -1,43 +0,0 @@
|
||||
# Page, products
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-01-30 10:49:01',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-01-30 10:49:01',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': 'Website',
|
||||
'name': '__common__',
|
||||
'page_name': 'products',
|
||||
'standard': 'Yes',
|
||||
'title': 'Products'
|
||||
},
|
||||
|
||||
# These values are common for all Page Role
|
||||
{
|
||||
'doctype': 'Page Role',
|
||||
'name': '__common__',
|
||||
'parent': 'products',
|
||||
'parentfield': 'roles',
|
||||
'parenttype': 'Page',
|
||||
'role': 'Guest'
|
||||
},
|
||||
|
||||
# Page, products
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'products'
|
||||
},
|
||||
|
||||
# Page Role
|
||||
{
|
||||
'doctype': 'Page Role'
|
||||
}
|
||||
]
|
116
erpnext/website/product.py
Normal file
116
erpnext/website/product.py
Normal file
@ -0,0 +1,116 @@
|
||||
import webnotes
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_product_list(args=None):
|
||||
"""
|
||||
args = {
|
||||
'limit_start': 0,
|
||||
'limit_page_length': 20,
|
||||
'search': '',
|
||||
'product_group': '',
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
from webnotes.utils import cstr, cint
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
|
||||
# base query
|
||||
query = """\
|
||||
select name, item_name, page_name, website_image,
|
||||
description, web_short_description
|
||||
from `tabItem`
|
||||
where is_sales_item = 'Yes'
|
||||
and docstatus = 0
|
||||
and show_in_website = 1"""
|
||||
|
||||
# search term condition
|
||||
if args.get('search'):
|
||||
query += """
|
||||
and (
|
||||
web_short_description like %(search)s or
|
||||
web_long_description like %(search)s or
|
||||
description like %(search)s or
|
||||
item_name like %(search)s or
|
||||
name like %(search)s
|
||||
)"""
|
||||
args['search'] = "%" + cstr(args.get('search')) + "%"
|
||||
|
||||
# product group condition
|
||||
if args.get('product_group') and args.get('product_group') != 'All Products':
|
||||
query += """
|
||||
and item_group = %(product_group)s"""
|
||||
|
||||
# order by
|
||||
query += """
|
||||
order by item_name asc, name asc"""
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
return webnotes.conn.sql(query, args, as_dict=1)
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_product_category_list(args=None):
|
||||
"""
|
||||
args = {
|
||||
'limit_start': 0,
|
||||
'limit_page_length': 5,
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
|
||||
query = """\
|
||||
select count(name) as items, item_group
|
||||
from `tabItem`
|
||||
where is_sales_item = 'Yes'
|
||||
and docstatus = 0
|
||||
and show_in_website = 1
|
||||
group by item_group
|
||||
order by items desc"""
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
|
||||
result = webnotes.conn.sql(query, args, as_dict=1)
|
||||
|
||||
# add All Products link
|
||||
total_count = sum((r.get('items') or 0 for r in result))
|
||||
result = [{'items': total_count, 'item_group': 'All Products'}] + (result or [])
|
||||
|
||||
return result
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_similar_product_list(args=None):
|
||||
"""
|
||||
args = {
|
||||
'limit_start': 0,
|
||||
'limit_page_length': 5,
|
||||
'product_name': '',
|
||||
'product_group': '',
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
|
||||
query = """\
|
||||
select name, item_name, page_name, website_image,
|
||||
description, web_short_description
|
||||
from `tabItem`
|
||||
where is_sales_item = 'Yes'
|
||||
and docstatus = 0
|
||||
and show_in_website = 1
|
||||
and name != %(product_name)s
|
||||
and item_group = %(product_group)s
|
||||
order by item_name"""
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
result = webnotes.conn.sql(query, args, as_dict=1)
|
||||
|
||||
return result
|
7
erpnext/website/templates/css/blog.css
Normal file
7
erpnext/website/templates/css/blog.css
Normal file
@ -0,0 +1,7 @@
|
||||
<style>
|
||||
h2 > a, h2 > a:link, h2 > a:visited, h2 > a:active,
|
||||
h2 > a:hover, h2 > a:focus {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
9
erpnext/website/templates/css/blog_page.css
Normal file
9
erpnext/website/templates/css/blog_page.css
Normal file
@ -0,0 +1,9 @@
|
||||
<style>
|
||||
.comment-title {
|
||||
color:#777;
|
||||
}
|
||||
|
||||
.comment-content {
|
||||
margin-left: 20px;
|
||||
}
|
||||
</style>
|
10
erpnext/website/templates/css/login.css
Normal file
10
erpnext/website/templates/css/login.css
Normal file
@ -0,0 +1,10 @@
|
||||
<style>
|
||||
#login_wrapper {
|
||||
width: 300px !important;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
.login-banner {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
34
erpnext/website/templates/css/product_page.css
Normal file
34
erpnext/website/templates/css/product_page.css
Normal file
@ -0,0 +1,34 @@
|
||||
<style>
|
||||
.web-long-description {
|
||||
font-size: 18px;
|
||||
line-height: 200%;
|
||||
}
|
||||
.product-page-content {
|
||||
float: left;
|
||||
}
|
||||
/* product page image css */
|
||||
.product-page-content img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* similar products listing */
|
||||
.similar-products .img-area img {
|
||||
max-width: 55px;
|
||||
max-height: 55px;
|
||||
}
|
||||
|
||||
.similar-products .img-area {
|
||||
float: left;
|
||||
width: 30%;
|
||||
margin-top: 0.3em;
|
||||
}
|
||||
|
||||
.similar-product-description {
|
||||
float: left;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.similar-product-description span {
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
11
erpnext/website/templates/css/products.css
Normal file
11
erpnext/website/templates/css/products.css
Normal file
@ -0,0 +1,11 @@
|
||||
<style>
|
||||
.img-area {
|
||||
float:left;
|
||||
width: 115px;
|
||||
}
|
||||
|
||||
.product-list-description {
|
||||
float:left;
|
||||
width: 400px;
|
||||
}
|
||||
</style>
|
27
erpnext/website/templates/html/base.html
Normal file
27
erpnext/website/templates/html/base.html
Normal file
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
<meta name="generator" content="wnframework">
|
||||
<script type="text/javascript" src="js/lib/jquery/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="js/all-web.js"></script>
|
||||
<script type="text/javascript" src="js/wn-web.js"></script>
|
||||
<link type="text/css" rel="stylesheet" href="css/all-web.css">
|
||||
<link type="text/css" rel="stylesheet" href="css/wn-web.css">
|
||||
|
||||
{% if favicon %}
|
||||
<link rel="shortcut icon" href="files/{{ favicon }}" type="image/x-icon">
|
||||
<link rel="icon" href="files/{{ favicon }}" type="image/x-icon">
|
||||
{% else %}
|
||||
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
|
||||
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% block header %}
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% block body %}
|
||||
{% endblock %}
|
||||
</body>
|
58
erpnext/website/templates/html/blog_page.html
Normal file
58
erpnext/website/templates/html/blog_page.html
Normal file
@ -0,0 +1,58 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/blog_page.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% include "css/blog_page.css" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="web-content" id="blog-{{ name }}">
|
||||
|
||||
<div class="layout-main-section">
|
||||
|
||||
<h2>{{ title }}</h2>
|
||||
|
||||
<!-- begin blog content -->
|
||||
<div class="help">By {{ full_name }} on {{ updated }}</div>
|
||||
<br>
|
||||
{{ content_html }}
|
||||
<!-- end blog content -->
|
||||
|
||||
<hr>
|
||||
<h3>Comments</h3><br>
|
||||
<div class="blog-comments">
|
||||
|
||||
{% if not comment_list %}
|
||||
<div class="no-result help hide">
|
||||
<p>Be the first one to comment</p>
|
||||
<br />
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% include 'html/comment.html' %}
|
||||
|
||||
<button class="btn add-comment">Add Comment</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layout-side-section">
|
||||
<p><a href="blog.html">All Blogs</a></p>
|
||||
<br />
|
||||
<h4>Subscribe</h4>
|
||||
<p>
|
||||
<img src="images/feed.png" style="margin-right: 4px; margin-bottom: -4px">
|
||||
<a href="rss.xml" target="_blank">RSS Feed</a>
|
||||
</p>
|
||||
<br />
|
||||
<h4>Recent Posts</h4>
|
||||
<div class="recent-posts" style="min-height: 100px;"></div>
|
||||
</div>
|
||||
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
14
erpnext/website/templates/html/comment.html
Normal file
14
erpnext/website/templates/html/comment.html
Normal file
@ -0,0 +1,14 @@
|
||||
{#
|
||||
this template generates comment rows for a blog
|
||||
it is to be included in the blog/blog.html template
|
||||
#}
|
||||
|
||||
{% for comment in comment_list %}
|
||||
<div class="comment-row">
|
||||
<div class="comment-title">
|
||||
{{ comment.comment_by_fullname }} - {{ comment.comment_date }}:
|
||||
</div>
|
||||
<p class="comment-content">{{ comment.comment }}</p>
|
||||
<hr>
|
||||
</div>
|
||||
{% endfor %}
|
59
erpnext/website/templates/html/outer.html
Normal file
59
erpnext/website/templates/html/outer.html
Normal file
@ -0,0 +1,59 @@
|
||||
{#
|
||||
requires, brand, top_bar_items, footer_items, copyright, content
|
||||
#}
|
||||
|
||||
{% extends "html/base.html" %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
<header>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="index.html">{{ brand }}</a>
|
||||
<ul class="nav">
|
||||
{% for page in top_bar_items %}
|
||||
{% if not page.parent_label %}
|
||||
<li data-label="{{ page.label }}">
|
||||
<a href="{{ page.url }}" {{ page.target }}>
|
||||
{{ page.label }}
|
||||
{% if page.child_items %}
|
||||
<ul class="dropdown-menu">
|
||||
{% for child in page.child_items %}
|
||||
<li data-label="{{ child.label }}">
|
||||
<a href="{{ child.url }}" {{ child.target }}>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<img src="images/lib/ui/spinner.gif" id="spinner"/>
|
||||
<ul class="nav pull-right">
|
||||
<li id="login-topbar-item"><a href="login.html">Login</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div id="body_div">
|
||||
<div class="content" id="page-{{ name }}" style="display: block;">
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
<footer><div class="web-footer">
|
||||
<div class="web-footer-menu"><ul>
|
||||
{% for item in footer_items %}
|
||||
<li><a href="{{ item.url }}" {{ item.target }}
|
||||
data-label="{{ item.label }}">{{ item.label }}</a></li>
|
||||
{% endfor %}
|
||||
</ul></div>
|
||||
{% if copyright %}
|
||||
<div class="web-footer-copyright">© {{ copyright }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
{% endblock %}
|
36
erpnext/website/templates/html/page.html
Normal file
36
erpnext/website/templates/html/page.html
Normal file
@ -0,0 +1,36 @@
|
||||
{% extends "html/outer.html" %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
{% block header %}
|
||||
{{ super() }}
|
||||
<script>
|
||||
window.page_name = "{{ name }}";
|
||||
|
||||
$(document).bind('app_ready', function() {
|
||||
var _page = new wn.views.Page(window.page_name);
|
||||
|
||||
// page script
|
||||
{% block javascript %}
|
||||
{% endblock %}
|
||||
|
||||
// trigger onload
|
||||
_page.trigger('onload');
|
||||
|
||||
// activate page
|
||||
wn.container.change_to(window.page_name);
|
||||
});
|
||||
</script>
|
||||
|
||||
{% block css %}
|
||||
{% if insert_style %}
|
||||
|
||||
<style>{{ css }}</style>
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ content }}
|
||||
{% endblock %}
|
48
erpnext/website/templates/html/product_page.html
Normal file
48
erpnext/website/templates/html/product_page.html
Normal file
@ -0,0 +1,48 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/product_page.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% include "css/product_page.css" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
{% if item_name != name %}
|
||||
{{ item_name }} [{{ name }}]
|
||||
{% else %}
|
||||
{{ item_name }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="web-content" id="content-product-{{ name }}">
|
||||
<div class="layout-main-section">
|
||||
<h1>{{ item_name }}</h1>
|
||||
<div class="product-page-content">
|
||||
<br><br>
|
||||
{% if website_image %}
|
||||
<image src="files/{{ website_image }}" />
|
||||
{% else %}
|
||||
<div class="img-area"></div>
|
||||
<span style="font-size: 11px">This is an auto-generated Image</span>
|
||||
{% endif %}
|
||||
<br><br>
|
||||
<div class="web-long-description">
|
||||
{{ web_description_html }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout-side-section">
|
||||
<h4>More Categories</h4>
|
||||
<div class="more-categories"></div>
|
||||
<br>
|
||||
<h4>Similar Products</h4>
|
||||
<div class="similar-products"></div>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
29
erpnext/website/templates/html/web_page.html
Normal file
29
erpnext/website/templates/html/web_page.html
Normal file
@ -0,0 +1,29 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% if insert_code %}
|
||||
{{ javascript }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="web-content" style="text-align: {{ text_align }};">
|
||||
|
||||
{% if layout and layout.startswith('Two column') %}
|
||||
<div class="layout-main-section">
|
||||
{% else %}
|
||||
<div class="layout-main">
|
||||
{% endif %}
|
||||
{{ main_section_html }}
|
||||
</div>
|
||||
|
||||
{% if layout and layout.startswith('Two column') %}
|
||||
<div class="layout-side-section">
|
||||
{{ side_section_html }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -14,17 +14,21 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
erpnext.make_product_categories = function(wrapper) {
|
||||
wrapper.category_list = new wn.ui.Listing({
|
||||
parent: $(wrapper).find('.more-categories').get(0),
|
||||
query: 'select count(name) as items, item_group \
|
||||
from tabItem where is_sales_item="Yes" \
|
||||
group by item_group order by items desc',
|
||||
// js inside blog page
|
||||
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',
|
||||
hide_refresh: true,
|
||||
no_toolbar: true,
|
||||
render_row: function(parent, data) {
|
||||
parent.innerHTML = repl('<a href="#!products/%(item_group)s">%(item_group)s</a> (%(items)s)',
|
||||
data);
|
||||
}
|
||||
if(data.content && data.content.length==1000) {
|
||||
data.content += repl('... <a href="%(name)s.html">(read on)</a>', data);
|
||||
}
|
||||
parent.innerHTML = repl('<h2><a href="%(name)s.html">%(title)s</a></h2>\
|
||||
%(content)s<br /><br />', data);
|
||||
},
|
||||
page_length: 10
|
||||
});
|
||||
wrapper.category_list.run();
|
||||
}
|
||||
erpnext.blog_list.run();
|
||||
}
|
180
erpnext/website/templates/js/blog_page.js
Normal file
180
erpnext/website/templates/js/blog_page.js
Normal file
@ -0,0 +1,180 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// js inside blog page
|
||||
|
||||
wn.provide('erpnext.blog');
|
||||
wn.pages['{{ name }}'].onload = function(wrapper) {
|
||||
erpnext.blog.wrapper = wrapper;
|
||||
|
||||
// sidebar
|
||||
erpnext.blog.render_recent_list(wrapper);
|
||||
|
||||
// unhide no-result if no comments found
|
||||
erpnext.blog.toggle_no_result(wrapper);
|
||||
|
||||
// bind add comment button to comment dialog
|
||||
erpnext.blog.make_comment_dialog(wrapper);
|
||||
|
||||
// hide add comment button after 50 comments
|
||||
erpnext.blog.toggle_add_comment_btn(wrapper);
|
||||
}
|
||||
|
||||
erpnext.blog.adjust_page_height = function(wrapper) {
|
||||
if (!wrapper) { wrapper = erpnext.blog.wrapper; }
|
||||
if (!wrapper) { return; }
|
||||
|
||||
// adjust page height based on sidebar height
|
||||
var $main_page = $(wrapper).find('.layout-main-section');
|
||||
var $sidebar = $(wrapper).find('.layout-side-section');
|
||||
if ($sidebar.height() > $main_page.height()) {
|
||||
$main_page.height($sidebar.height());
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.blog.render_recent_list = function(wrapper) {
|
||||
if (!wrapper) { wrapper = erpnext.blog.wrapper; }
|
||||
if (!wrapper) { return; }
|
||||
|
||||
wrapper.recent_list = new wn.ui.Listing({
|
||||
parent: $(wrapper).find('.recent-posts'),
|
||||
no_toolbar: true,
|
||||
method: 'website.blog.get_recent_blog_list',
|
||||
get_args: function() {
|
||||
return { name: '{{ name }}' }
|
||||
},
|
||||
hide_refresh: true,
|
||||
render_row: function(parent, data) {
|
||||
if(data.content && data.content.length>=100) data.content += '...';
|
||||
parent.innerHTML = repl('<a href="%(name)s.html">%(title)s</a>\
|
||||
<div class="comment">%(content)s</div><br>', data);
|
||||
|
||||
// adjust page height depending on sidebar height
|
||||
erpnext.blog.adjust_page_height(wrapper);
|
||||
},
|
||||
page_length: 5,
|
||||
});
|
||||
wrapper.recent_list.run();
|
||||
}
|
||||
|
||||
erpnext.blog.toggle_no_result = function(wrapper) {
|
||||
if (!wrapper) { wrapper = erpnext.blog.wrapper; }
|
||||
if (!wrapper) { return; }
|
||||
|
||||
var $blog_comments = $(wrapper).find('.blog-comments');
|
||||
var $comment_rows = $blog_comments.find('.comment-row');
|
||||
var $no_result = $blog_comments.find('.no-result');
|
||||
|
||||
if ($comment_rows.length == 0) {
|
||||
$no_result.removeClass('hide');
|
||||
} else {
|
||||
$no_result.addClass('hide');
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.blog.make_comment_dialog = function(wrapper) {
|
||||
if (!wrapper) { wrapper = erpnext.blog.wrapper; }
|
||||
if (!wrapper) { return; }
|
||||
|
||||
var $comment_btn = $(wrapper).find('button.add-comment');
|
||||
|
||||
$comment_btn.click(function() {
|
||||
if(!erpnext.blog.comment_dialog) {
|
||||
var d = new wn.widgets.Dialog({
|
||||
title: 'Add Comment',
|
||||
fields: [
|
||||
{
|
||||
fieldname: 'comment_by_fullname', label: 'Your Name',
|
||||
reqd: 1, fieldtype: 'Data'
|
||||
},
|
||||
{
|
||||
fieldname: 'comment_by', label: 'Email Id',
|
||||
reqd: 1, fieldtype: 'Data'
|
||||
},
|
||||
{
|
||||
fieldname: 'comment', label: 'Comment',
|
||||
reqd: 1, fieldtype: 'Text'
|
||||
},
|
||||
{
|
||||
fieldname: 'post_comment', label: 'Post Comment',
|
||||
fieldtype: 'Button'
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
erpnext.blog.comment_dialog = d;
|
||||
}
|
||||
|
||||
erpnext.blog.comment_dialog.fields_dict.post_comment
|
||||
.input.onclick = function() {
|
||||
erpnext.blog.add_comment(wrapper);
|
||||
}
|
||||
|
||||
erpnext.blog.comment_dialog.show();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
erpnext.blog.add_comment = function(wrapper) {
|
||||
var args = erpnext.blog.comment_dialog.get_values();
|
||||
|
||||
if(!args) return;
|
||||
|
||||
args.comment_doctype = 'Blog';
|
||||
args.comment_docname = '{{ name }}';
|
||||
args.page_name = '{{ page_name }}';
|
||||
|
||||
wn.call({
|
||||
method: 'website.blog.add_comment',
|
||||
args: args,
|
||||
btn: this,
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
erpnext.blog.add_comment_to_page(wrapper, r.message);
|
||||
erpnext.blog.comment_dialog.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
erpnext.blog.add_comment_to_page = function(wrapper, comment) {
|
||||
$blog_comments = $(wrapper).find('.blog-comments');
|
||||
$comment_rows = $blog_comments.find('.comment-row');
|
||||
|
||||
if ($comment_rows.length) {
|
||||
$blog_comments.append(comment);
|
||||
} else {
|
||||
$blog_comments.append(comment);
|
||||
}
|
||||
|
||||
erpnext.blog.toggle_no_result(wrapper);
|
||||
erpnext.blog.toggle_add_comment_btn(wrapper);
|
||||
}
|
||||
|
||||
erpnext.blog.toggle_add_comment_btn = function(wrapper) {
|
||||
var $wrapper = $(wrapper);
|
||||
if ($wrapper.find('.blog-comments .comment-row').length > 50) {
|
||||
var $comment_btn = $wrapper.find('button.add-comment');
|
||||
$comment_btn.addClass('hide');
|
||||
|
||||
// show comments are close
|
||||
$wrapper.find('.blog-comments').append("\
|
||||
<div class=\"help\"> \
|
||||
<p>Comments Closed</p> \
|
||||
<br /> \
|
||||
</div>");
|
||||
}
|
||||
}
|
91
erpnext/website/templates/js/login.js
Normal file
91
erpnext/website/templates/js/login.js
Normal file
@ -0,0 +1,91 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
wn.provide('erpnext.login');
|
||||
|
||||
wn.pages["{{ name }}"].onload = function(wrapper) {
|
||||
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
|
||||
wrapper.appframe.title('Login');
|
||||
wrapper.appframe.$w.find('.close').toggle(false);
|
||||
|
||||
var lw = $i('login_wrapper');
|
||||
$bs(lw, '1px 1px 3px #888');
|
||||
|
||||
$('#login_btn').click(erpnext.login.doLogin)
|
||||
|
||||
$('#password').keypress(function(ev){
|
||||
if(ev.which==13 && $('#password').val()) {
|
||||
$('form').submit(function() {
|
||||
erpnext.login.doLogin();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
$(document).trigger('login_rendered');
|
||||
}
|
||||
|
||||
// Login Callback
|
||||
erpnext.login.onLoginReply = function(r, rtext) {
|
||||
$('#login_btn').done_working();
|
||||
if(r.message=="Logged In"){
|
||||
window.location.href='app.html' + (get_url_arg('page') ? ('?page='+get_url_arg('page')) : '');
|
||||
} else {
|
||||
$i('login_message').innerHTML = '<span style="color: RED;">'+(r.message)+'</span>';
|
||||
//if(r.exc)alert(r.exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Login
|
||||
erpnext.login.doLogin = function(){
|
||||
|
||||
var args = {};
|
||||
args['usr']=$i("login_id").value;
|
||||
args['pwd']=$i("password").value;
|
||||
if($i('remember_me').checked)
|
||||
args['remember_me'] = 1;
|
||||
|
||||
$('#login_btn').set_working();
|
||||
|
||||
$c("login", args, erpnext.login.onLoginReply);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
erpnext.login.show_forgot_password = function(){
|
||||
// create dialog
|
||||
var d = new wn.ui.Dialog({
|
||||
title:"Forgot Password",
|
||||
fields: [
|
||||
{'label':'Email Id', 'fieldname':'email_id', 'fieldtype':'Data', 'reqd':true},
|
||||
{'label':'Email Me A New Password', 'fieldname':'run', 'fieldtype':'Button'}
|
||||
]
|
||||
});
|
||||
|
||||
$(d.fields_dict.run.input).click(function() {
|
||||
var values = d.get_values();
|
||||
if(!values) return;
|
||||
wn.call({
|
||||
method:'reset_password',
|
||||
args: { user: values.email_id },
|
||||
callback: function() {
|
||||
d.hide();
|
||||
}
|
||||
})
|
||||
})
|
||||
d.show();
|
||||
}
|
18
erpnext/website/templates/js/product_category.js
Normal file
18
erpnext/website/templates/js/product_category.js
Normal file
@ -0,0 +1,18 @@
|
||||
wn.provide('erpnext.products');
|
||||
|
||||
erpnext.products.make_product_categories = function(wrapper) {
|
||||
if (!wrapper) { wrapper = erpnext.products.wrapper; }
|
||||
if (!wrapper) { return; }
|
||||
|
||||
wrapper.category_list = new wn.ui.Listing({
|
||||
parent: $(wrapper).find('.more-categories').get(0),
|
||||
method: 'website.product.get_product_category_list',
|
||||
hide_refresh: true,
|
||||
render_row: function(parent, data) {
|
||||
parent.innerHTML = repl(
|
||||
'<a href="products.html#!products/%(item_group)s">%(item_group)s</a> (%(items)s)',
|
||||
data);
|
||||
}
|
||||
});
|
||||
wrapper.category_list.run();
|
||||
}
|
92
erpnext/website/templates/js/product_page.js
Normal file
92
erpnext/website/templates/js/product_page.js
Normal file
@ -0,0 +1,92 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
{% include "js/product_category.js" %}
|
||||
|
||||
wn.pages['{{ name }}'].onload = function(wrapper) {
|
||||
wrapper.product_group = "{{ item_group }}";
|
||||
wrapper.product_name = "{{ name }}";
|
||||
erpnext.products.make_product_categories(wrapper);
|
||||
erpnext.products.make_similar_products(wrapper);
|
||||
|
||||
// if website image missing, autogenerate one
|
||||
var $img = $(wrapper).find('.product-page-content .img-area');
|
||||
if ($img && $img.length > 0) {
|
||||
$img.append(wn.dom.placeholder(160, "{{ item_name }}"));
|
||||
}
|
||||
|
||||
erpnext.products.adjust_page_height(wrapper);
|
||||
|
||||
}
|
||||
|
||||
erpnext.products.adjust_page_height = function(wrapper) {
|
||||
if (!wrapper) { wrapper = erpnext.products.wrapper; }
|
||||
if (!wrapper) { return; }
|
||||
|
||||
// adjust page height based on sidebar height
|
||||
var $main_page = $(wrapper).find('.layout-main-section');
|
||||
var $sidebar = $(wrapper).find('.layout-side-section');
|
||||
if ($sidebar.height() > $main_page.height()) {
|
||||
$main_page.height($sidebar.height());
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.products.make_similar_products = function(wrapper) {
|
||||
if (!wrapper) { wrapper = erpnext.products.wrapper; }
|
||||
if (!wrapper) { return; }
|
||||
|
||||
// similar products
|
||||
wrapper.similar = new wn.ui.Listing({
|
||||
parent: $(wrapper).find('.similar-products').get(0),
|
||||
hide_refresh: true,
|
||||
page_length: 5,
|
||||
method: 'website.product.get_similar_product_list',
|
||||
get_args: function() {
|
||||
return {
|
||||
product_group: wrapper.product_group,
|
||||
product_name: wrapper.product_name
|
||||
}
|
||||
},
|
||||
render_row: function(parent, data) {
|
||||
if (!data.web_short_description) {
|
||||
data.web_short_description = data.description;
|
||||
}
|
||||
if(data.web_short_description.length > 100) {
|
||||
data.web_short_description =
|
||||
data.web_short_description.substr(0,100) + '...';
|
||||
}
|
||||
parent.innerHTML = repl('\
|
||||
<a href="%(page_name)s.html"><div class="img-area"></div></a>\
|
||||
<div class="similar-product-description">\
|
||||
<h5><a href="%(page_name)s.html">%(item_name)s</a></h5>\
|
||||
<span>%(web_short_description)s</span>\
|
||||
</div>\
|
||||
<div style="clear:both"></div>', data);
|
||||
|
||||
if(data.website_image) {
|
||||
$(parent).find('.img-area').append(repl(
|
||||
'<img src="files/%(website_image)s" />', data))
|
||||
} else {
|
||||
$(parent).find('.img-area').append(wn.dom.placeholder(55,
|
||||
data.item_name));
|
||||
}
|
||||
|
||||
// adjust page height, if sidebar height keeps increasing
|
||||
erpnext.products.adjust_page_height(wrapper);
|
||||
}
|
||||
});
|
||||
wrapper.similar.run();
|
||||
}
|
@ -14,20 +14,22 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
erpnext.products = {}
|
||||
// js inside blog page
|
||||
|
||||
wn.require('js/product_category.js');
|
||||
|
||||
pscript.onload_products = function(wrapper) {
|
||||
erpnext.make_product_categories(wrapper);
|
||||
erpnext.products.wrapper = wrapper;
|
||||
{% include "js/product_category.js" %}
|
||||
|
||||
wn.pages['{{ name }}'].onload = function(wrapper) {
|
||||
erpnext.products.wrapper = wrapper;
|
||||
|
||||
// make product categories in the sidebar
|
||||
erpnext.products.make_product_categories(wrapper);
|
||||
|
||||
// make lists
|
||||
erpnext.products.make_product_list(wrapper);
|
||||
|
||||
// button
|
||||
// bind search button or enter key
|
||||
$(wrapper).find('.products-search .btn').click(function() {
|
||||
wrapper.mainlist.run();
|
||||
erpnext.products.product_list.run();
|
||||
});
|
||||
|
||||
$(wrapper).find('.products-search input').keypress(function(ev) {
|
||||
@ -35,75 +37,70 @@ pscript.onload_products = function(wrapper) {
|
||||
});
|
||||
}
|
||||
|
||||
pscript.onshow_products = function(wrapper) {
|
||||
// show default product category
|
||||
erpnext.products.set_group();
|
||||
}
|
||||
|
||||
erpnext.products.get_group = function() {
|
||||
route = wn.get_route();
|
||||
if(route.length>1) {
|
||||
// from url
|
||||
var grp = route[1];
|
||||
var label = route[1];
|
||||
} else {
|
||||
// default
|
||||
var grp = wn.boot.website_settings.default_product_category;
|
||||
var label = wn.boot.website_settings.default_product_category;
|
||||
}
|
||||
erpnext.products.cur_group = grp;
|
||||
return {grp:grp, label:label};
|
||||
}
|
||||
|
||||
erpnext.products.make_product_list = function(wrapper) {
|
||||
wrapper.mainlist = new wn.ui.Listing({
|
||||
parent: $(wrapper).find('.products-list').get(0),
|
||||
if (!wrapper) { wrapper = erpnext.products.wrapper; }
|
||||
if (!wrapper) { return; }
|
||||
|
||||
erpnext.products.product_list = new wn.ui.Listing({
|
||||
parent: $(wrapper).find('#products-list').get(0),
|
||||
run_btn: $(wrapper).find('.products-search .btn').get(0),
|
||||
no_toolbar: true,
|
||||
get_query: function() {
|
||||
var srch = $('input[name="products-search"]').val()
|
||||
var search_cond = 'and (description like "%%(srch)s%"\
|
||||
or item_name like "%%(srch)s%")';
|
||||
args = {
|
||||
search_cond: srch ? repl(search_cond, {srch:srch}) : '',
|
||||
cat: erpnext.products.cur_group
|
||||
method: 'website.product.get_product_list',
|
||||
get_args: function() {
|
||||
return {
|
||||
search: $('input[name="products-search"]').val() || '',
|
||||
product_group: erpnext.products.cur_group || '',
|
||||
};
|
||||
return repl('select name, item_name, website_image, \
|
||||
description, page_name \
|
||||
from tabItem \
|
||||
where is_sales_item="Yes" \
|
||||
and item_group="%(cat)s" \
|
||||
%(search_cond)s', args)
|
||||
},
|
||||
render_row: function(parent, data) {
|
||||
parent.innerHTML = repl('<div style="float:left; width: 115px;" class="img-area">\
|
||||
</div>\
|
||||
<div style="float:left; width: 400px">\
|
||||
<p><b><a href="#!%(page_name)s">%(item_name)s</a></b></p>\
|
||||
<p>%(description)s</p></div>\
|
||||
if (!data.web_short_description) {
|
||||
data.web_short_description = data.description;
|
||||
}
|
||||
parent.innerHTML = repl('\
|
||||
<a href="%(page_name)s.html"><div class="img-area"></div></a>\
|
||||
<div class="product-list-description">\
|
||||
<h4><a href="%(page_name)s.html">%(item_name)s</a></h4>\
|
||||
<p>%(web_short_description)s</p></div>\
|
||||
<div style="clear: both;"></div>', data);
|
||||
|
||||
if(data.website_image) {
|
||||
$(parent).find('.img-area').append(repl(
|
||||
'<img src="files/%(website_image)s" style="width:100px;">', data))
|
||||
} else {
|
||||
$(parent).find('.img-area').append(wn.dom.placeholder(70,
|
||||
$(parent).find('.img-area').append(wn.dom.placeholder(100,
|
||||
data.item_name));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
wn.pages['{{ name }}'].onshow = function(wrapper) {
|
||||
// show default product category
|
||||
erpnext.products.set_group();
|
||||
}
|
||||
|
||||
erpnext.products.set_group = function() {
|
||||
var cat = erpnext.products.get_group();
|
||||
if(!cat.grp) {
|
||||
// still nothing
|
||||
setTimeout('erpnext.products.set_group()', 1000);
|
||||
return;
|
||||
}
|
||||
|
||||
// get erpnext.products.default_category
|
||||
var wrapper = erpnext.products.wrapper;
|
||||
|
||||
$(wrapper).find('h1').html(cat.label);
|
||||
wrapper.mainlist.run();
|
||||
erpnext.products.product_list.run();
|
||||
}
|
||||
|
||||
erpnext.products.get_group = function() {
|
||||
route = wn.get_route();
|
||||
if(route && route.length>1) {
|
||||
// from url
|
||||
var grp = route[1];
|
||||
var label = route[1];
|
||||
erpnext.products.cur_group = grp;
|
||||
} else {
|
||||
// default
|
||||
var grp = 'Products';
|
||||
var label = 'Products';
|
||||
erpnext.products.cur_group = null;
|
||||
}
|
||||
return {grp:grp, label:label};
|
||||
}
|
12
erpnext/website/templates/pages/404.html
Normal file
12
erpnext/website/templates/pages/404.html
Normal file
@ -0,0 +1,12 @@
|
||||
{% extends "html/outer.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="content">
|
||||
<div class="layout-wrapper layout-main">
|
||||
<h3>Page missing or moved</h3>
|
||||
<br>
|
||||
<p>We are very sorry for this, but the page you are looking for is missing
|
||||
(this could be because of a typo in the address) or moved.</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
41
erpnext/website/templates/pages/blog.html
Normal file
41
erpnext/website/templates/pages/blog.html
Normal file
@ -0,0 +1,41 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/blog.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% include "css/blog.css" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}Blog{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="web-content" id="content-blog">
|
||||
|
||||
<div class="layout-main-section">
|
||||
<h1>Blog</h1>
|
||||
<br>
|
||||
<div id="blog-list">
|
||||
<!-- blog list will be generated dynamically -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layout-side-section">
|
||||
<!-- for later
|
||||
<h4>Get Updates</h4>
|
||||
<p>
|
||||
<input name="blog-subscribe">
|
||||
<button class="btn" id="blog-subscribe">Subscribe</button>
|
||||
</p>-->
|
||||
<h4>Subscribe</h4>
|
||||
<p>
|
||||
<img src="images/feed.png" style="margin-right: 4px; margin-bottom: -4px">
|
||||
<a href="rss.xml" target="_blank">RSS Feed</a>
|
||||
</p>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
1
erpnext/website/templates/pages/index.html
Normal file
1
erpnext/website/templates/pages/index.html
Normal file
@ -0,0 +1 @@
|
||||
{% extends "html/web_page.html" %}
|
52
erpnext/website/templates/pages/login.html
Normal file
52
erpnext/website/templates/pages/login.html
Normal file
@ -0,0 +1,52 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/login.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% include "css/login.css" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
Login Page
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="layout-wrapper layout-wrapper-appframe" id='login_wrapper'>
|
||||
<div class="appframe-area"></div>
|
||||
<div class="layout-main" style="padding: 15px;">
|
||||
<form autocomplete="on">
|
||||
<table border="0" cellspacing="8">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Login Id</td>
|
||||
<td><input id="login_id" type="text" style="width: 180px"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Password</td>
|
||||
<td><input id="password" type="password" style="width: 180px" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:right"><input id="remember_me" type="checkbox" /></td>
|
||||
<td>Remember Me</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td id="login_message"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<button type="submit" id="login_btn" class="btn btn-small btn-primary">Login</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<p style="margin-left: 72px;"><span class="link_type"
|
||||
onclick="erpnext.login.show_forgot_password()">Forgot Password</span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
37
erpnext/website/templates/pages/products.html
Normal file
37
erpnext/website/templates/pages/products.html
Normal file
@ -0,0 +1,37 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/products.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% include "css/products.css" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
Products
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="web-content" id="content-products">
|
||||
|
||||
<div class="layout-main-section">
|
||||
<h1 class="products-category"></h1>
|
||||
<div class="products-search" style="margin-bottom: 15px;">
|
||||
<input name="products-search" />
|
||||
<button class="btn" style="margin-left: 7px">Search</button>
|
||||
</div>
|
||||
<div id="products-list">
|
||||
<!-- product list will be generated dynamically -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layout-side-section">
|
||||
<h3>Categories</h3>
|
||||
<div class="more-categories"></div>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -17,6 +17,12 @@
|
||||
import webnotes
|
||||
from webnotes.model.doc import Document
|
||||
|
||||
def scrub_page_name(page_name):
|
||||
if page_name.endswith('.html'):
|
||||
page_name = page_name[:-5]
|
||||
|
||||
return page_name
|
||||
|
||||
def make_template(doc, path, convert_fields = ['main_section', 'side_section']):
|
||||
"""make template"""
|
||||
import os, jinja2
|
||||
@ -29,119 +35,9 @@ def make_template(doc, path, convert_fields = ['main_section', 'side_section']):
|
||||
|
||||
return temp.render(doc = doc.fields)
|
||||
|
||||
def markdown(doc, fields):
|
||||
"""convert fields to markdown"""
|
||||
import markdown2
|
||||
# markdown
|
||||
for f in fields:
|
||||
doc.fields[f + '_html'] = markdown2.markdown(doc.fields[f] or '', \
|
||||
extras=["wiki-tables"])
|
||||
|
||||
|
||||
def page_name(title):
|
||||
"""make page name from title, and check that there is no duplicate"""
|
||||
import webnotes.cms
|
||||
return webnotes.cms.page_name(title)
|
||||
|
||||
def add_page(title):
|
||||
"""add a custom page with title"""
|
||||
name = page_name(title)
|
||||
if webnotes.conn.sql("""select name from tabPage where name=%s""", name):
|
||||
p = Document('Page', name)
|
||||
else:
|
||||
p = Document('Page')
|
||||
|
||||
p.title = title
|
||||
p.name = p.page_name = name
|
||||
p.module = 'Website'
|
||||
p.standard = 'No'
|
||||
|
||||
return p
|
||||
|
||||
def add_guest_access_to_page(page):
|
||||
"""add Guest in Page Role"""
|
||||
if not webnotes.conn.sql("""select parent from `tabPage Role`
|
||||
where role='Guest' and parent=%s""", page):
|
||||
d = Document('Page Role')
|
||||
d.parent = page
|
||||
d.role = 'Guest'
|
||||
d.save()
|
||||
|
||||
def get_header(page_name):
|
||||
"""get page header"""
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from jinja2 import Template
|
||||
import webnotes.utils
|
||||
|
||||
def get_item(l, label):
|
||||
for i in l:
|
||||
if i['label']==label:
|
||||
return i
|
||||
|
||||
top_bar_items = webnotes.conn.sql("""select * from `tabTop Bar Item`
|
||||
where parent='Website Settings' and parentfield='top_bar_items'
|
||||
order by idx asc""", as_dict=1)
|
||||
|
||||
# build child items
|
||||
for t in top_bar_items:
|
||||
if t.get('parent_label'):
|
||||
pi = get_item(top_bar_items, t['parent_label'])
|
||||
if 'child_items' not in pi:
|
||||
pi['child_items'] = []
|
||||
pi['child_items'].append(t)
|
||||
|
||||
website_settings = Document('Website Settings', 'Website Settings')
|
||||
|
||||
return Template("""<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="index.html">{{ brand }}</a>
|
||||
<ul class="nav">
|
||||
{% for page in top_bar_items %}
|
||||
{% if not page.parent_label %}
|
||||
<li data-label="{{ page.label }}">
|
||||
<a href="{{ page.url }}" {{ page.target }}>
|
||||
{{ page.label }}
|
||||
{% if page.child_items %}
|
||||
<ul class="dropdown-menu">
|
||||
{% for child in page.child_items %}
|
||||
<li data-label="{{ child.label }}">
|
||||
<a href="{{ child.url }}" {{ child.target }}>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<img src="images/lib/ui/spinner.gif" id="spinner"/>
|
||||
<ul class="nav pull-right">
|
||||
<li id="login-topbar-item"><a href="login-page.html">Login</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>""").render(top_bar_items = top_bar_items,
|
||||
brand=website_settings.brand_html or webnotes.utils.get_defaults('company') or 'ERPNext')
|
||||
|
||||
def get_footer(page_name):
|
||||
"""get page footer"""
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from jinja2 import Template
|
||||
|
||||
website_settings = Document('Website Settings', 'Website Settings')
|
||||
|
||||
website_settings.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)
|
||||
|
||||
return Template("""<div class="web-footer">
|
||||
<div class="web-footer-menu"><ul>
|
||||
{% for item in footer_items %}
|
||||
<li><a href="{{ item.url }}" {{ item.target }}
|
||||
data-label="{{ item.label }}">{{ item.label }}</a></li>
|
||||
{% endfor %}
|
||||
</ul></div>
|
||||
<div class="web-footer-copyright">© {{ copyright }}
|
||||
</div>""").render(website_settings.fields)
|
||||
"""make page name from title"""
|
||||
import re
|
||||
name = title.lower()
|
||||
name = re.sub('[~!@#$%^&*()<>,."\']', '', name)
|
||||
return '-'.join(name.split()[:4])
|
||||
|
248
erpnext/website/web_cache.py
Normal file
248
erpnext/website/web_cache.py
Normal file
@ -0,0 +1,248 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# html generation functions
|
||||
|
||||
template_map = {
|
||||
'Web Page': 'html/web_page.html',
|
||||
'Blog': 'html/blog_page.html',
|
||||
'Item': 'html/product_page.html',
|
||||
}
|
||||
|
||||
def get_html(page_name, comments=''):
|
||||
import conf
|
||||
|
||||
html = ''
|
||||
|
||||
# load from cache, if auto cache clear is falsy
|
||||
if not (hasattr(conf, 'auto_cache_clear') and conf.auto_cache_clear or 0):
|
||||
html = load_from_cache(page_name)
|
||||
|
||||
if not html:
|
||||
html = load_into_cache(page_name)
|
||||
comments += "\n\npage load status: fresh"
|
||||
|
||||
# insert comments
|
||||
import webnotes.utils
|
||||
html += """\n<!-- %s -->""" % webnotes.utils.cstr(comments)
|
||||
|
||||
return html
|
||||
|
||||
def load_from_cache(page_name):
|
||||
import webnotes
|
||||
|
||||
result = search_cache(page_name)
|
||||
|
||||
if not result:
|
||||
if page_name in get_predefined_pages():
|
||||
# if a predefined page doesn't exist, load it into cache
|
||||
return None
|
||||
else:
|
||||
# if page doesn't exist, raise exception
|
||||
raise Exception, "Page %s not found" % page_name
|
||||
|
||||
return result[0][0]
|
||||
|
||||
def load_into_cache(page_name):
|
||||
args = prepare_args(page_name)
|
||||
|
||||
html = build_html(args)
|
||||
|
||||
# create cache entry for predefined pages, if not exists
|
||||
if page_name in get_predefined_pages():
|
||||
create_cache(page_name)
|
||||
|
||||
import webnotes
|
||||
webnotes.conn.begin()
|
||||
webnotes.conn.set_value('Web Cache', page_name, 'html', html)
|
||||
webnotes.conn.commit()
|
||||
|
||||
return html
|
||||
|
||||
def get_predefined_pages():
|
||||
"""
|
||||
gets a list of predefined pages
|
||||
they do not exist in `tabWeb Page`
|
||||
"""
|
||||
import os
|
||||
import conf
|
||||
import website.utils
|
||||
|
||||
pages_path = os.path.join(conf.modules_path, 'website', 'templates', 'pages')
|
||||
|
||||
page_list = []
|
||||
|
||||
for page in os.listdir(pages_path):
|
||||
page_list.append(website.utils.scrub_page_name(page))
|
||||
|
||||
return page_list
|
||||
|
||||
def prepare_args(page_name):
|
||||
if page_name == 'index':
|
||||
page_name = get_home_page()
|
||||
|
||||
if page_name in get_predefined_pages():
|
||||
args = {
|
||||
'template': 'pages/%s.html' % page_name,
|
||||
'name': page_name,
|
||||
}
|
||||
else:
|
||||
args = get_doc_fields(page_name)
|
||||
|
||||
args.update(get_outer_env())
|
||||
|
||||
return args
|
||||
|
||||
def get_home_page():
|
||||
import webnotes
|
||||
doc_name = webnotes.conn.get_value('Website Settings', None, 'home_page')
|
||||
if doc_name:
|
||||
page_name = webnotes.conn.get_value('Web Page', doc_name, 'page_name')
|
||||
else:
|
||||
page_name = 'login'
|
||||
|
||||
return page_name
|
||||
|
||||
def get_doc_fields(page_name):
|
||||
import webnotes
|
||||
doc_type, doc_name = webnotes.conn.get_value('Web Cache', page_name, ['doc_type', 'doc_name'])
|
||||
|
||||
import webnotes.model.code
|
||||
obj = webnotes.model.code.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]
|
||||
|
||||
return args
|
||||
|
||||
def get_outer_env():
|
||||
"""
|
||||
env dict for outer template
|
||||
"""
|
||||
import webnotes
|
||||
return {
|
||||
'top_bar_items': webnotes.conn.sql("""\
|
||||
select * from `tabTop Bar Item`
|
||||
where parent='Website Settings' and parentfield='top_bar_items'
|
||||
order by idx asc""", as_dict=1),
|
||||
|
||||
'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')
|
||||
}
|
||||
|
||||
def build_html(args):
|
||||
"""
|
||||
build html using jinja2 templates
|
||||
"""
|
||||
import os
|
||||
import conf
|
||||
templates_path = os.path.join(conf.modules_path, 'website', 'templates')
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
jenv = Environment(loader = FileSystemLoader(templates_path))
|
||||
html = jenv.get_template(args['template']).render(args)
|
||||
return html
|
||||
|
||||
# cache management
|
||||
def search_cache(page_name):
|
||||
if not page_name: return ()
|
||||
import webnotes
|
||||
return webnotes.conn.sql("""\
|
||||
select html, doc_type, doc_name
|
||||
from `tabWeb Cache`
|
||||
where name = %s""", page_name)
|
||||
|
||||
def create_cache(page_name, doc_type=None, doc_name=None):
|
||||
# check if a record already exists
|
||||
result = search_cache(page_name)
|
||||
if result: return
|
||||
|
||||
# create a Web Cache record
|
||||
import webnotes.model.doc
|
||||
d = webnotes.model.doc.Document('Web Cache')
|
||||
d.name = page_name
|
||||
d.doc_type = doc_type
|
||||
d.doc_name = doc_name
|
||||
d.html = None
|
||||
d.save()
|
||||
|
||||
def clear_cache(page_name, doc_type=None, doc_name=None):
|
||||
"""
|
||||
* if no page name, clear whole cache
|
||||
* if page_name, doc_type and doc_name match, clear cache's copy
|
||||
* else, raise exception that such a page already exists
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not page_name:
|
||||
webnotes.conn.sql("""update `tabWeb Cache` set html = ''""")
|
||||
return
|
||||
|
||||
result = search_cache(page_name)
|
||||
|
||||
if not doc_type or (result and result[0][1] == doc_type and result[0][2] == doc_name):
|
||||
webnotes.conn.set_value('Web Cache', page_name, 'html', '')
|
||||
else:
|
||||
webnotes.msgprint("""Page with name "%s" already exists as a %s.
|
||||
Please save it with another name.""" % (page_name, result[0][1]),
|
||||
raise_exception=1)
|
||||
|
||||
def delete_cache(page_name):
|
||||
"""
|
||||
delete entry of page_name from Web Cache
|
||||
used when:
|
||||
* web page is deleted
|
||||
* blog is un-published
|
||||
"""
|
||||
import webnotes
|
||||
webnotes.conn.sql("""delete from `tabWeb Cache` where name=%s""", page_name)
|
||||
|
||||
def refresh_cache(build=None):
|
||||
"""delete and re-create web cache entries"""
|
||||
import webnotes
|
||||
|
||||
# webnotes.conn.sql("delete from `tabWeb Cache`")
|
||||
|
||||
clear_cache(None)
|
||||
|
||||
query_map = {
|
||||
'Web Page': """select page_name, name from `tabWeb Page` where docstatus=0""",
|
||||
'Blog': """\
|
||||
select page_name, name from `tabBlog`
|
||||
where docstatus = 0 and ifnull(published, 0) = 1""",
|
||||
'Item': """\
|
||||
select page_name, name from `tabItem`
|
||||
where docstatus = 0 and ifnull(show_in_website, 0) = 1""",
|
||||
}
|
||||
|
||||
for dt in query_map:
|
||||
if build and dt in build:
|
||||
for result in webnotes.conn.sql(query_map[dt], as_dict=1):
|
||||
create_cache(result['page_name'], dt, result['name'])
|
||||
load_into_cache(result['page_name'])
|
||||
|
||||
for page_name in get_predefined_pages():
|
||||
create_cache(page_name, None, None)
|
||||
if build: load_into_cache(page_name)
|
81
erpnext/website/web_page.py
Normal file
81
erpnext/website/web_page.py
Normal file
@ -0,0 +1,81 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import webnotes
|
||||
import website.utils
|
||||
import website.web_cache
|
||||
|
||||
class Page(object):
|
||||
def __init__(self, doctype):
|
||||
self.doctype = doctype
|
||||
|
||||
def autoname(self):
|
||||
"""name from title"""
|
||||
self.doc.name = website.utils.page_name(self.doc.title)
|
||||
|
||||
def validate(self):
|
||||
if self.doc.name:
|
||||
self.old_page_name = webnotes.conn.get_value(self.doctype, self.doc.name, 'page_name')
|
||||
|
||||
def on_update(self):
|
||||
# page name updates with the title
|
||||
self.update_page_name()
|
||||
|
||||
self.clear_web_cache()
|
||||
|
||||
self.doc.save()
|
||||
|
||||
def on_trash(self):
|
||||
"""delete Web Cache entry"""
|
||||
self.delete_web_cache(self.doc.page_name)
|
||||
|
||||
def update_page_name(self):
|
||||
"""set page_name and check if it is unique"""
|
||||
self.doc.page_name = website.utils.page_name(self.doc.title)
|
||||
|
||||
res = webnotes.conn.sql("""\
|
||||
select count(*) from `tab%s`
|
||||
where page_name=%s and name!=%s""" % (self.doctype, '%s', '%s'),
|
||||
(self.doc.page_name, self.doc.name))
|
||||
if res and res[0][0] > 0:
|
||||
webnotes.msgprint("""A %s with the same title already exists.
|
||||
Please change the title of %s and save again."""
|
||||
% (self.doctype, self.doc.name), raise_exception=1)
|
||||
|
||||
def clear_web_cache(self):
|
||||
"""
|
||||
if web cache entry doesn't exist, it creates one
|
||||
if duplicate entry exists for another doctype, it raises exception
|
||||
"""
|
||||
# delete web cache entry of old name
|
||||
if hasattr(self, 'old_page_name') and self.old_page_name and \
|
||||
self.old_page_name != self.doc.page_name:
|
||||
self.delete_web_cache(self.old_page_name)
|
||||
|
||||
website.web_cache.create_cache(self.doc.page_name, self.doc.doctype, self.doc.name)
|
||||
website.web_cache.clear_cache(self.doc.page_name, self.doc.doctype, self.doc.name)
|
||||
|
||||
def delete_web_cache(self, page_name):
|
||||
"""delete entry of page name from Web Cache"""
|
||||
website.web_cache.delete_cache(page_name)
|
||||
|
||||
def markdown_to_html(self, fields_list):
|
||||
"""convert fields from markdown to html"""
|
||||
import markdown2
|
||||
for f in fields_list:
|
||||
field_name = "%s_html" % f
|
||||
self.doc.fields[field_name] = markdown2.markdown(self.doc.fields.get(f) or '', \
|
||||
extras=["wiki-tables"])
|
@ -48,7 +48,7 @@ if not os.path.exists(os.path.join(erpnext_path, 'logs')):
|
||||
# setup lib -- framework repo with read only access
|
||||
# change this if you have your own fork
|
||||
if not os.path.exists(os.path.join(erpnext_path, 'lib')):
|
||||
os.system('git clone git://github.com/webnotes/wnframework.git lib')
|
||||
os.system('git clone https://github.com/webnotes/wnframework.git lib')
|
||||
|
||||
# setup symlinks in public
|
||||
if not os.path.exists(os.path.join(erpnext_path, 'public', 'js', 'lib')):
|
||||
@ -101,12 +101,7 @@ inst.import_from_db(new_dbname, source_path=os.path.join(erpnext_path, 'data', '
|
||||
|
||||
# apply patches
|
||||
os.chdir(erpnext_path)
|
||||
os.system("lib/wnf.py -l")
|
||||
|
||||
# force sync all
|
||||
os.system("lib/wnf.py --sync_all -f")
|
||||
|
||||
os.system("lib/wnf.py --cms")
|
||||
os.system("lib/wnf.py --update origin master")
|
||||
|
||||
# set filemode false
|
||||
os.system("git config core.filemode false")
|
||||
@ -114,11 +109,56 @@ os.chdir(os.path.join(erpnext_path, 'lib'))
|
||||
os.system("git config core.filemode false")
|
||||
|
||||
steps_remaining = """
|
||||
Notes:
|
||||
------
|
||||
|
||||
sample apache conf file
|
||||
#-----------------------------------------------------------
|
||||
SetEnv PYTHON_EGG_CACHE /var/www
|
||||
|
||||
# you can change 99 to any other port
|
||||
|
||||
Listen 99
|
||||
NameVirtualHost *:99
|
||||
<VirtualHost *:99>
|
||||
ServerName localhost
|
||||
DocumentRoot {path to erpnext's folder}/public
|
||||
AddHandler cgi-script .cgi .xml .py
|
||||
|
||||
<Directory {path to erpnext's folder}/public/>
|
||||
# directory specific options
|
||||
Options -Indexes +FollowSymLinks +ExecCGI
|
||||
|
||||
# directory's index file
|
||||
DirectoryIndex web.py
|
||||
|
||||
# rewrite rule
|
||||
RewriteEngine on
|
||||
|
||||
# condition 1:
|
||||
# ignore login-page.html, app.html, blank.html, unsupported.html
|
||||
RewriteCond %{REQUEST_URI} ^((?!app\.html|blank\.html|unsupported\.html).)*$
|
||||
|
||||
# condition 2: if there are no slashes
|
||||
# and file is .html or does not containt a .
|
||||
RewriteCond %{REQUEST_URI} ^(?!.+/)((.+\.html)|([^.]+))$
|
||||
|
||||
# rewrite if both of the above conditions are true
|
||||
RewriteRule ^(.+)$ web.py?page=$1 [NC,L]
|
||||
|
||||
AllowOverride all
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
#-----------------------------------------------------------
|
||||
|
||||
To Do:
|
||||
|
||||
* Configure apache/http conf file to point to public folder
|
||||
* chown recursively all files in your folder to apache user
|
||||
* login using: user="Administrator" and password="admin"
|
||||
|
||||
"""
|
||||
|
||||
print steps_remaining
|
||||
|
@ -252,8 +252,7 @@ wn.re_route={}
|
||||
wn.route=function(){if(wn.re_route[window.location.hash]){var re_route_val=wn.get_route_str(wn.re_route[window.location.hash]);var cur_route_val=wn.get_route_str(wn._cur_route);if(decodeURIComponent(re_route_val)===decodeURIComponent(cur_route_val)){window.history.back();return;}else{window.location.hash=wn.re_route[window.location.hash];}}
|
||||
wn._cur_route=window.location.hash;route=wn.get_route();switch(route[0]){case"List":wn.views.doclistview.show(route[1]);break;case"Form":if(route.length>3){route[2]=route.splice(2).join('/');}
|
||||
wn.views.formview.show(route[1],route[2]);break;case"Report":wn.views.reportview.show(route[1],route[2]);break;case"Report2":wn.views.reportview2.show();break;default:wn.views.pageview.show(route[0]);}}
|
||||
wn.get_route=function(route){if(!wn.boot){return[window.page_name];}
|
||||
return $.map(wn.get_route_str(route).split('/'),function(r){return decodeURIComponent(r);});}
|
||||
wn.get_route=function(route){return $.map(wn.get_route_str(route).split('/'),function(r){return decodeURIComponent(r);});}
|
||||
wn.get_route_str=function(route){if(!route)
|
||||
route=window.location.hash;if(route.substr(0,1)=='#')route=route.substr(1);if(route.substr(0,1)=='!')route=route.substr(1);return route;}
|
||||
wn.set_route=function(){route=$.map(arguments,function(a){return encodeURIComponent(a)}).join('/');window.location.hash=route;wn.app.set_favicon();}
|
||||
@ -310,13 +309,13 @@ if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.sho
|
||||
if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_new_doc:function(new_doctype){new_doc(new_doctype);},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function')
|
||||
this.onrun=a0;if(a0&&a0.callback)
|
||||
this.onrun=a0.callback;if(!a1&&!(a0&&a0.append))
|
||||
this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(a0),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(opts){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1}
|
||||
args.simple_query=this.query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
|
||||
this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(a0),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(opts){if(!this.method){var query=this.get_query?this.get_query():this.query;query=this.add_limits(query);var args={query_max:this.query_max,as_dict:1}
|
||||
args.simple_query=query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
|
||||
if(this.args)
|
||||
$.extend(args,this.args)
|
||||
if(this.get_args){$.extend(args,this.get_args(opts));}
|
||||
return args;},render_results:function(r){if(this.start==0)this.clear();this.$w.find('.btn-more').toggle(false);if(r.message)r.values=r.message;if(r.values&&r.values.length){this.data=this.data.concat(r.values);this.render_list(r.values);this.update_paging(r.values);}else{if(this.start==0){this.$w.find('.result').toggle(false);this.$w.find('.no-result').toggle(true);}}
|
||||
if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}},update_paging:function(values){if(values.length>=this.page_length){this.$w.find('.btn-more').toggle(true);this.start+=this.page_length;}},add_row:function(){return $('<div class="list-row">').appendTo(this.$w.find('.result-list')).get(0);},refresh:function(){this.run();},add_limits:function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);}});
|
||||
if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}},update_paging:function(values){if(values.length>=this.page_length){this.$w.find('.btn-more').toggle(true);this.start+=this.page_length;}},add_row:function(){return $('<div class="list-row">').appendTo(this.$w.find('.result-list')).get(0);},refresh:function(){this.run();},add_limits:function(query){query+=' LIMIT '+this.start+','+(this.page_length+1);return query}});
|
||||
/*
|
||||
* lib/js/wn/ui/filters.js
|
||||
*/
|
||||
@ -390,7 +389,7 @@ wn.views.make_404=function(){var page=wn.container.add_page('404');$(page).html(
|
||||
/*
|
||||
* lib/js/wn/request.js
|
||||
*/
|
||||
wn.provide('wn.request');wn.request.url='index.cgi';wn.request.prepare=function(opts){if(opts.btn)$(opts.btn).set_working();if(opts.show_spinner)set_loading();if(opts.freeze)freeze();if(!opts.args.cmd){console.log(opts)
|
||||
wn.provide('wn.request');wn.request.url='server.py';wn.request.prepare=function(opts){if(opts.btn)$(opts.btn).set_working();if(opts.show_spinner)set_loading();if(opts.freeze)freeze();if(!opts.args.cmd){console.log(opts)
|
||||
throw"Incomplete Request";}}
|
||||
wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(opts.show_spinner)hide_loading();if(opts.freeze)unfreeze();if(wn.boot&&wn.boot.sid&&wn.get_cookie('sid')!=wn.boot.sid){if(!wn.app.logged_out){msgprint('Session Expired. Logging you out');wn.app.logout();}
|
||||
return;}
|
||||
@ -997,7 +996,7 @@ args.label=v[0];args.width=flt(v[1])/max*100;args.count=v[1];args.field=field;$i
|
||||
</div>',args));this.setup_stat_item_click($item);return $item;},reload_stats:function(){this.$page.find('.layout-side-section .stat-wrapper').remove();this.init_stats();},setup_stat_item_click:function($item){var me=this;$item.find('a').click(function(){var fieldname=$(this).attr('data-field');var label=$(this).attr('data-label');me.set_filter(fieldname,label);return false;});},set_filter:function(fieldname,label){var filter=this.filter_list.get_filter(fieldname);if(filter){var v=filter.field.get_value();if(v.indexOf(label)!=-1){return false;}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{filter.set_values(fieldname,'in',v+', '+label);}}}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{this.filter_list.add_filter(fieldname,'=',label);}}
|
||||
this.run();}});wn.views.ListView=Class.extend({init:function(doclistview){this.doclistview=doclistview;this.doctype=doclistview.doctype;var t="`tab"+this.doctype+"`.";this.fields=[t+'name',t+'owner',t+'docstatus',t+'_user_tags',t+'modified'];this.stats=['_user_tags'];this.show_hide_check_column();},columns:[{width:'3%',content:'check'},{width:'4%',content:'avatar'},{width:'3%',content:'docstatus',css:{"text-align":"center"}},{width:'35%',content:'name'},{width:'40%',content:'tags',css:{'color':'#aaa'}},{width:'15%',content:'modified',css:{'text-align':'right','color':'#222'}}],render_column:function(data,parent,opts){var me=this;if(opts.css){$.each(opts.css,function(k,v){$(parent).css(k,v)});}
|
||||
if(opts.content.indexOf&&opts.content.indexOf('+')!=-1){$.map(opts.content.split('+'),function(v){me.render_column(data,parent,{content:v});});return;}
|
||||
if(typeof opts.content=='function'){opts.content(parent,data);}
|
||||
if(typeof opts.content=='function'){opts.content(parent,data,me);}
|
||||
else if(opts.content=='name'){$(parent).append(repl('<a href="#!Form/%(doctype)s/%(name)s">%(name)s</a>',data));}
|
||||
else if(opts.content=='avatar'){$(parent).append(repl('<span class="avatar-small"><img src="%(avatar)s" \
|
||||
title="%(fullname)s"/></span>',data));}
|
||||
@ -1006,12 +1005,7 @@ else if(opts.content=='docstatus'){$(parent).append(repl('<span class="docstatus
|
||||
title="%(docstatus_title)s"></i></span>',data));}
|
||||
else if(opts.content=='tags'){this.add_user_tags(parent,data);}
|
||||
else if(opts.content=='modified'){$(parent).append(data.when);}
|
||||
else if(opts.type=='bar-graph'){args={percent:data[opts.content],fully_delivered:(data[opts.content]>99?'bar-complete':''),label:opts.label}
|
||||
$(parent).append(repl('<span class="bar-outer" style="width: 30px; float: right" \
|
||||
title="%(percent)s% %(label)s">\
|
||||
<span class="bar-inner %(fully_delivered)s" \
|
||||
style="width: %(percent)s%;"></span>\
|
||||
</span>',args));}
|
||||
else if(opts.type=='bar-graph'){this.render_bar_graph(parent,data,opts.content,opts.label);}
|
||||
else if(opts.type=='link'&&opts.doctype){$(parent).append(repl('<a href="#!Form/'+opts.doctype+'/'
|
||||
+data[opts.content]+'">'+data[opts.content]+'</a>',data));}
|
||||
else if(opts.template){$(parent).append(repl(opts.template,data));}
|
||||
@ -1020,7 +1014,12 @@ for(key in data){if(data[key]==null){data[key]='';}}},prepare_when:function(data
|
||||
if(diff==1){data.when='Yesterday'}
|
||||
if(diff==2){data.when='2 days ago'}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){if($(parent).html().length>0){$(parent).append('<br />');}
|
||||
$.each(data._user_tags.split(','),function(i,t){if(t){$('<span class="label label-info" style="cursor: pointer; line-height: 200%">'
|
||||
+strip(t)+'</span>').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}}});wn.provide('wn.views.RecordListView');wn.views.RecordListView=wn.views.DocListView.extend({init:function(doctype,wrapper,ListView){this.doctype=doctype;this.wrapper=wrapper;this.listview=new ListView(this);this.listview.parent=this;this.setup();},setup:function(){var me=this;me.page_length=10;$(me.wrapper).empty();me.init_list();},get_args:function(){var args=this._super();$.each((this.default_filters||[]),function(i,f){args.filters.push(f);});args.docstatus=args.docstatus.concat((this.default_docstatus||[]));return args;},});
|
||||
+strip(t)+'</span>').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}},render_bar_graph:function(parent,data,field,label){var args={percent:data[field],fully_delivered:(data[field]>99?'bar-complete':''),label:label}
|
||||
$(parent).append(repl('<span class="bar-outer" style="width: 30px; float: right" \
|
||||
title="%(percent)s% %(label)s">\
|
||||
<span class="bar-inner %(fully_delivered)s" \
|
||||
style="width: %(percent)s%;"></span>\
|
||||
</span>',args));},render_icon:function(parent,icon_class,label){var icon_html="<i class='%(icon_class)s' title='%(label)s'></i>";$(parent).append(repl(icon_html,{icon_class:icon_class,label:label}));}});wn.provide('wn.views.RecordListView');wn.views.RecordListView=wn.views.DocListView.extend({init:function(doctype,wrapper,ListView){this.doctype=doctype;this.wrapper=wrapper;this.listview=new ListView(this);this.listview.parent=this;this.setup();},setup:function(){var me=this;me.page_length=10;$(me.wrapper).empty();me.init_list();},get_args:function(){var args=this._super();$.each((this.default_filters||[]),function(i,f){args.filters.push(f);});args.docstatus=args.docstatus.concat((this.default_docstatus||[]));return args;},});
|
||||
/*
|
||||
* lib/js/wn/views/formview.js
|
||||
*/
|
||||
@ -1749,7 +1748,7 @@ _f.Frm.prototype.setup_fields_std=function(){var fl=wn.meta.docfield_list[this.d
|
||||
var sec;for(var i=0;i<fl.length;i++){var f=fl[i];if(f.fieldtype=='Section Break'&&fl[i+1]&&fl[i+1].fieldtype=='Section Break')
|
||||
continue;var fn=f.fieldname?f.fieldname:f.label;var fld=make_field(f,this.doctype,this.layout.cur_cell,this);this.fields[this.fields.length]=fld;this.fields_dict[fn]=fld;if(sec&&['Section Break','Column Break'].indexOf(f.fieldtype)==-1){fld.parent_section=sec;sec.fields.push(fld);}
|
||||
if(f.fieldtype=='Section Break'){sec=fld;this.sections.push(fld);}
|
||||
if((f.fieldtype=='Section Break')&&(fl[i+1])&&(fl[i+1].fieldtype!='Column Break')){var c=this.layout.addcell();$y(c.wrapper,{padding:'8px'});}}}
|
||||
if((f.fieldtype=='Section Break')&&(fl[i+1])&&(fl[i+1].fieldtype!='Column Break')&&!f.hidden){var c=this.layout.addcell();$y(c.wrapper,{padding:'8px'});}}}
|
||||
_f.Frm.prototype.add_custom_button=function(label,fn,icon){this.frm_head.appframe.add_button(label,fn,icon);}
|
||||
_f.Frm.prototype.clear_custom_buttons=function(){this.frm_head.refresh_toolbar()}
|
||||
_f.Frm.prototype.add_fetch=function(link_field,src_field,tar_field){if(!this.fetch_dict[link_field]){this.fetch_dict[link_field]={'columns':[],'fields':[]}}
|
||||
@ -1857,13 +1856,14 @@ else{hide_field(fields)}}
|
||||
* lib/js/legacy/widgets/form/form_fields.js
|
||||
*/
|
||||
_f.ColumnBreak=function(){this.set_input=function(){};}
|
||||
_f.ColumnBreak.prototype.make_body=function(){this.cell=this.frm.layout.addcell(this.df.width);$y(this.cell.wrapper,{padding:'8px'});_f.cur_col_break_width=this.df.width;var fn=this.df.fieldname?this.df.fieldname:this.df.label;if(this.df&&this.df.label){this.label=$a(this.cell.wrapper,'div','','',this.df.label);}}
|
||||
_f.ColumnBreak.prototype.refresh=function(layout){var hidden=0;if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])||this.df.hidden){hidden=1;}
|
||||
if(this.set_hidden!=hidden){if(hidden)
|
||||
_f.ColumnBreak.prototype.make_body=function(){if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])||this.df.hidden){return;}
|
||||
this.cell=this.frm.layout.addcell(this.df.width);$y(this.cell.wrapper,{padding:'8px'});_f.cur_col_break_width=this.df.width;var fn=this.df.fieldname?this.df.fieldname:this.df.label;if(this.df&&this.df.label){this.label=$a(this.cell.wrapper,'div','','',this.df.label);}}
|
||||
_f.ColumnBreak.prototype.refresh=function(layout){if(!this.cell)return;if(this.set_hidden!=this.df.hidden){if(this.df.hidden)
|
||||
this.cell.hide();else
|
||||
this.cell.show();this.set_hidden=hidden;}}
|
||||
this.cell.show();this.set_hidden=this.df.hidden;}}
|
||||
_f.SectionBreak=function(){this.fields=[];this.set_input=function(){};this.make_row=function(){this.row=this.df.label?this.frm.layout.addrow():this.frm.layout.addsubrow();}}
|
||||
_f.SectionBreak.prototype.make_body=function(){var me=this;this.make_row();if(this.df.label){if(!this.df.description)
|
||||
_f.SectionBreak.prototype.make_body=function(){var me=this;if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])||this.df.hidden){return;}
|
||||
this.make_row();if(this.df.label){if(!this.df.description)
|
||||
this.df.description='';$(this.row.main_head).html(repl('<div class="form-section-head">\
|
||||
<h3 class="head">%(label)s</h3>\
|
||||
<div class="help small" \
|
||||
@ -1879,8 +1879,7 @@ _f.SectionBreak.prototype.has_data=function(){var me=this;for(var i in me.fields
|
||||
if(f.df.reqd&&!v){return true;}
|
||||
if(f.df.fieldtype=='Table'){if(f.grid.get_children().length||f.df.reqd){return true;}}}
|
||||
return false;}
|
||||
_f.SectionBreak.prototype.refresh=function(from_form){var hidden=0;if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])||this.df.hidden){hidden=1;}
|
||||
if(hidden){if(this.row)this.row.hide();}else{if(this.collapsible){}}}
|
||||
_f.SectionBreak.prototype.refresh=function(from_form){if(this.df.hidden){if(this.row)this.row.hide();}else{if(this.collapsible){}}}
|
||||
_f.ImageField=function(){this.images={};}
|
||||
_f.ImageField.prototype=new Field();_f.ImageField.prototype.onmake=function(){this.no_img=$a(this.wrapper,'div','no_img');this.no_img.innerHTML="No Image";$dh(this.no_img);}
|
||||
_f.ImageField.prototype.get_image_src=function(doc){if(doc.file_list){file=doc.file_list.split(',');extn=file[0].split('.');extn=extn[extn.length-1].toLowerCase();var img_extn_list=['gif','jpg','bmp','jpeg','jp2','cgm','ief','jpm','jpx','png','tiff','jpe','tif'];if(in_list(img_extn_list,extn)){var src=wn.request.url+"?cmd=downloadfile&file_id="+file[1];}}else{var src="";}
|
||||
|
@ -139,8 +139,7 @@ wn.re_route={}
|
||||
wn.route=function(){if(wn.re_route[window.location.hash]){var re_route_val=wn.get_route_str(wn.re_route[window.location.hash]);var cur_route_val=wn.get_route_str(wn._cur_route);if(decodeURIComponent(re_route_val)===decodeURIComponent(cur_route_val)){window.history.back();return;}else{window.location.hash=wn.re_route[window.location.hash];}}
|
||||
wn._cur_route=window.location.hash;route=wn.get_route();switch(route[0]){case"List":wn.views.doclistview.show(route[1]);break;case"Form":if(route.length>3){route[2]=route.splice(2).join('/');}
|
||||
wn.views.formview.show(route[1],route[2]);break;case"Report":wn.views.reportview.show(route[1],route[2]);break;case"Report2":wn.views.reportview2.show();break;default:wn.views.pageview.show(route[0]);}}
|
||||
wn.get_route=function(route){if(!wn.boot){return[window.page_name];}
|
||||
return $.map(wn.get_route_str(route).split('/'),function(r){return decodeURIComponent(r);});}
|
||||
wn.get_route=function(route){return $.map(wn.get_route_str(route).split('/'),function(r){return decodeURIComponent(r);});}
|
||||
wn.get_route_str=function(route){if(!route)
|
||||
route=window.location.hash;if(route.substr(0,1)=='#')route=route.substr(1);if(route.substr(0,1)=='!')route=route.substr(1);return route;}
|
||||
wn.set_route=function(){route=$.map(arguments,function(a){return encodeURIComponent(a)}).join('/');window.location.hash=route;wn.app.set_favicon();}
|
||||
@ -197,13 +196,13 @@ if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.sho
|
||||
if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_new_doc:function(new_doctype){new_doc(new_doctype);},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function')
|
||||
this.onrun=a0;if(a0&&a0.callback)
|
||||
this.onrun=a0.callback;if(!a1&&!(a0&&a0.append))
|
||||
this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(a0),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(opts){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1}
|
||||
args.simple_query=this.query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
|
||||
this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(a0),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(opts){if(!this.method){var query=this.get_query?this.get_query():this.query;query=this.add_limits(query);var args={query_max:this.query_max,as_dict:1}
|
||||
args.simple_query=query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
|
||||
if(this.args)
|
||||
$.extend(args,this.args)
|
||||
if(this.get_args){$.extend(args,this.get_args(opts));}
|
||||
return args;},render_results:function(r){if(this.start==0)this.clear();this.$w.find('.btn-more').toggle(false);if(r.message)r.values=r.message;if(r.values&&r.values.length){this.data=this.data.concat(r.values);this.render_list(r.values);this.update_paging(r.values);}else{if(this.start==0){this.$w.find('.result').toggle(false);this.$w.find('.no-result').toggle(true);}}
|
||||
if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}},update_paging:function(values){if(values.length>=this.page_length){this.$w.find('.btn-more').toggle(true);this.start+=this.page_length;}},add_row:function(){return $('<div class="list-row">').appendTo(this.$w.find('.result-list')).get(0);},refresh:function(){this.run();},add_limits:function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);}});
|
||||
if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}},update_paging:function(values){if(values.length>=this.page_length){this.$w.find('.btn-more').toggle(true);this.start+=this.page_length;}},add_row:function(){return $('<div class="list-row">').appendTo(this.$w.find('.result-list')).get(0);},refresh:function(){this.run();},add_limits:function(query){query+=' LIMIT '+this.start+','+(this.page_length+1);return query}});
|
||||
/*
|
||||
* lib/js/wn/ui/filters.js
|
||||
*/
|
||||
@ -277,7 +276,7 @@ wn.views.make_404=function(){var page=wn.container.add_page('404');$(page).html(
|
||||
/*
|
||||
* lib/js/wn/request.js
|
||||
*/
|
||||
wn.provide('wn.request');wn.request.url='index.cgi';wn.request.prepare=function(opts){if(opts.btn)$(opts.btn).set_working();if(opts.show_spinner)set_loading();if(opts.freeze)freeze();if(!opts.args.cmd){console.log(opts)
|
||||
wn.provide('wn.request');wn.request.url='server.py';wn.request.prepare=function(opts){if(opts.btn)$(opts.btn).set_working();if(opts.show_spinner)set_loading();if(opts.freeze)freeze();if(!opts.args.cmd){console.log(opts)
|
||||
throw"Incomplete Request";}}
|
||||
wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(opts.show_spinner)hide_loading();if(opts.freeze)unfreeze();if(wn.boot&&wn.boot.sid&&wn.get_cookie('sid')!=wn.boot.sid){if(!wn.app.logged_out){msgprint('Session Expired. Logging you out');wn.app.logout();}
|
||||
return;}
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,7 +0,0 @@
|
||||
|
||||
/*
|
||||
* erpnext/website/js/product_category.js
|
||||
*/
|
||||
erpnext.make_product_categories=function(wrapper){wrapper.category_list=new wn.ui.Listing({parent:$(wrapper).find('.more-categories').get(0),query:'select count(name) as items, item_group \
|
||||
from tabItem where is_sales_item="Yes" \
|
||||
group by item_group order by items desc',hide_refresh:true,render_row:function(parent,data){parent.innerHTML=repl('<a href="#!products/%(item_group)s">%(item_group)s</a> (%(items)s)',data);}});wrapper.category_list.run();}
|
@ -27,8 +27,12 @@ sys.path.append('../lib/py')
|
||||
import webnotes
|
||||
import webnotes.auth
|
||||
|
||||
import conf
|
||||
sys.path.append(conf.modules_path)
|
||||
|
||||
if __name__=='__main__':
|
||||
webnotes.http_request = webnotes.auth.HTTPRequest()
|
||||
# webnotes.http_request = webnotes.auth.HTTPRequest()
|
||||
webnotes.connect()
|
||||
from webnotes.cms import feed
|
||||
try:
|
||||
print 'Content-Type: text/xml'
|
||||
|
79
public/web.py
Executable file
79
public/web.py
Executable file
@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""
|
||||
return a dynamic page from website templates
|
||||
|
||||
all html pages except login-page.html get generated here
|
||||
"""
|
||||
|
||||
import cgi, cgitb, os, sys
|
||||
cgitb.enable()
|
||||
|
||||
# import libs
|
||||
sys.path.append('..')
|
||||
import conf
|
||||
sys.path.append('../lib/py')
|
||||
sys.path.append(conf.modules_path)
|
||||
|
||||
def init():
|
||||
import webnotes
|
||||
webnotes.form = cgi.FieldStorage(keep_blank_values=True)
|
||||
for key in webnotes.form.keys():
|
||||
webnotes.form_dict[key] = webnotes.form.getvalue(key)
|
||||
webnotes.connect()
|
||||
|
||||
def respond():
|
||||
import webnotes
|
||||
try:
|
||||
if 'page' in webnotes.form_dict:
|
||||
html = get_html(webnotes.form_dict['page'])
|
||||
else:
|
||||
# show home page
|
||||
html = get_html('index')
|
||||
except Exception, e:
|
||||
html = get_html('404')
|
||||
|
||||
print "Content-Type: text/html"
|
||||
print
|
||||
print html.encode('utf-8')
|
||||
|
||||
def get_html(page_name):
|
||||
import website.utils
|
||||
page_name = website.utils.scrub_page_name(page_name)
|
||||
|
||||
comments = get_comments(page_name)
|
||||
|
||||
import website.web_cache
|
||||
html = website.web_cache.get_html(page_name, comments)
|
||||
|
||||
return html
|
||||
|
||||
def get_comments(page_name):
|
||||
import webnotes
|
||||
|
||||
if page_name == '404':
|
||||
comments = """error: %s""" % webnotes.getTraceback()
|
||||
else:
|
||||
comments = """page: %s""" % page_name
|
||||
|
||||
return comments
|
||||
|
||||
if __name__=="__main__":
|
||||
init()
|
||||
respond()
|
Loading…
x
Reference in New Issue
Block a user