From 0e0b2317e119a78dfab8c45aeb1e7eb18b9ddd0f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 6 Dec 2012 18:18:58 +0530 Subject: [PATCH 1/2] fixes in item after change in website --- stock/doctype/item/item.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index c22462b210..e3ad01af9e 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -25,7 +25,7 @@ from webnotes import msgprint sql = webnotes.conn.sql -class DocType(): +class DocType: def __init__(self, doc, doclist=[]): self.doc = doc self.doclist = doclist @@ -38,9 +38,13 @@ class DocType(): return ret def on_update(self): - # webpage updates - from website.utils import update_page_name - update_page_name(self.doc, self.doc.item_name) + if self.doc.show_in_website: + # webpage updates + from website.utils import update_page_name + update_page_name(self.doc, self.doc.item_name) + elif self.doc.page_name: + from website.web_cache import delete_page_cache + delete_page_cache(self.doc.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): @@ -80,8 +84,10 @@ class DocType(): sql("""delete from `tabStock Ledger Entry` where item_code=%s and is_cancelled='Yes' """, self.doc.item_code) - self.delete_web_cache(self.doc.page_name) - + if self.doc.page_name: + from website.web_cache import delete_page_cache + delete_page_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): check_list=[] From a367bfe059f055b761ae6cdebc66a336ff34f394 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 6 Dec 2012 18:26:09 +0530 Subject: [PATCH 2/2] fixes after website refactor --- stock/doctype/item/item.py | 11 +++++++---- website/doctype/blog/blog.py | 2 +- website/web_cache.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index e3ad01af9e..4af556c015 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -43,8 +43,8 @@ class DocType: from website.utils import update_page_name update_page_name(self.doc, self.doc.item_name) elif self.doc.page_name: - from website.web_cache import delete_page_cache - delete_page_cache(self.doc.page_name) + from website.web_cache import clear_cache + clear_cache(self.doc.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): @@ -85,8 +85,8 @@ class DocType: where item_code=%s and is_cancelled='Yes' """, self.doc.item_code) if self.doc.page_name: - from website.web_cache import delete_page_cache - delete_page_cache(self.doc.page_name) + from website.web_cache import clear_cache + clear_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): @@ -198,6 +198,9 @@ class DocType: def on_rename(self,newdn,olddn): sql("update tabItem set item_code = %s where name = %s", (newdn, olddn)) + if self.doc.page_name: + from website.web_cache import clear_cache + clear_cache(self.doc.page_name) def prepare_template_args(self): self.doc.web_description_html = self.doc.description or '' diff --git a/website/doctype/blog/blog.py b/website/doctype/blog/blog.py index 46fa8333f2..cfc0ca643e 100644 --- a/website/doctype/blog/blog.py +++ b/website/doctype/blog/blog.py @@ -19,7 +19,7 @@ from __future__ import unicode_literals import webnotes import website.utils -class DocType(): +class DocType: def __init__(self, d, dl): self.doc, self.doclist = d, dl diff --git a/website/web_cache.py b/website/web_cache.py index a1ab2b99bf..9146dd918e 100644 --- a/website/web_cache.py +++ b/website/web_cache.py @@ -164,7 +164,7 @@ def get_outer_env(): 'favicon': webnotes.conn.get_value('Website Settings', None, 'favicon') } -def clear_cache(page_name, doc_type=None, doc_name=None): +def clear_cache(page_name): if page_name: delete_page_cache(page_name) else: