Browse Source

[website sitemap] [setup] [minor] fixes

version-14
Rushabh Mehta 11 years ago
parent
commit
63a43f0c28
4 changed files with 12 additions and 7 deletions
  1. +7
    -2
      webnotes/webutils.py
  2. +2
    -1
      website/doctype/website_settings/website_settings.py
  3. +0
    -1
      website/doctype/website_sitemap/website_sitemap.py
  4. +3
    -3
      website/doctype/website_sitemap_config/website_sitemap_config.py

+ 7
- 2
webnotes/webutils.py View File

@@ -20,6 +20,11 @@ def render(page_name):
html = render_page(page_name or "index")
except PageNotFoundError:
html = render_page("404")
except webnotes.DoesNotExistError:
if page_name=="index":
html = render_page("login")
else:
html = render_page("404")
except Exception:
html = render_page("error")
@@ -218,9 +223,9 @@ class WebsiteGenerator(object):
def on_update(self, page_name=None):
self.setup_generator()
if self._website_config.condition_field:
if not self.doc.fields[self._website_config.condition_field]:
if not self.doc.fields.get(self._website_config.condition_field):
# condition field failed, return
remove_page(self.doc.fields[self._website_config.page_name_field])
remove_page(self.doc.fields.get(self._website_config.page_name_field))
return

if not page_name:


+ 2
- 1
website/doctype/website_settings/website_settings.py View File

@@ -10,7 +10,6 @@ class DocType:
self.doc, self.doclist = d, dl
def validate(self):
self.set_home_page()
self.validate_top_bar_items()
self.validate_footer_items()
@@ -59,6 +58,8 @@ class DocType:
def on_update(self):
# make js and css
# clear web cache (for menus!)
self.set_home_page()

from webnotes.webutils import clear_cache
clear_cache()



+ 0
- 1
website/doctype/website_sitemap/website_sitemap.py View File

@@ -19,4 +19,3 @@ def add_to_sitemap(options):
doc.name = doc.page_name
doc.website_sitemap_config = options.link_name
doc.insert()
webnotes.conn.commit()

+ 3
- 3
website/doctype/website_sitemap_config/website_sitemap_config.py View File

@@ -34,7 +34,6 @@ import os, time
def rebuild_website_sitemap_config():
webnotes.conn.sql("""delete from `tabWebsite Sitemap Config`""")
webnotes.conn.sql("""delete from `tabWebsite Sitemap`""")
webnotes.conn.commit()
build_website_sitemap_config()

def build_website_sitemap_config():
@@ -67,7 +66,9 @@ def build_website_sitemap_config():
for name in existing_configs:
webnotes.delete_doc("Website Sitemap Config", name)

webnotes.conn.commit()

def add_website_sitemap_config(page_or_generator, path, fname, existing_configs):
basepath = webnotes.utils.get_base_path()
template_path = os.path.relpath(os.path.join(path, fname), basepath)
@@ -105,6 +106,5 @@ def add_website_sitemap_config(page_or_generator, path, fname, existing_configs)
wsc.condition_field = getattr(module, "condition_field", None)
webnotes.bean(wsc).insert()
webnotes.conn.commit()
return name

Loading…
Cancel
Save