remove website route, wip

This commit is contained in:
Rushabh Mehta 2014-08-18 17:50:56 +05:30
parent 13313b5cb6
commit 74bc2baa1d
3 changed files with 21 additions and 40 deletions

View File

@ -9,22 +9,16 @@ from frappe.website.website_generator import WebsiteGenerator
from frappe.website.render import clear_cache
from frappe.website.doctype.website_slideshow.website_slideshow import get_slideshow
condition_field = "show_in_website"
template = "templates/generators/item_group.html"
class ItemGroup(NestedSet, WebsiteGenerator):
nsm_parent_field = 'parent_item_group'
condition_field = "show_in_website"
template = "templates/generators/item_group.html"
parent_website_route_field = "parent_item_group"
def autoname(self):
self.name = self.item_group_name
def validate(self):
WebsiteGenerator.validate(self)
if not self.parent_website_route:
if frappe.db.get_value("Item Group", self.parent_item_group, "show_in_website"):
self.parent_website_route = frappe.get_website_route("Item Group",
self.parent_item_group)
def on_update(self):
NestedSet.on_update(self)
WebsiteGenerator.on_update(self)
@ -60,14 +54,16 @@ def get_product_list_for_group(product_group=None, start=0, limit=10):
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(product_group)])
# base query
query = """select t1.name, t1.item_name, t1.page_name, t1.website_image, t1.item_group,
t1.web_long_description as website_description, t2.name as route
from `tabItem` t1, `tabWebsite Route` t2
where t1.show_in_website = 1 and (item_group in (%s)
or t1.name in (select parent from `tabWebsite Item Group` where item_group in (%s)))
and t1.name = t2.docname and t2.ref_doctype='Item' """ % (child_groups, child_groups)
query = """select name, item_name, page_name, website_image, item_group,
web_long_description as website_description,
concat(parent_website_route, "/", page_name) as route
from `tabItem`
where show_in_website = 1
and (item_group in (%s)
or name in (select parent from `tabWebsite Item Group` where item_group in (%s)))
""" % (child_groups, child_groups)
query += """order by t1.weightage desc, t1.modified desc limit %s, %s""" % (start, limit)
query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit)
data = frappe.db.sql(query, {"product_group": product_group}, as_dict=1)

View File

@ -6,14 +6,15 @@ import frappe
from frappe.utils import cstr, filter_strip_join
from frappe.website.website_generator import WebsiteGenerator
condition_field = "show_in_website"
template = "templates/generators/sales_partner.html"
class SalesPartner(WebsiteGenerator):
page_title_field = "partner_name"
condition_field = "show_in_website"
template = "templates/generators/sales_partner.html"
def autoname(self):
self.name = self.partner_name
def validate(self):
self.parent_website_route = "partners"
super(SalesPartner, self).validate()
if self.partner_website and not self.partner_website.startswith("http"):
self.partner_website = "http://" + self.partner_website
@ -27,9 +28,6 @@ class SalesPartner(WebsiteGenerator):
else:
return ''
def get_page_title(self):
return self.partner_name
def get_context(self, context):
address = frappe.db.get_value("Address",
{"sales_partner": self.name, "is_primary_address": 1},
@ -46,7 +44,3 @@ class SalesPartner(WebsiteGenerator):
})
return context
def get_parent_website_route(self):
parent_website_sitemap = super(SalesPartner, self).get_parent_website_route()
return parent_website_sitemap or "partners"

View File

@ -12,10 +12,12 @@ from frappe.website.doctype.website_slideshow.website_slideshow import get_slide
class WarehouseNotSet(frappe.ValidationError): pass
condition_field = "show_in_website"
template = "templates/generators/item.html"
class Item(WebsiteGenerator):
page_title_field = "item_name"
condition_field = "show_in_website"
template = "templates/generators/item.html"
parent_website_route_field = "item_group"
def onload(self):
super(Item, self).onload()
self.get("__onload").sle_exists = self.check_if_sle_exists()
@ -49,9 +51,6 @@ class Item(WebsiteGenerator):
self.cant_change()
self.validate_item_type_for_reorder()
if not self.parent_website_route:
self.parent_website_route = frappe.get_website_route("Item Group", self.item_group)
if not self.get("__islocal"):
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
self.old_website_item_groups = frappe.db.sql_list("""select item_group from `tabWebsite Item Group`
@ -216,14 +215,6 @@ class Item(WebsiteGenerator):
item_description=%s, modified=NOW() where item_code=%s""",
(self.item_name, self.description, self.name))
def get_page_title(self):
if self.name==self.item_name:
page_name_from = self.name
else:
page_name_from = self.name + " - " + self.item_name
return page_name_from
def get_tax_rate(self, tax_type):
return { "tax_rate": frappe.db.get_value("Account", tax_type, "tax_rate") }