added products, custom pages and footer

This commit is contained in:
Rushabh Mehta 2012-01-31 18:01:16 +05:30
parent bc5ec4f19e
commit ab1148cbc9
29 changed files with 835 additions and 156 deletions

View File

@ -477,10 +477,6 @@ FeedList.prototype.make_list = function() {
});
}
FeedList.prototype.after_run = function() {
this.list.has_data() ? $dh(this.no_result) : $ds(this.no_result)
}
FeedList.prototype.render_feed = function(parent, data) {
new FeedItem(parent, data, this);
}

View File

@ -41,7 +41,8 @@ def boot_session(bootinfo):
if webnotes.session['user']=='Guest':
bootinfo['topbar'] = webnotes.model.doc.getsingle('Top Bar Settings')
bootinfo['topbaritems'] = webnotes.conn.sql("""select label, std_page, custom_page, parent_label
bootinfo['topbaritems'] = webnotes.conn.sql("""select label, std_page, custom_page,
parent_label, parentfield
from `tabTop Bar Item` where parent='Top Bar Settings' order by idx asc""", as_dict=1)
else:
bootinfo['letter_heads'] = get_letter_heads()

View File

@ -266,11 +266,14 @@ SidebarItem.prototype.show_items = function() {
SidebarItem.prototype.show_section = function(sec_type) {
var me = this;
var label = this.det.module_label + ' ' + sec_type;
var type_map = {'Reports':'Reports', 'Custom Reports':'Custom Reports', 'Pages':'Tools', 'Single DocType':'Tools', 'Setup Forms':'Tools'}
var type_map = {'Reports':'Reports', 'Custom Reports':'Custom Reports',
'Pages':'Tools', 'Single DocType':'Tools', 'Setup Forms':'Tools'}
if(page_body.pages[label]) {
loadpage(label, null, 1);
} else {
// make the reports page
var page = page_body.add_page(label);
this.wrapper = $a(page,'div','layout_wrapper');
@ -373,3 +376,6 @@ pscript.startup_set_module_order = function() {
$c_obj('Home Control', 'get_module_order', '', callback)
}

View File

@ -0,0 +1,36 @@
// Tools Page
erpnext.ListPage = Class.extend({
init: function(opts) {
var me = this;
this.opts = opts;
this.page = page_body.add_page[opts.title];
this.page.wrapper = $a(this.page, 'div', 'layout_wrapper');
this.page.head = new PageHeading(this.wrapper, this.title)
this.page.list = new wn.widgets.Listing({
parent: this.page.wrapper,
query: opts.query,
render:row: opts.render_row
});
},
show: function() {
if(this.first) {
this.page.list.run();
this.first = false;
}
page_body.change_to(this.opts.title);
}
});
erpnext.ToolsPage = erpnext.ListPage.extend({
init: function(opts) {
this._super({
title: opts.module + ' Settings',
query: repl('select name, description from tabDocType where \
module=%(module)s and ifnull(issingle,0)=1 order by name asc', opts),
render_row: function(parent, data) {
parent.innerHTML = repl('<a href="#!Form/%(name)s/%(name)s">%(name)s</a>\
<div class="comment">%(description)s</div>', data)
}
})
}
});

View File

@ -28,12 +28,12 @@ erpnext.startup.start = function() {
wn.require('erpnext/startup/toolbar.js');
erpnext.toolbar.setup();
wn.require('erpnext/startup/feature_setup.js');
}
// border to the body
// ------------------
$('footer').html('<div class="erpnext-footer">\
Powered by <a href="https://erpnext.com">ERPNext</a></div>');
}
$('#startup_div').toggle(false);
}

View File

@ -5,14 +5,14 @@
{
'creation': '2010-08-08 17:09:05',
'docstatus': 0,
'modified': '2012-01-30 12:10:37',
'modified': '2012-01-30 16:46:37',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1327904359',
'_last_update': '1327905637',
'allow_attach': 1,
'allow_trash': 1,
'autoname': 'field:item_code',
@ -29,7 +29,7 @@
'show_in_menu': 0,
'subject': '%(item_name)s',
'tag_fields': 'item_group',
'version': 164
'version': 165
},
# These values are common for all DocField
@ -493,98 +493,6 @@
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'label': 'Website Details',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Check here to show this item on your website under "Products"',
'doctype': 'DocField',
'fieldname': 'show_in_website',
'fieldtype': 'Check',
'label': 'Show in website',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Small image shown in listings (100px width) (Attach first)',
'doctype': 'DocField',
'fieldname': 'thumbnail_image',
'fieldtype': 'Select',
'label': 'Thumbnail Image',
'options': 'attach_files:',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Small image shown product page (300px width) (Attach first)',
'doctype': 'DocField',
'fieldname': 'full_image',
'fieldtype': 'Select',
'label': 'Full Image',
'options': 'attach_files:',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Price list for your website (leave blank if you do not want to show the price)',
'doctype': 'DocField',
'fieldname': 'website_price_list',
'fieldtype': 'Link',
'label': 'Website Price List',
'options': 'Price List',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Enter your shipping warehouse if you want "In Stock" or "Out of Stock" to appear on your website',
'doctype': 'DocField',
'fieldname': 'website_warehouse',
'fieldtype': 'Link',
'label': 'Website Warehouse',
'options': 'Warehouse',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Detailed description of your product for your website. Formatted in html/markdown format.',
'doctype': 'DocField',
'fieldname': 'website_description',
'fieldtype': 'Code',
'label': 'Website Description',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',

View File

@ -5,7 +5,7 @@
{
'creation': '2012-01-23 17:05:32',
'docstatus': 0,
'modified': '2012-01-30 12:19:11',
'modified': '2012-01-31 15:19:28',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
@ -52,6 +52,22 @@
'doctype': 'Module Def Item'
},
# Module Def Item
{
'display_name': 'Web Page',
'doc_name': 'Web Page',
'doc_type': 'Forms',
'doctype': 'Module Def Item'
},
# Module Def Item
{
'display_name': 'Product',
'doc_name': 'Product',
'doc_type': 'Forms',
'doctype': 'Module Def Item'
},
# Module Def Item
{
'display_name': 'Blog',

View File

@ -3,6 +3,10 @@
margin: auto;
}
footer {
width: 900px;
margin: auto;
}
header .topbar .container {
width: 900px;
margin: auto;
@ -26,3 +30,41 @@ header .topbar .container {
color: #606060;
overflow-x: hidden;
}
.web-footer {
text-align: center;
color: #777;
margin: 10px;
line-height: 1.7;
}
.web-footer div, .web-footer a {
font-size: 11px;
}
.web-footer-menu {
margin-bottom: 7px;
}
.web-footer a, .web-footer a:visited {
color: #777;
}
.web-footer a:hover {
background-color: #777;
color: #fff;
}
.web-footer-menu ul {
list-style: none;
margin: 0px;
}
.web-footer-menu ul li {
display: inline;
padding: 2px 15px;
border-right: 1px solid #999;
}
.web-footer-menu ul li:last-child {
border-right: 0px solid #777;
}

View File

@ -5,6 +5,7 @@ naming for same name files: file.gif, file-1.gif, file-2.gif etc
"""
import webnotes
import website.utils
class DocType():
def __init__(self, d, dl):
@ -12,27 +13,11 @@ class DocType():
def autoname(self):
"""save file by its name"""
import re
self.doc.name = re.sub('[~!@#$%^&*()<>,."\']', '', self.doc.title.lower())
self.doc.name = '-'.join(self.doc.name.split()[:4])
if webnotes.conn.sql("""select name from tabBlog where name=%s""", self.doc.name) or \
webnotes.conn.sql("""select name from tabPage where name=%s""", self.doc.name):
webnotes.msgprint("Another page with similar title exists, please change the title",\
raise_exception=1)
self.doc.name = website.utils.page_name(self.doc.title)
def on_update(self):
"""write/update 'Page' with the blog"""
from webnotes.model.doc import Document
if webnotes.conn.sql("""select name from tabPage where name=%s""", self.doc.name):
p = Document('Page', self.doc.name)
else:
p = Document('Page')
p.title = self.doc.title
p.name = p.page_name = self.doc.name
p.module = 'Website'
p.standard = 'No'
p = website.utils.add_page(self.doc.title)
from jinja2 import Template
import markdown2
@ -48,11 +33,6 @@ class DocType():
p.save()
# add guest access
if not webnotes.conn.sql("""select parent from `tabPage Role`
where role='Guest' and parent=%s""", self.doc.name):
d = Document('Page Role')
d.parent = self.doc.name
d.role = 'Guest'
d.save()
website.utils.add_guest_access_to_page(p.name)

View File

@ -0,0 +1,6 @@
$.extend(cur_frm.cscript, {
onload: function() {
cur_frm.add_fetch('item', 'description', 'short_description');
cur_frm.add_fetch('item', 'item_name', 'title');
}
});

View File

@ -0,0 +1,27 @@
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def validate(self):
"""make page for this product"""
import website.utils
p = website.utils.add_page("Product " + self.doc.title)
from jinja2 import Template
import markdown2
import os
self.doc.long_description_html = markdown2.markdown(self.doc.long_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)
self.doc.page_name = p.name
del self.doc.fields['long_description_html']

View File

@ -0,0 +1,251 @@
# DocType, Product
[
# These values are common in all dictionaries
{
'creation': '2012-01-30 16:21:29',
'docstatus': 0,
'modified': '2012-01-31 13:46:23',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1327995660',
'allow_attach': 1,
'autoname': 'field:item',
'colour': 'White:FFF',
'description': 'A Product is shown on the website and is linked to an item.',
'doctype': 'DocType',
'max_attachments': 5,
'module': 'Website',
'name': '__common__',
'section_style': 'Simple',
'show_in_menu': 0,
'version': 10
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Product',
'parentfield': 'fields',
'parenttype': 'DocType'
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Product',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1,
'role': 'Website Manager'
},
# DocType, Product
{
'doctype': 'DocType',
'name': 'Product'
},
# DocPerm
{
'create': 1,
'doctype': 'DocPerm',
'permlevel': 0,
'write': 1
},
# DocPerm
{
'doctype': 'DocPerm',
'permlevel': 1
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'item',
'fieldtype': 'Link',
'label': 'Item',
'options': 'Item',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'title',
'fieldtype': 'Link',
'label': 'Title',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'published',
'fieldtype': 'Check',
'label': 'Published',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Select Price List for the web. Leave blank to hide price.',
'doctype': 'DocField',
'fieldname': 'price_list',
'fieldtype': 'Link',
'label': 'Price List',
'options': 'Price List',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Select shipping warehouse to show "In Stock" or "Out of Stock". To hide, leave blank',
'doctype': 'DocField',
'fieldname': 'warehouse',
'fieldtype': 'Link',
'label': 'Warehouse',
'options': 'Warehouse',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Image for listing (Width: 100px) (Attach First)',
'doctype': 'DocField',
'fieldname': 'thumbnail_image',
'fieldtype': 'Select',
'label': 'Thumbnail Image',
'options': 'attach_files:',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Image for listing (Width: 300px) (Attach First)',
'doctype': 'DocField',
'fieldname': 'full_image',
'fieldtype': 'Select',
'label': 'Full Image',
'options': 'attach_files:',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'short_description',
'fieldtype': 'Text',
'label': 'Short Description',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Full description (formatted as markdown)',
'doctype': 'DocField',
'fieldname': 'long_description',
'fieldtype': 'Code',
'label': 'Long Description',
'permlevel': 0,
'reqd': 0
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'page_name',
'fieldtype': 'Data',
'label': 'Page Name',
'permlevel': 1
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'price',
'fieldtype': 'Currency',
'hidden': 0,
'label': 'Price',
'permlevel': 1
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'sales',
'fieldtype': 'Currency',
'label': 'Sales',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'stock',
'fieldtype': 'Currency',
'label': 'Stock',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'currency',
'fieldtype': 'Link',
'label': 'Currency',
'options': 'Currency',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'file_list',
'fieldtype': 'Text',
'hidden': 1,
'label': 'File List',
'no_copy': 1,
'permlevel': 0,
'print_hide': 1
}
]

View File

@ -0,0 +1,13 @@
wn.require('erpnext/website/js/product_category.js');
pscript["onload_{{ doc.page_name }}"] = function(wrapper) {
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!\
");
})
})
}

View File

@ -0,0 +1,28 @@
<div class="layout_wrapper">
<div class="web-content" id="content-product-{{ doc.name }}">
<h1>{{ doc.title }}</h1>
<div class="web-main-section">
<div style="float: left;">
<image src="files/{{ doc.full_image }}" style="width: 300px;
margin-left: 15px;" />
{{ 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="web-side-section">
<div class="info-box round">
<p><b>Item Code:</b> {{ doc.item }}</p>
<p>{{ doc.short_description }}</p>
<p><button class="btn primary product-inquiry"
data-product="{{ doc.name }}"
data-description="{{ doc.short_description }}">Send Inquiry</button>
</p>
</div>
<br>
<h4>More Categories</h4>
</div>
<div style="clear: both"></div>
</div>
</div>

View File

@ -0,0 +1,15 @@
import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def on_update(self):
tmp = None
for d in self.doclist:
if d.doctype=="Product Group":
import json
tmp = json.dumps({"item_group": d.item_group, "label":d.label})
break
webnotes.conn.set_default("default_product_category", tmp)

View File

@ -5,7 +5,7 @@
{
'creation': '2012-01-24 10:24:19',
'docstatus': 0,
'modified': '2012-01-24 10:24:19',
'modified': '2012-01-30 14:14:48',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
@ -19,7 +19,7 @@
'name': '__common__',
'section_style': 'Simple',
'show_in_menu': 0,
'version': 1
'version': 2
},
# These values are common for all DocField
@ -52,7 +52,7 @@
'fieldname': 'std_page',
'fieldtype': 'Select',
'label': 'Std Page',
'options': 'Home\nAbout\nContact\nProduct\nCustomer\nBlog\nPartner\nCareer\nCustom'
'options': 'Home\nAbout\nContact\nProducts\nBlog\nCustom'
},
# DocField

View File

@ -5,14 +5,14 @@
{
'creation': '2012-01-24 10:21:41',
'docstatus': 0,
'modified': '2012-01-24 10:45:02',
'modified': '2012-01-31 15:55:34',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1327380941',
'_last_update': '1327382102',
'allow_attach': 1,
'colour': 'White:FFF',
'doctype': 'DocType',
@ -23,7 +23,7 @@
'name': '__common__',
'section_style': 'Simple',
'show_in_menu': 0,
'version': 3
'version': 4
},
# These values are common for all DocField
@ -67,6 +67,13 @@
'role': 'Website Manager'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'label': 'Top Bar'
},
# DocField
{
'colour': 'White:FFF',
@ -86,6 +93,38 @@
'options': 'Top Bar Item'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'label': 'Footer'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'address',
'fieldtype': 'Text',
'label': 'Address'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'copyright',
'fieldtype': 'Data',
'label': 'Copyright'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'footer_items',
'fieldtype': 'Table',
'label': 'Footer Items',
'options': 'Top Bar Item'
},
# DocField
{
'doctype': 'DocField',

View File

@ -0,0 +1,13 @@
<div class="layout_wrapper">
<div class="web-content" id="content-{{ doc.name }}">
<h1>{{ doc.title }}</h1>
<br>
<div class="web-main-section">
{{ doc.main_section_html }}
</div>
<div class="web-side-section">
{{ doc.side_section_html }}
</div>
<div style="clear: both"></div>
</div>
</div>

View File

@ -0,0 +1,30 @@
import webnotes
import website.utils
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def autoname(self):
"""name from title"""
self.doc.name = website.utils.page_name(self.doc.title)
def validate(self):
"""make page for this product"""
p = website.utils.add_page(self.doc.title)
from jinja2 import Template
import os
website.utils.markdown(self.doc, ['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.save()
website.utils.add_guest_access_to_page(p.name)
del self.doc.fields['main_section_html']
del self.doc.fields['side_section_html']

View File

@ -0,0 +1,110 @@
# DocType, Web Page
[
# These values are common in all dictionaries
{
'creation': '2012-01-31 15:18:49',
'docstatus': 0,
'modified': '2012-01-31 15:48:50',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1328003330',
'allow_attach': 1,
'colour': 'White:FFF',
'description': 'A custom page is a simple page with the layout - headline, main section, side section\n\nEditing:\n\n- Editing is in [markdown format](http://daringfireball.net/projects/markdown/syntax)\n- You can also add images and embed html code\n\nAccessing the page:\n\n- The page can be accessed as #![page-name] after the main url\n\nIdeal for pages like FAQ, Terms, Help etc.\n\n',
'doctype': 'DocType',
'max_attachments': 5,
'module': 'Website',
'name': '__common__',
'section_style': 'Simple',
'show_in_menu': 0,
'version': 3
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Web Page',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Web Page',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1,
'role': 'Website Manager'
},
# DocType, Web Page
{
'doctype': 'DocType',
'name': 'Web Page'
},
# DocPerm
{
'create': 1,
'doctype': 'DocPerm',
'permlevel': 0,
'write': 1
},
# DocPerm
{
'doctype': 'DocPerm',
'permlevel': 1
},
# DocField
{
'colour': 'White:FFF',
'description': 'Title / headline of your page',
'doctype': 'DocField',
'fieldname': 'title',
'fieldtype': 'Data',
'label': 'Title',
'reqd': 1
},
# DocField
{
'colour': 'White:FFF',
'description': 'Content in markdown format that appears on the main side of your page',
'doctype': 'DocField',
'fieldname': 'main_section',
'fieldtype': 'Code',
'label': 'Main Section'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Content in markdown format that appears on the right side',
'doctype': 'DocField',
'fieldname': 'side_section',
'fieldtype': 'Code',
'label': 'Side Section'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'file_list',
'fieldtype': 'Text',
'hidden': 1,
'label': 'File List',
'no_copy': 1,
'print_hide': 1
}
]

View File

@ -0,0 +1,22 @@
// make sidelisting of categories
erpnext.product_item_group = {}
erpnext.make_product_categories = function(wrapper) {
wrapper.category_list = new wn.widgets.Listing({
parent: $(wrapper).find('.web-side-section').get(0),
query: 'select label, count(t2.name) as items, t1.item_group \
from `tabProduct Group` t1, `tabItem` t2\
where t1.parent="Products Settings" \
and t2.item_group = t1.item_group \
and ifnull(t2.show_in_website, 0)=1 \
group by t2.item_group \
order by t1.idx desc',
hide_refresh: true,
render_row: function(parent, data) {
parent.innerHTML = repl('<a href="#!products/%(label)s">%(label)s</a> (%(items)s)',
data);
erpnext.product_item_group[data.label] = data.item_group;
}
});
wrapper.category_list.run();
}

View File

@ -35,8 +35,8 @@ erpnext.topbar.TopBar = Class.extend({
var items = wn.boot.topbaritems
for(var i=0;i<items.length;i++) {
var item = items[i];
if(!item.parent_label) {
item.route = item.std_page.toLowerCase();
if(!item.parent_label && item.parentfield=='top_bar_items') {
item.route = item.std_page ? item.std_page.toLowerCase() : item.custom_page;
$('header .nav:first').append(repl('<li><a href="#!%(route)s" \
data-label="%(label)s">%(label)s</a></li>', item))
}
@ -45,3 +45,30 @@ erpnext.topbar.TopBar = Class.extend({
});
erpnext.topbar.topbar = new erpnext.topbar.TopBar();
// footer
erpnext.Footer = Class.extend({
init: function() {
$('footer').html(repl('<div class="web-footer">\
<div class="web-footer-menu"><ul></ul></div>\
<div class="web-footer-address">%(address)s</div>\
<div class="web-footer-copyright">&copy; %(copyright)s</div>\
<div class="web-footer-powered">Powered by \
<a href="https://erpnext.com">erpnext.com</a></div>\
</div>', wn.boot.topbar));
this.make_items();
},
make_items: function() {
var items = wn.boot.topbaritems
for(var i=0;i<items.length;i++) {
var item = items[i];
if(!item.parent_label && item.parentfield=='footer_items') {
item.route = item.std_page ? item.std_page.toLowerCase() : item.custom_page;
$('.web-footer-menu ul').append(repl('<li><a href="#!%(route)s" \
data-label="%(label)s">%(label)s</a></li>', item))
}
}
}
});
erpnext.footer = new erpnext.Footer();

View File

@ -1,6 +1,6 @@
<div class="layout_wrapper" id="content-products">
<div class="web-main-section">
<h2 class="products-category"></h2>
<h1 class="products-category"></h1>
<div class="products-search">
<input name="products-search" /><button class="btn">Search</button>
</div>
@ -8,4 +8,5 @@
<div class="web-side-section">
<h3>Categories</h3>
</div>
<div style="clear:both;">
</div>

View File

@ -1,11 +1,84 @@
erpnext.products = {}
wn.require('erpnext/website/js/product_category.js');
pscript.onload_products = function(wrapper) {
// get erpnext.products.default_category
sys_defaults.default_product_category = JSON.parse(sys_defaults.default_product_category);
erpnext.products.wrapper = wrapper;
// make search box
// make lists
erpnext.make_product_categories(wrapper);
erpnext.products.make_product_list(wrapper);
// make main listing based on default category
// button
$(wrapper).find('.products-search .btn').click(function() {
wrapper.mainlist.run();
});
// make sidelisting of categories
$(wrapper).find('.products-search input').keypress(function(ev) {
if(ev.which==13) $(wrapper).find('.products-search .btn').click();
});
}
pscript.onshow_products = function(wrapper) {
// show default product category
erpnext.products.set_group();
}
erpnext.products.get_group = function() {
var route = window.location.hash.split('/');
if(route.length>1) {
// from url
var grp = erpnext.product_item_group[route[1]];
var label = route[1];
} else {
// default
var grp = sys_defaults.default_product_category.item_group;
var label = sys_defaults.default_product_category.label;
}
erpnext.products.cur_group = grp;
return {grp:grp, label:label};
}
erpnext.products.make_product_list = function(wrapper) {
wrapper.mainlist = new wn.widgets.Listing({
parent: $(wrapper).find('.web-main-section').get(0),
run_btn: $(wrapper).find('.products-search .btn').get(0),
hide_refresh: true,
get_query: function() {
args = {
searchstr: $('input[name="products-search"]').val() || '',
cat: erpnext.products.cur_group
};
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 t2.item_group="%(cat)s" \
and t1.short_description like "%%(searchstr)s%"', args)
},
render_row: function(parent, data) {
parent.innerHTML = repl('<div style="float:left; width: 115px;">\
<img src="files/%(thumbnail_image)s" style="width:100px;"></div>\
<div style="float:left; width: 400px">\
<b><a href="#!%(page_name)s">%(title)s</a></b>\
<p>%(short_description)s</p></div>\
<div style="clear: both; margin-bottom: 7px;"></div>', data);
}
});
}
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();
}

View File

@ -1,14 +1,53 @@
import webnotes
from webnotes.model.doc import Document
def make_template(doc, path, convert_fields = ['main_section', 'side_section']):
"""make template"""
import os, jinja2, markdown2
import os, jinja2
# markdown
for f in convert_fields:
doc.fields[f + '_html'] = markdown2.markdown(doc.fields[f] or '', \
extras=["wiki-tables"])
markdown(doc, convert_fields)
# write template
with open(path, 'r') as f:
temp = jinja2.Template(f.read())
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 re
name = re.sub('[~!@#$%^&*()<>,."\']', '', title.lower())
return '-'.join(name.split()[:4])
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()

View File

@ -3,7 +3,7 @@
<meta charset="utf-8">
<title>ERPNext</title>
<meta name="author" content="">
<script type="text/javascript">window._version_number="249";
<script type="text/javascript">window._version_number="276";
/*
* lib/js/wn/class.js

View File

@ -1 +1 @@
249
276