fix to product, blog

This commit is contained in:
Rushabh Mehta 2012-02-07 14:31:49 +05:30
parent 8ebf4e27ef
commit f9620eaf44
17 changed files with 99 additions and 11 deletions

View File

@ -34,8 +34,8 @@ feed_dict = {
'Support Ticket': ['[%(status)s] %(subject)s', '#000080'],
# Website
'Web Page': ['%(title)s', '#00080'],
'Blog': ['%(title)s', '#00080']
'Web Page': ['%(title)s', '#000080'],
'Blog': ['%(title)s', '#000080']
}
def make_feed(feedtype, doctype, name, owner, subject, color):

View File

@ -12,6 +12,7 @@ def execute():
delete_doc('Website', 'Module Def', 'Website')
reload_doc('website', 'Module Def', 'Website')
reload_doc('website', 'Role', 'Website Manager')
reload_doc('website', 'Role', 'Blogger')
webnotes.conn.sql("""delete from `tabModule Def Role` where parent='Website'""")
d = Document('Module Def Role')

View File

@ -0,0 +1,26 @@
# Role, Blogger
[
# These values are common in all dictionaries
{
'creation': '2012-01-27 12:22:24',
'docstatus': 0,
'modified': '2012-01-27 12:22:24',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Role
{
'doctype': 'Role',
'module': u'Website',
'name': '__common__',
'role_name': u'Blogger'
},
# Role, Blogger
{
'doctype': 'Role',
'name': u'Blogger'
}
]

View File

@ -18,6 +18,7 @@ class DocType():
def validate(self):
"""write/update 'Page' with the blog"""
p = website.utils.add_page(self.doc.title)
self.doc.name = p.name
from jinja2 import Template
import markdown2

View File

@ -5,21 +5,23 @@
{
'creation': '2012-01-27 12:24:03',
'docstatus': 0,
'modified': '2012-02-07 12:59:01',
'modified': '2012-02-07 13:55:17',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1327647244',
'_last_update': u'1328599743',
'allow_attach': 1,
'colour': u'White:FFF',
'doctype': 'DocType',
'max_attachments': 5,
'module': u'Website',
'name': '__common__',
'section_style': u'Simple',
'show_in_menu': 0,
'version': 2
'version': 3
},
# These values are common for all DocField
@ -106,5 +108,17 @@
'fieldtype': u'Text',
'label': u'Preview',
'permlevel': 1
},
# 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
}
]

View File

@ -14,6 +14,7 @@ class DocType:
import markdown2
import os
self.doc.item_group = webnotes.conn.get_value('Item', self.doc.item, 'item_group')
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:
@ -26,14 +27,15 @@ class DocType:
website.utils.add_guest_access_to_page(p.name)
self.doc.page_name = p.name
del self.doc.fields['long_description_html']
self.make_item_group_active()
del self.doc.fields['long_description_html']
del self.doc.fields['item_group']
def make_item_group_active(self):
"""show item group in website"""
if self.doc.published:
from webnotes.model.doc import Document
ig = Document('Item Group', webnotes.conn.get_value('Item', self.doc.item, 'item_group'))
ig = Document('Item Group', self.doc.item_group)
ig.show_in_website = 1
ig.save()

View File

@ -1,6 +1,8 @@
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() {
@ -9,5 +11,37 @@ pscript["onload_{{ doc.page_name }}"] = function(wrapper) {
My contact details are:\n\nThank you!\
");
})
})
});
// similar products
wrapper.similar = new wn.widgets.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();
}

View File

@ -22,6 +22,10 @@
</div>
<br>
<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>

View File

@ -3,7 +3,7 @@ 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),
parent: $(wrapper).find('.more-categories').get(0),
query: 'select label, count(t2.name) as items, t1.item_group \
from `tabProduct Group` t1, `tabProduct` t2, tabItem t3\
where t1.parent="Products Settings" \

View File

@ -7,6 +7,7 @@
</div>
<div class="web-side-section">
<h3>Categories</h3>
<div class="more-categories"></div>
</div>
<div style="clear:both;">
</div>

View File

@ -70,7 +70,6 @@ erpnext.products.make_product_list = function(wrapper) {
<div style="clear: both; margin-bottom: 15px; border-bottom: 1px solid #AAA"></div>', data);
}
});
}
erpnext.products.set_group = function() {

View File

@ -1 +1 @@
360
361

6
wnf.py
View File

@ -52,6 +52,8 @@ def setup_options():
help="Apply the patches on given db")
parser.add_option('--reload_doc', nargs=3, metavar = "module doctype docname",
help="reload doc")
parser.add_option('--export_doc', nargs=2, metavar = "doctype docname",
help="export doc")
return parser.parse_args()
@ -121,6 +123,10 @@ def run():
{"module":options.reload_doc[0], "dt":options.reload_doc[1], "dn":options.reload_doc[2]})
print '\n'.join(webnotes.modules.patch_handler.log_list)
elif options.export_doc:
from webnotes.modules import export_doc
export_doc(options.export_doc[0], options.export_doc[1])
# run all pending
elif options.run_latest:
webnotes.modules.patch_handler.run_all()