[website] [sitemap] cleanup

This commit is contained in:
Rushabh Mehta 2013-11-18 19:27:18 +05:30
parent be78d05a0b
commit ebdddf3fb6
5 changed files with 30 additions and 69 deletions

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-24 19:29:05", "creation": "2013-05-24 19:29:05",
"docstatus": 0, "docstatus": 0,
"modified": "2013-11-03 14:11:36", "modified": "2013-11-18 15:16:50",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -179,12 +179,11 @@
"search_index": 1 "search_index": 1
}, },
{ {
"description": "Enter the date by which payments from customer is expected against this invoice.",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "due_date", "fieldname": "due_date",
"fieldtype": "Date", "fieldtype": "Date",
"in_filter": 1, "in_filter": 1,
"label": "Due Date", "label": "Payment Due Date",
"no_copy": 1, "no_copy": 1,
"oldfieldname": "due_date", "oldfieldname": "due_date",
"oldfieldtype": "Date", "oldfieldtype": "Date",
@ -821,7 +820,6 @@
"search_index": 1 "search_index": 1
}, },
{ {
"description": "Track this Sales Invoice against any Project",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "project_name", "fieldname": "project_name",
"fieldtype": "Link", "fieldtype": "Link",

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-04-10 11:45:37", "creation": "2013-04-10 11:45:37",
"docstatus": 0, "docstatus": 0,
"modified": "2013-11-06 11:27:57", "modified": "2013-11-18 15:12:07",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -73,13 +73,12 @@
"search_index": 1 "search_index": 1
}, },
{ {
"description": "Name of organization from where lead has come",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "company_name", "fieldname": "company_name",
"fieldtype": "Data", "fieldtype": "Data",
"in_filter": 1, "in_filter": 1,
"in_list_view": 1, "in_list_view": 1,
"label": "Company Name", "label": "Organization Name",
"oldfieldname": "company_name", "oldfieldname": "company_name",
"oldfieldtype": "Data", "oldfieldtype": "Data",
"reqd": 0, "reqd": 0,
@ -116,7 +115,6 @@
"search_index": 1 "search_index": 1
}, },
{ {
"description": "Source of the lead. If via a campaign, select \"Campaign\"",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "source", "fieldname": "source",
"fieldtype": "Select", "fieldtype": "Select",
@ -181,7 +179,6 @@
}, },
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"description": "Your sales person who will contact the lead in future",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "contact_by", "fieldname": "contact_by",
"fieldtype": "Link", "fieldtype": "Link",
@ -197,7 +194,7 @@
}, },
{ {
"allow_on_submit": 0, "allow_on_submit": 0,
"description": "Your sales person will get a reminder on this date to contact the lead", "description": "Add to calendar on this date",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "contact_date", "fieldname": "contact_date",
"fieldtype": "Date", "fieldtype": "Date",

View File

@ -4,46 +4,31 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.utils.nestedset import DocTypeNestedSet from webnotes.utils.nestedset import DocTypeNestedSet
from webnotes.webutils import WebsiteGenerator
class DocType(DocTypeNestedSet): class DocType(DocTypeNestedSet, WebsiteGenerator):
def __init__(self, doc, doclist=[]): def __init__(self, doc, doclist=[]):
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist
self.nsm_parent_field = 'parent_item_group' self.nsm_parent_field = 'parent_item_group'
def on_update(self): def on_update(self):
super(DocType, self).on_update() DocTypeNestedSet.on_update(self)
WebsiteGenerator.on_update(self)
self.validate_name_with_item() self.validate_name_with_item()
from selling.utils.product import invalidate_cache_for from selling.utils.product import invalidate_cache_for
invalidate_cache_for(self.doc.name)
if self.doc.show_in_website:
from webnotes.webutils import update_page_name
# webpage updates
page_name = self.doc.name
update_page_name(self.doc, page_name)
invalidate_cache_for(self.doc.name)
elif self.doc.page_name:
# if unchecked show in website
from webnotes.webutils import delete_page_cache
delete_page_cache(self.doc.page_name)
invalidate_cache_for(self.doc.name)
webnotes.conn.set(self.doc, "page_name", None)
self.validate_one_root() self.validate_one_root()
def validate_name_with_item(self): def validate_name_with_item(self):
if webnotes.conn.exists("Item", self.doc.name): if webnotes.conn.exists("Item", self.doc.name):
webnotes.msgprint("An item exists with same name (%s), please change the \ webnotes.msgprint("An item exists with same name (%s), please change the \
item group name or rename the item" % self.doc.name, raise_exception=1) item group name or rename the item" % self.doc.name, raise_exception=1)
def get_context(self): def get_context(self):
from selling.utils.product import get_product_list_for_group, \ from selling.utils.product import get_product_list_for_group, \
get_parent_item_groups, get_group_item_count get_parent_item_groups, get_group_item_count

View File

@ -4,9 +4,10 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.utils import cint, cstr, filter_strip_join from webnotes.utils import cint, cstr, filter_strip_join
from website.webutils import WebsiteGenerator
class DocType: class DocType(WebsiteGenerator):
def __init__(self, doc, doclist=None): def __init__(self, doc, doclist=None):
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist
@ -16,13 +17,8 @@ class DocType:
self.doc.partner_website = "http://" + self.doc.partner_website self.doc.partner_website = "http://" + self.doc.partner_website
def on_update(self): def on_update(self):
if cint(self.doc.show_in_website): WebsiteGenerator.on_update()
from webnotes.webutils import update_page_name
update_page_name(self.doc, self.doc.partner_name)
if self.doc.page_name: if self.doc.page_name:
from webnotes.webutils import clear_cache
clear_cache(self.doc.page_name)
clear_cache("partners") clear_cache("partners")
def get_contacts(self,nm): def get_contacts(self,nm):

View File

@ -8,12 +8,13 @@ from webnotes.utils import cstr, flt, cint
from webnotes.model.doc import addchild from webnotes.model.doc import addchild
from webnotes.model.bean import getlist from webnotes.model.bean import getlist
from webnotes import msgprint, _ from webnotes import msgprint, _
from webnotes.webutils import WebsiteGenerator
from webnotes.model.controller import DocListController from webnotes.model.controller import DocListController
class WarehouseNotSet(Exception): pass class WarehouseNotSet(Exception): pass
class DocType(DocListController): class DocType(DocListController, WebsiteGenerator):
def onload(self): def onload(self):
self.doc.fields["__sle_exists"] = self.check_if_sle_exists() self.doc.fields["__sle_exists"] = self.check_if_sle_exists()
@ -212,34 +213,21 @@ class DocType(DocListController):
self.doc.name, raise_exception=1) self.doc.name, raise_exception=1)
def update_website(self): def update_website(self):
def _invalidate_cache(): from selling.utils.product import invalidate_cache_for
from selling.utils.product import invalidate_cache_for invalidate_cache_for(self.doc.item_group)
[invalidate_cache_for(d.item_group) for d in \
invalidate_cache_for(self.doc.item_group) self.doclist.get({"doctype":"Website Item Group"})]
[invalidate_cache_for(d.item_group) for d in \ WebsiteGenerator.on_update(self)
self.doclist.get({"doctype":"Website Item Group"})]
def get_page_title(self):
if self.doc.name==self.doc.item_name:
page_name_from = self.doc.name
else:
page_name_from = self.doc.name + " " + self.doc.item_name
if self.doc.show_in_website: return page_name_from
from webnotes.webutils import update_page_name
if self.doc.name==self.doc.item_name:
page_name_from = self.doc.name
else:
page_name_from = self.doc.name + " " + self.doc.item_name
update_page_name(self.doc, page_name_from)
_invalidate_cache()
elif self.doc.page_name:
# if unchecked show in website
from webnotes.webutils import delete_page_cache
delete_page_cache(self.doc.page_name)
_invalidate_cache()
webnotes.conn.set(self.doc, "page_name", None)
def get_tax_rate(self, tax_type): def get_tax_rate(self, tax_type):
return { "tax_rate": webnotes.conn.get_value("Account", tax_type, "tax_rate") } return { "tax_rate": webnotes.conn.get_value("Account", tax_type, "tax_rate") }
@ -263,10 +251,7 @@ class DocType(DocListController):
def on_trash(self): def on_trash(self):
webnotes.conn.sql("""delete from tabBin where item_code=%s""", self.doc.item_code) webnotes.conn.sql("""delete from tabBin where item_code=%s""", self.doc.item_code)
WebsiteGenerator.on_trash(self)
if self.doc.page_name:
from webnotes.webutils import clear_cache
clear_cache(self.doc.page_name)
def on_rename(self, newdn, olddn, merge=False): def on_rename(self, newdn, olddn, merge=False):
webnotes.conn.sql("update tabItem set item_code = %s where name = %s", (newdn, olddn)) webnotes.conn.sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))