浏览代码

renamed Website Sitemap > Website Route, Website Sitemap Config > Website TeWebsite Template

version-14
Rushabh Mehta 11 年前
父节点
当前提交
8377acb148
共有 64 个文件被更改,包括 434 次插入265 次删除
  1. +2
    -2
      frappe/__init__.py
  2. +1
    -1
      frappe/cli.py
  3. +2
    -9
      frappe/db.py
  4. +1
    -1
      frappe/hooks.txt
  5. +2
    -2
      frappe/installer.py
  6. +7
    -2
      frappe/model/doc.py
  7. +12
    -11
      frappe/model/rename_doc.py
  8. +2
    -1
      frappe/patches.txt
  9. +2
    -2
      frappe/patches/4_0/remove_index_sitemap.py
  10. +23
    -0
      frappe/patches/4_0/rename_sitemap_to_route.py
  11. +5
    -5
      frappe/patches/4_0/set_website_route_idx.py
  12. +5
    -5
      frappe/patches/4_0/website_sitemap_hierarchy.py
  13. +1
    -1
      frappe/templates/generators/blog_post.py
  14. +5
    -5
      frappe/templates/generators/website_group.py
  15. +4
    -4
      frappe/templates/pages/sitemap.py
  16. +1
    -1
      frappe/templates/website_group/forum.py
  17. +8
    -8
      frappe/templates/website_group/settings.py
  18. +2
    -2
      frappe/translations/ar.csv
  19. +2
    -2
      frappe/translations/de.csv
  20. +2
    -2
      frappe/translations/el.csv
  21. +2
    -2
      frappe/translations/es.csv
  22. +2
    -2
      frappe/translations/fr.csv
  23. +2
    -2
      frappe/translations/hi.csv
  24. +2
    -2
      frappe/translations/hr.csv
  25. +2
    -2
      frappe/translations/it.csv
  26. +2
    -2
      frappe/translations/nl.csv
  27. +2
    -2
      frappe/translations/pt-BR.csv
  28. +2
    -2
      frappe/translations/pt.csv
  29. +2
    -2
      frappe/translations/sr.csv
  30. +2
    -2
      frappe/translations/ta.csv
  31. +2
    -2
      frappe/translations/th.csv
  32. +2
    -2
      frappe/translations/zh-cn.csv
  33. +2
    -2
      frappe/translations/zh-tw.csv
  34. +2
    -2
      frappe/website/__init__.py
  35. +1
    -1
      frappe/website/context.py
  36. +4
    -4
      frappe/website/doctype/blog_category/blog_category.txt
  37. +2
    -2
      frappe/website/doctype/blog_category/test_blog_category.py
  38. +1
    -1
      frappe/website/doctype/blog_post/blog_post.py
  39. +4
    -4
      frappe/website/doctype/blog_post/blog_post.txt
  40. +1
    -1
      frappe/website/doctype/user_vote/user_vote.py
  41. +36
    -0
      frappe/website/doctype/web_page/test_web_page.py
  42. +7
    -7
      frappe/website/doctype/web_page/web_page.py
  43. +3
    -3
      frappe/website/doctype/web_page/web_page.txt
  44. +1
    -1
      frappe/website/doctype/website_group/website_group.py
  45. +4
    -4
      frappe/website/doctype/website_group/website_group.txt
  46. +0
    -0
      frappe/website/doctype/website_route/__init__.py
  47. +42
    -43
      frappe/website/doctype/website_route/website_route.py
  48. +9
    -9
      frappe/website/doctype/website_route/website_route.txt
  49. +0
    -0
      frappe/website/doctype/website_route_permission/__init__.py
  50. +16
    -0
      frappe/website/doctype/website_route_permission/website_route_permission.py
  51. +85
    -0
      frappe/website/doctype/website_route_permission/website_route_permission.txt
  52. +1
    -1
      frappe/website/doctype/website_settings/website_settings.py
  53. +1
    -1
      frappe/website/doctype/website_settings/website_settings.txt
  54. +6
    -6
      frappe/website/doctype/website_sitemap_permission/website_sitemap_permission.txt
  55. +0
    -0
      frappe/website/doctype/website_template/__init__.py
  56. +24
    -20
      frappe/website/doctype/website_template/website_template.py
  57. +4
    -4
      frappe/website/doctype/website_template/website_template.txt
  58. +2
    -2
      frappe/website/page/sitemap_browser/sitemap_browser.js
  59. +13
    -13
      frappe/website/page/sitemap_browser/sitemap_browser.py
  60. +2
    -2
      frappe/website/page/website_home/website_home.js
  61. +33
    -27
      frappe/website/permissions.py
  62. +1
    -1
      frappe/website/render.py
  63. +7
    -7
      frappe/website/sitemap.py
  64. +7
    -7
      frappe/website/website_generator.py

+ 2
- 2
frappe/__init__.py 查看文件

@@ -616,8 +616,8 @@ def set_filters(jenv):
def get_template(path):
return get_jenv().get_template(path)
def get_website_sitemap(doctype, name):
return conn.get_value("Website Sitemap", {"ref_doctype": doctype, "docname": name})
def get_website_route(doctype, name):
return conn.get_value("Website Route", {"ref_doctype": doctype, "docname": name})

def add_version(doclist):
bean({


+ 1
- 1
frappe/cli.py 查看文件

@@ -190,7 +190,7 @@ def setup_utilities(parser):
parser.add_argument("--clear_web", default=False, action="store_true",
help="Clear website cache")
parser.add_argument("--build_sitemap", default=False, action="store_true",
help="Build Website Sitemap")
help="Build Website Route")
parser.add_argument("--sync_statics", default=False, action="store_true",
help="Sync files from templates/statics to Web Pages")
parser.add_argument("--clear_cache", default=False, action="store_true",


+ 2
- 9
frappe/db.py 查看文件

@@ -395,16 +395,9 @@ class Database:
if field!="modified":
self.set_value(dt, dn, "modified", modified or now())
def set_in_doc(self, doc, field, val):
self.set(doc, field, val)
def set(self, doc, field, val):
from frappe.utils import now
doc.modified = now()
doc.modified_by = frappe.session["user"]
self.set_value(doc.doctype, doc.name, field, val, doc.modified, doc.modified_by)
doc.fields[field] = val
doc.set(field, val)
def touch(self, doctype, docname):
from frappe.utils import now


+ 1
- 1
frappe/hooks.txt 查看文件

@@ -42,4 +42,4 @@ has_permission:ToDo = frappe.core.doctype.todo.todo.has_permission
# bean

bean_event:User Vote:after_insert = frappe.templates.generators.website_group.clear_cache_on_bean_event
bean_event:Website Sitemap Permission:on_update = frappe.templates.generators.website_group.clear_cache_on_bean_event
bean_event:Website Route Permission:on_update = frappe.templates.generators.website_group.clear_cache_on_bean_event

+ 2
- 2
frappe/installer.py 查看文件

@@ -120,8 +120,8 @@ def add_to_installed_apps(app_name, rebuild_sitemap=True):
frappe.conn.commit()

if rebuild_sitemap:
from frappe.website.doctype.website_sitemap_config.website_sitemap_config import rebuild_website_sitemap_config
rebuild_website_sitemap_config()
from frappe.website.doctype.website_template.website_template import rebuild_website_template
rebuild_website_template()

frappe.clear_cache()



+ 7
- 2
frappe/model/doc.py 查看文件

@@ -10,7 +10,6 @@ _toc = ["frappe.model.doc.Document"]

import frappe
import frappe.model.meta

from frappe.utils import *

class Document:
@@ -304,7 +303,13 @@ class Document:
if not self.naming_series:
# pick default naming series
self.naming_series = get_default_naming_series(self.doctype)
def set(self, key, value):
self.modified = now()
self.modified_by = frappe.session["user"]
frappe.conn.set_value(self.doctype, self.name, key, value, self.modified, self.modified_by)
self.fields[key] = value
def _insert(self, make_autoname=True, keep_timestamps=False):
# set name
if make_autoname:


+ 12
- 11
frappe/model/rename_doc.py 查看文件

@@ -32,7 +32,7 @@ def rename_doc(doctype, old, new, force=False, merge=False, ignore_permissions=F
# update link fields' values
link_fields = get_link_fields(doctype)
update_link_field_values(link_fields, old, new)
update_link_field_values(link_fields, old, new, doctype)
if doctype=='DocType':
rename_doctype(doctype, old, new, force)
@@ -99,7 +99,7 @@ def rename_doctype(doctype, old, new, force=False):
# change options where select options are hardcoded i.e. listed
select_fields = get_select_fields(old, new)
update_link_field_values(select_fields, old, new)
update_link_field_values(select_fields, old, new, doctype)
update_select_field_values(old, new)
# change parenttype for fieldtype Table
@@ -118,7 +118,7 @@ def update_child_docs(old, new, doclist):
frappe.conn.sql("update `tab%s` set parent=%s where parent=%s" \
% (child, '%s', '%s'), (new, old))

def update_link_field_values(link_fields, old, new):
def update_link_field_values(link_fields, old, new, doctype):
update_list = []
# update values
@@ -133,13 +133,14 @@ def update_link_field_values(link_fields, old, new):
where doctype=%s and field=%s and value=%s""",
(new, field['parent'], field['fieldname'], old))
else:
frappe.conn.sql("""\
update `tab%s` set `%s`=%s
where `%s`=%s""" \
% (field['parent'], field['fieldname'], '%s',
field['fieldname'], '%s'),
(new, old))
if doctype!='DocType' and field['parent']!=new:
frappe.conn.sql("""\
update `tab%s` set `%s`=%s
where `%s`=%s""" \
% (field['parent'], field['fieldname'], '%s',
field['fieldname'], '%s'),
(new, old), debug=1)
def get_link_fields(doctype):
# get link fields from tabDocField
link_fields = frappe.conn.sql("""\
@@ -181,7 +182,7 @@ def get_link_fields(doctype):
% ('%s', doctype), (doctype,), as_dict=1)
link_fields += property_setter_link_fields
return link_fields
def update_parent_of_fieldtype_table(old, new):


+ 2
- 1
frappe/patches.txt 查看文件

@@ -14,4 +14,5 @@ frappe.patches.4_0.set_todo_checked_as_closed
frappe.patches.4_0.website_sitemap_hierarchy
frappe.patches.4_0.webnotes_to_frappe
execute:frappe.reset_perms("Module Def")
frappe.patches.4_0.set_website_sitemap_idx
frappe.patches.4_0.rename_sitemap_to_route
frappe.patches.4_0.set_website_route_idx

+ 2
- 2
frappe/patches/4_0/remove_index_sitemap.py 查看文件

@@ -1,6 +1,6 @@
import frappe

def execute():
if frappe.conn.exists("Website Sitemap", "index"):
frappe.delete_doc("Website Sitemap", "index", ignore_permissions=True)
if frappe.conn.exists("Website Route", "index"):
frappe.delete_doc("Website Route", "index", ignore_permissions=True)

+ 23
- 0
frappe/patches/4_0/rename_sitemap_to_route.py 查看文件

@@ -0,0 +1,23 @@
import frappe

from frappe.model import rename_field

def execute():
tables = frappe.conn.sql_list("show tables")
if "tabWebsite Route" not in tables:
frappe.rename_doc("DocType", "Website Sitemap", "Website Route", force=True)

if "tabWebsite Template" not in tables:
frappe.rename_doc("DocType", "Website Sitemap Config", "Website Template", force=True)
if "tabWebsite Route Permission" not in tables:
frappe.rename_doc("DocType", "Website Sitemap Permission", "Website Route Permission", force=True)
for d in ("blog_category", "blog_post", "web_page", "website_route", "website_group"):
frappe.reload_doc("website", "doctype", d)
for d in ("Blog Category", "Blog Post", "Web Page", "Website Route", "Website Group"):
rename_field(d, "parent_website_sitemap", "parent_website_route")
rename_field("Website Route", "website_sitemap_config", "website_template")
rename_field("Website Route Permission", "website_sitemap", "website_route")

frappe/patches/4_0/set_website_sitemap_idx.py → frappe/patches/4_0/set_website_route_idx.py 查看文件

@@ -1,20 +1,20 @@
import frappe

def execute():
from frappe.website.doctype.website_sitemap_config.website_sitemap_config import \
from frappe.website.doctype.website_template.website_template import \
get_pages_and_generators, get_template_controller


for app in frappe.get_installed_apps():
pages, generators = get_pages_and_generators(app)
for g in generators:
doctype = frappe.get_attr(get_template_controller(app, g[2], g[3]) + ".doctype")
doctype = frappe.get_attr(get_template_controller(app, g["path"], g["fname"]) + ".doctype")
module = frappe.conn.get_value("DocType", doctype, "module")
frappe.reload_doc(module, "doctype", doctype)
frappe.conn.sql("""update `tabWebsite Sitemap` set idx=null""")
frappe.conn.sql("""update `tabWebsite Route` set idx=null""")
for doctype in ["Blog Category", "Blog Post", "Web Page", "Website Group"]:
frappe.conn.sql("""update `tab{}` set idx=null""".format(doctype))

from frappe.website.doctype.website_sitemap_config.website_sitemap_config import rebuild_website_sitemap_config
rebuild_website_sitemap_config()
from frappe.website.doctype.website_template.website_template import rebuild_website_template
rebuild_website_template()

+ 5
- 5
frappe/patches/4_0/website_sitemap_hierarchy.py 查看文件

@@ -6,17 +6,17 @@ from __future__ import unicode_literals
import frappe

def execute():
frappe.reload_doc("website", "doctype", "website_sitemap")
frappe.reload_doc("website", "doctype", "website_sitemap_permission")
frappe.reload_doc("website", "doctype", "website_route")
frappe.reload_doc("website", "doctype", "website_route_permission")
frappe.reload_doc("website", "doctype", "website_group")
frappe.reload_doc("website", "doctype", "post")
frappe.reload_doc("website", "doctype", "user_vote")
frappe.conn.sql("""update `tabWebsite Sitemap` ws set ref_doctype=(select wsc.ref_doctype
from `tabWebsite Sitemap Config` wsc where wsc.name=ws.website_sitemap_config)
frappe.conn.sql("""update `tabWebsite Route` ws set ref_doctype=(select wsc.ref_doctype
from `tabWebsite Template` wsc where wsc.name=ws.website_template)
where ifnull(page_or_generator, '')!='Page'""")
home_page = frappe.conn.get_value("Website Settings", "Website Settings", "home_page")
home_page = frappe.conn.get_value("Website Sitemap", {"docname": home_page}) or home_page
home_page = frappe.conn.get_value("Website Route", {"docname": home_page}) or home_page
frappe.conn.set_value("Website Settings", "Website Settings", "home_page",
home_page)

+ 1
- 1
frappe/templates/generators/blog_post.py 查看文件

@@ -53,7 +53,7 @@ def get_blog_list(start=0, by=None, category=None):
t2.full_name, t2.avatar, t1.blogger,
(select count(name) from `tabComment` where
comment_doctype='Blog Post' and comment_docname=t1.name) as comments
from `tabBlog Post` t1, `tabBlogger` t2, `tabWebsite Sitemap` t3
from `tabBlog Post` t1, `tabBlogger` t2, `tabWebsite Route` t3
where ifnull(t1.published,0)=1
and t1.blogger = t2.name
and t3.docname = t1.name


+ 5
- 5
frappe/templates/generators/website_group.py 查看文件

@@ -75,8 +75,8 @@ def build_view_context(context):

elif context.view.name == "settings":
context.profiles = frappe.conn.sql("""select p.*, wsp.`read`, wsp.`write`, wsp.`admin`
from `tabProfile` p, `tabWebsite Sitemap Permission` wsp
where wsp.website_sitemap=%s and wsp.profile=p.name""", context.pathname, as_dict=True)
from `tabProfile` p, `tabWebsite Route Permission` wsp
where wsp.website_route=%s and wsp.profile=p.name""", context.pathname, as_dict=True)
elif context.view.name == "post":
context.update(get_post_context(context))
@@ -119,7 +119,7 @@ def has_access(access, view):
def clear_cache(path=None, website_group=None):
from frappe.templates.website_group.post import clear_post_cache
if path:
website_groups = [frappe.conn.get_value("Website Sitemap", path, "docname")]
website_groups = [frappe.conn.get_value("Website Route", path, "docname")]
elif website_group:
website_groups = [website_group]
else:
@@ -137,10 +137,10 @@ def clear_event_cache():
clear_unit_views(website_group=group)
def clear_cache_on_bean_event(bean, method, *args, **kwargs):
clear_cache(path=bean.doc.website_sitemap, website_group=bean.doc.website_group)
clear_cache(path=bean.doc.website_route, website_group=bean.doc.website_group)
def get_pathname(group):
return frappe.conn.get_value("Website Sitemap", {"ref_doctype": "Website Group",
return frappe.conn.get_value("Website Route", {"ref_doctype": "Website Group",
"docname": group})

views = {


+ 4
- 4
frappe/templates/pages/sitemap.py 查看文件

@@ -15,11 +15,11 @@ def get_context(context):
"""generate the sitemap XML"""
host = get_request_site_address()
links = []
for l in frappe.conn.sql("""select `tabWebsite Sitemap`.page_name, `tabWebsite Sitemap`.lastmod
from `tabWebsite Sitemap`, `tabWebsite Sitemap Config`
for l in frappe.conn.sql("""select `tabWebsite Route`.page_name, `tabWebsite Route`.lastmod
from `tabWebsite Route`, `tabWebsite Template`
where
`tabWebsite Sitemap`.website_sitemap_config = `tabWebsite Sitemap Config`.name
and ifnull(`tabWebsite Sitemap Config`.no_sitemap, 0)=0""",
`tabWebsite Route`.website_template = `tabWebsite Template`.name
and ifnull(`tabWebsite Template`.no_sitemap, 0)=0""",
as_dict=True):
links.append({
"loc": urllib.basejoin(host, urllib.quote(l.page_name.encode("utf-8"))),


+ 1
- 1
frappe/templates/website_group/forum.py 查看文件

@@ -12,7 +12,7 @@ def get_post_list_html(group, view, limit_start=0, limit_length=20):
# verify permission for paging
if frappe.local.form_dict.cmd == "get_post_list_html":
pathname = frappe.conn.get_value("Website Sitemap",
pathname = frappe.conn.get_value("Website Route",
{"ref_doctype": "Website Group", "docname": group})
access = get_access(pathname)


+ 8
- 8
frappe/templates/website_group/settings.py 查看文件

@@ -19,8 +19,8 @@ def suggest_user(term, group):
where (pr.first_name like %(term)s or pr.last_name like %(term)s)
and pr.user_type = "Website User"
and pr.user_image is not null and pr.enabled=1
and not exists(select wsp.name from `tabWebsite Sitemap Permission` wsp
where wsp.website_sitemap=%(group)s and wsp.profile=pr.name)""",
and not exists(select wsp.name from `tabWebsite Route Permission` wsp
where wsp.website_route=%(group)s and wsp.profile=pr.name)""",
{"term": "%{}%".format(term), "group": pathname}, as_dict=True)
template = frappe.get_template("templates/includes/profile_display.html")
@@ -37,8 +37,8 @@ def add_sitemap_permission(group, profile):
raise frappe.PermissionError
permission = frappe.bean({
"doctype": "Website Sitemap Permission",
"website_sitemap": pathname,
"doctype": "Website Route Permission",
"website_route": pathname,
"profile": profile,
"read": 1
})
@@ -58,13 +58,13 @@ def update_permission(group, profile, perm, value):
if not get_access(pathname).get("admin"):
raise frappe.PermissionError
permission = frappe.bean("Website Sitemap Permission", {"website_sitemap": pathname, "profile": profile})
permission = frappe.bean("Website Route Permission", {"website_route": pathname, "profile": profile})
permission.doc.fields[perm] = int(value)
permission.save(ignore_permissions=True)
# send email
if perm=="admin" and int(value):
group_title = frappe.conn.get_value("Website Sitemap", pathname, "page_title")
group_title = frappe.conn.get_value("Website Route", pathname, "page_title")
subject = "You have been made Administrator of Group " + group_title
@@ -88,14 +88,14 @@ def add_website_group(group, new_group, public_read, public_write, group_type="F
if not get_access(get_pathname(group)).get("admin"):
raise frappe.PermissionError
parent_website_sitemap = frappe.conn.get_value("Website Sitemap",
parent_website_route = frappe.conn.get_value("Website Route",
{"ref_doctype": "Website Group", "docname": group})
frappe.bean({
"doctype": "Website Group",
"group_name": group + "-" + new_group,
"group_title": new_group,
"parent_website_sitemap": parent_website_sitemap,
"parent_website_route": parent_website_route,
"group_type": group_type,
"public_read": int(public_read),
"public_write": int(public_write)

+ 2
- 2
frappe/translations/ar.csv 查看文件

@@ -869,8 +869,8 @@ Website,الموقع
Website Overall Settings,إعدادات الموقع بشكل عام
Website Script,الموقع سكربت
Website Settings,موقع إعدادات
Website Sitemap,خريطة الموقع الموقع
Website Sitemap Config,الموقع خريطة الموقع التكوين
Website Route,خريطة الموقع الموقع
Website Template,الموقع خريطة الموقع التكوين
Website Slideshow,موقع عرض الشرائح
Website Slideshow Item,موقع السلعة عرض شرائح
Website User,موقع العضو


+ 2
- 2
frappe/translations/de.csv 查看文件

@@ -845,8 +845,8 @@ Website,Webseite
Website Overall Settings,Website Overall Einstellungen
Website Script,Website Script
Website Settings,Website-Einstellungen
Website Sitemap,Website Sitemap
Website Sitemap Config,Website Sitemap Config
Website Route,Website Route
Website Template,Website Template
Website Slideshow,Website Slideshow
Website Slideshow Item,Website Slideshow Artikel
Website User,Webseite User


+ 2
- 2
frappe/translations/el.csv 查看文件

@@ -869,8 +869,8 @@ Website,Δικτυακός τόπος
Website Overall Settings,Website Συνολικά Ρυθμίσεις
Website Script,Script Website
Website Settings,Ρυθμίσεις Website
Website Sitemap,Website Sitemap
Website Sitemap Config,Website Sitemap Config
Website Route,Website Route
Website Template,Website Template
Website Slideshow,Παρουσίαση Ιστοσελίδας
Website Slideshow Item,Website Στοιχείο Παρουσίαση
Website User,Χρήστης Website


+ 2
- 2
frappe/translations/es.csv 查看文件

@@ -869,8 +869,8 @@ Website,Sitio web
Website Overall Settings,Sitio web Configuración general
Website Script,Sitio Web de secuencias de comandos
Website Settings,Ajustes del Sitio Web
Website Sitemap,mapa del sitio Web
Website Sitemap Config,Mapa del sitio Web Config
Website Route,mapa del sitio Web
Website Template,Mapa del sitio Web Config
Website Slideshow,Sitio Web Presentación
Website Slideshow Item,Sitio Web Presentación del artículo
Website User,Sitio web del usuario


+ 2
- 2
frappe/translations/fr.csv 查看文件

@@ -869,8 +869,8 @@ Website,Site Web
Website Overall Settings,Réglages généraux Site web
Website Script,Script site web
Website Settings,Réglages Site web
Website Sitemap,Plan du site
Website Sitemap Config,Plan du site Config
Website Route,Plan du site
Website Template,Plan du site Config
Website Slideshow,Diaporama site web
Website Slideshow Item,Point Diaporama site web
Website User,Utilisateur


+ 2
- 2
frappe/translations/hi.csv 查看文件

@@ -869,8 +869,8 @@ Website,वेबसाइट
Website Overall Settings,वेबसाइट कुल मिलाकर सेटिंग्स
Website Script,वेबसाइट स्क्रिप्ट
Website Settings,वेबसाइट सेटिंग
Website Sitemap,वेबसाइट साइटमैप
Website Sitemap Config,वेबसाइट साइटमैप विन्यास
Website Route,वेबसाइट साइटमैप
Website Template,वेबसाइट साइटमैप विन्यास
Website Slideshow,वेबसाइट स्लाइड शो
Website Slideshow Item,वेबसाइट स्लाइड शो आइटम
Website User,वेबसाइट प्रयोक्ता


+ 2
- 2
frappe/translations/hr.csv 查看文件

@@ -869,8 +869,8 @@ Website,Website
Website Overall Settings,Website Ukupni Postavke
Website Script,Web Skripta
Website Settings,Website Postavke
Website Sitemap,web stranica Mapa
Website Sitemap Config,Web stranica Mapa Config
Website Route,web stranica Mapa
Website Template,Web stranica Mapa Config
Website Slideshow,Web Slideshow
Website Slideshow Item,Web Slideshow artikla
Website User,Web User


+ 2
- 2
frappe/translations/it.csv 查看文件

@@ -869,8 +869,8 @@ Website,Sito
Website Overall Settings,Sito Impostazioni generali
Website Script,Script Sito
Website Settings,Impostazioni Sito
Website Sitemap,Sito Sitemap
Website Sitemap Config,Sito Sitemap Config
Website Route,Sito Sitemap
Website Template,Sito Sitemap Config
Website Slideshow,Presentazione sito web
Website Slideshow Item,Sito Slideshow articolo
Website User,Website Utente


+ 2
- 2
frappe/translations/nl.csv 查看文件

@@ -869,8 +869,8 @@ Website,Website
Website Overall Settings,Website Algemene Instellingen
Website Script,Website Script
Website Settings,Website-instellingen
Website Sitemap,website Sitemap
Website Sitemap Config,Website Sitemap Config
Website Route,website Sitemap
Website Template,Website Template
Website Slideshow,Website Diashow
Website Slideshow Item,Website Diashow Item
Website User,Website Gebruiker


+ 2
- 2
frappe/translations/pt-BR.csv 查看文件

@@ -869,8 +869,8 @@ Website,Site
Website Overall Settings,Configurações gerais do site
Website Script,Script do site
Website Settings,Configurações do site
Website Sitemap,site Mapa do Site
Website Sitemap Config,Site Mapa do Site Configuração
Website Route,site Mapa do Site
Website Template,Site Mapa do Site Configuração
Website Slideshow,Slideshow do site
Website Slideshow Item,Item do Slideshow do site
Website User,Site do Usuário


+ 2
- 2
frappe/translations/pt.csv 查看文件

@@ -869,8 +869,8 @@ Website,Site
Website Overall Settings,Configurações do site em geral
Website Script,Script site
Website Settings,Configurações do site
Website Sitemap,website Sitemap
Website Sitemap Config,Website Sitemap Config
Website Route,website Sitemap
Website Template,Website Template
Website Slideshow,Slideshow site
Website Slideshow Item,Item Slideshow site
Website User,Site do Usuário


+ 2
- 2
frappe/translations/sr.csv 查看文件

@@ -869,8 +869,8 @@ Website,Вебсајт
Website Overall Settings,Сајт Овералл Подешавања
Website Script,Сајт скрипте
Website Settings,Сајт Подешавања
Website Sitemap,Сајт Мапа
Website Sitemap Config,Сајт Мапа Цонфиг
Website Route,Сајт Мапа
Website Template,Сајт Мапа Цонфиг
Website Slideshow,Сајт Слидесхов
Website Slideshow Item,Сајт Слидесхов шифра
Website User,Сајт корисника


+ 2
- 2
frappe/translations/ta.csv 查看文件

@@ -869,8 +869,8 @@ Website,இணையதளம்
Website Overall Settings,இணைய மொத்தத்தில் அமைப்புகள்
Website Script,இணைய உரை
Website Settings,இணைய அமைப்புகள்
Website Sitemap,இணையத்தளம் தள வரைபடம்
Website Sitemap Config,இணையத்தளம் தள வரைபடம் கட்டமைப்பு
Website Route,இணையத்தளம் தள வரைபடம்
Website Template,இணையத்தளம் தள வரைபடம் கட்டமைப்பு
Website Slideshow,இணைய ப
Website Slideshow Item,இணைய ப பொருள்
Website User,வலைத்தளம் பயனர்


+ 2
- 2
frappe/translations/th.csv 查看文件

@@ -869,8 +869,8 @@ Website,เว็บไซต์
Website Overall Settings,การตั้งค่าโดยรวมของเว็บไซต์
Website Script,สคริปต์เว็บไซต์
Website Settings,การตั้งค่าเว็บไซต์
Website Sitemap,Sitemap เว็บไซต์
Website Sitemap Config,เว็บไซต์ แผนผังเว็บไซต์ Config
Website Route,Sitemap เว็บไซต์
Website Template,เว็บไซต์ แผนผังเว็บไซต์ Config
Website Slideshow,สไลด์โชว์เว็บไซต์
Website Slideshow Item,รายการสไลด์โชว์เว็บไซต์
Website User,ผู้ใช้งานเว็บไซต์


+ 2
- 2
frappe/translations/zh-cn.csv 查看文件

@@ -869,8 +869,8 @@ Website,网站
Website Overall Settings,网站整体设置
Website Script,网站脚本
Website Settings,网站设置
Website Sitemap,网站地图
Website Sitemap Config,网站地图配置
Website Route,网站地图
Website Template,网站地图配置
Website Slideshow,网站连续播放
Website Slideshow Item,网站幻灯片项目
Website User,网站用户


+ 2
- 2
frappe/translations/zh-tw.csv 查看文件

@@ -869,8 +869,8 @@ Website,網站
Website Overall Settings,網站整體設置
Website Script,網站腳本
Website Settings,網站設置
Website Sitemap,網站地圖
Website Sitemap Config,網站地圖配置
Website Route,網站地圖
Website Template,網站地圖配置
Website Slideshow,網站連續播放
Website Slideshow Item,網站幻燈片項目
Website User,網站用戶


+ 2
- 2
frappe/website/__init__.py 查看文件

@@ -3,5 +3,5 @@

from __future__ import unicode_literals

from frappe.website.doctype.website_sitemap_config.website_sitemap_config \
import rebuild_website_sitemap_config as rebuild_config
from frappe.website.doctype.website_template.website_template \
import rebuild_website_template as rebuild_config

+ 1
- 1
frappe/website/context.py 查看文件

@@ -63,5 +63,5 @@ def build_context(sitemap_options):
# remove bean, as it is not pickle friendly and its purpose is over
if context.bean:
del context["bean"]
return context

+ 4
- 4
frappe/website/doctype/blog_category/blog_category.txt 查看文件

@@ -2,7 +2,7 @@
{
"creation": "2013-03-08 09:41:11",
"docstatus": 0,
"modified": "2014-02-18 15:25:04",
"modified": "2014-02-18 15:25:05",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -62,10 +62,10 @@
{
"default": "blog",
"doctype": "DocField",
"fieldname": "parent_website_sitemap",
"fieldname": "parent_website_route",
"fieldtype": "Link",
"label": "Parent Website Sitemap",
"options": "Website Sitemap",
"label": "Parent Website Route",
"options": "Website Route",
"reqd": 1
},
{


+ 2
- 2
frappe/website/doctype/blog_category/test_blog_category.py 查看文件

@@ -6,12 +6,12 @@ test_records = [
"doctype": "Blog Category",
"category_name": "_Test Blog Category",
"title": "_Test Blog Category",
"parent_website_sitemap": "blog"
"parent_website_route": "blog"
}],
[{
"doctype": "Blog Category",
"category_name": "_Test Blog Category 1",
"title": "_Test Blog Category 1",
"parent_website_sitemap": "blog"
"parent_website_route": "blog"
}]
]

+ 1
- 1
frappe/website/doctype/blog_post/blog_post.py 查看文件

@@ -28,7 +28,7 @@ class DocType(WebsiteGenerator):
if self.doc.published and not self.doc.published_on:
self.doc.published_on = today()

self.doc.parent_website_sitemap = frappe.conn.get_value("Website Sitemap",
self.doc.parent_website_route = frappe.conn.get_value("Website Route",
{"ref_doctype": "Blog Category", "docname": self.doc.blog_category})

# update posts


+ 4
- 4
frappe/website/doctype/blog_post/blog_post.txt 查看文件

@@ -2,7 +2,7 @@
{
"creation": "2013-03-28 10:35:30",
"docstatus": 0,
"modified": "2014-02-20 12:55:06",
"modified": "2014-02-20 12:55:07",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -85,11 +85,11 @@
},
{
"doctype": "DocField",
"fieldname": "parent_website_sitemap",
"fieldname": "parent_website_route",
"fieldtype": "Link",
"hidden": 1,
"label": "Parent Website Sitemap",
"options": "Website Sitemap",
"label": "Parent Website Route",
"options": "Website Route",
"read_only": 1
},
{


+ 1
- 1
frappe/website/doctype/user_vote/user_vote.py 查看文件

@@ -35,7 +35,7 @@ def on_doctype_update():
@frappe.whitelist()
def set_vote(ref_doctype, ref_name):
website_group = frappe.conn.get_value(ref_doctype, ref_name, "website_group")
pathname = frappe.conn.get_value("Website Sitemap", {"ref_doctype": "Website Group",
pathname = frappe.conn.get_value("Website Route", {"ref_doctype": "Website Group",
"docname": website_group})
if not get_access(pathname).get("read"):


+ 36
- 0
frappe/website/doctype/web_page/test_web_page.py 查看文件

@@ -0,0 +1,36 @@
from __future__ import unicode_literals
import unittest
import frappe

test_records = [
[{
"doctype": "Web Page",
"title": "Test Web Page 1",
"main_section": "Test Content 1",
"published": 1
}],
[{
"doctype": "Web Page",
"title": "Test Web Page 2",
"main_section": "Test Content 2",
"published": 1,
"parent_website_route": "test-web-page-1"
}],
[{
"doctype": "Web Page",
"title": "Test Web Page 3",
"main_section": "Test Content 3",
"published": 1,
"parent_website_route": "test-web-page-1"
}],
[{
"doctype": "Web Page",
"title": "Test Web Page 4",
"main_section": "Test Content 4",
"published": 1,
}],
]

def TestWebPage(unittest.TestCase):
def check_sitemap(self):
self.assertEquals(frappe.conn.get_value("Website Route", ""))

+ 7
- 7
frappe/website/doctype/web_page/web_page.py 查看文件

@@ -51,11 +51,11 @@ def _sync_statics():
if fname.rsplit(".", 1)[0]=="index" and os.path.dirname(fpath) != statics_path:
url = os.path.dirname(url)
parent_website_sitemap = os.path.dirname(url)
parent_website_route = os.path.dirname(url)
page_name = os.path.basename(url)
try:
sitemap = frappe.bean("Website Sitemap", url)
sitemap = frappe.bean("Website Route", url)
except frappe.DoesNotExistError:
title, content = get_static_content(fpath)
@@ -68,7 +68,7 @@ def _sync_statics():
"page_name": page_name,
"main_section": content,
"published": 1,
"parent_website_sitemap": parent_website_sitemap
"parent_website_route": parent_website_route
}), os.path.getmtime(fpath)])
else:
@@ -84,7 +84,7 @@ def _sync_statics():
page.doc.title = title
page.save()

sitemap = frappe.bean("Website Sitemap", url)
sitemap = frappe.bean("Website Route", url)
sitemap.doc.static_file_timestamp = os.path.getmtime(fpath)
sitemap.save()
@@ -122,11 +122,11 @@ def _sync_statics():
# delete not synced
if synced:
frappe.delete_doc("Web Page", frappe.conn.sql_list("""select docname from `tabWebsite Sitemap`
frappe.delete_doc("Web Page", frappe.conn.sql_list("""select docname from `tabWebsite Route`
where ifnull(static_file_timestamp,'')!='' and name not in ({})
order by (rgt-lft) asc""".format(', '.join(["%s"]*len(synced))), tuple(synced)))
else:
frappe.delete_doc("Web Page", frappe.conn.sql_list("""select docname from `tabWebsite Sitemap`
frappe.delete_doc("Web Page", frappe.conn.sql_list("""select docname from `tabWebsite Route`
where ifnull(static_file_timestamp,'')!='' order by (rgt-lft) asc"""))

@@ -135,7 +135,7 @@ def _sync_statics():
page.insert()

# update timestamp
sitemap = frappe.bean("Website Sitemap", {"ref_doctype": "Web Page",
sitemap = frappe.bean("Website Route", {"ref_doctype": "Web Page",
"docname": page.doc.name})
sitemap.doc.static_file_timestamp = mtime
sitemap.save()


+ 3
- 3
frappe/website/doctype/web_page/web_page.txt 查看文件

@@ -2,7 +2,7 @@
{
"creation": "2013-03-28 10:35:30",
"docstatus": 0,
"modified": "2014-02-10 18:07:28",
"modified": "2014-02-10 18:07:29",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -71,10 +71,10 @@
},
{
"doctype": "DocField",
"fieldname": "parent_website_sitemap",
"fieldname": "parent_website_route",
"fieldtype": "Link",
"label": "Parent Website Page",
"options": "Website Sitemap"
"options": "Website Route"
},
{
"doctype": "DocField",


+ 1
- 1
frappe/website/doctype/website_group/website_group.py 查看文件

@@ -22,4 +22,4 @@ class DocType(WebsiteGenerator):
clear_cache(website_group=self.doc.name)
def after_insert(self):
clear_cache(path=self.doc.parent_website_sitemap)
clear_cache(path=self.doc.parent_website_route)

+ 4
- 4
frappe/website/doctype/website_group/website_group.txt 查看文件

@@ -2,7 +2,7 @@
{
"creation": "2014-01-29 15:57:42",
"docstatus": 0,
"modified": "2014-02-10 14:38:12",
"modified": "2014-02-10 14:38:13",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -69,13 +69,13 @@
"reqd": 1
},
{
"description": "Display in the sidebar of this Website Sitemap node",
"description": "Display in the sidebar of this Website Route node",
"doctype": "DocField",
"fieldname": "parent_website_sitemap",
"fieldname": "parent_website_route",
"fieldtype": "Link",
"in_list_view": 0,
"label": "Parent Website Page",
"options": "Website Sitemap"
"options": "Website Route"
},
{
"doctype": "DocField",


frappe/website/doctype/website_sitemap/__init__.py → frappe/website/doctype/website_route/__init__.py 查看文件


frappe/website/doctype/website_sitemap/website_sitemap.py → frappe/website/doctype/website_route/website_route.py 查看文件

@@ -8,21 +8,20 @@ from frappe.utils import cint
from frappe.utils.nestedset import DocTypeNestedSet

sitemap_fields = ("page_name", "ref_doctype", "docname", "page_or_generator", "idx",
"lastmod", "parent_website_sitemap", "public_read", "public_write", "page_title")
"lastmod", "parent_website_route", "public_read", "public_write", "page_title")

class DocType(DocTypeNestedSet):
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
self.nsm_parent_field = "parent_website_sitemap"
self.nsm_parent_field = "parent_website_route"
def autoname(self):
self.doc.name = self.get_url()

def get_url(self):
url = self.doc.page_name
if self.doc.parent_website_sitemap:
url = self.doc.parent_website_sitemap + "/" + url
if self.doc.parent_website_route:
url = self.doc.parent_website_route + "/" + url
return url
def validate(self):
@@ -35,35 +34,35 @@ class DocType(DocTypeNestedSet):
self.set_idx()

def renumber_if_moved(self):
current_parent = frappe.conn.get_value("Website Sitemap", self.doc.name, "parent_website_sitemap")
if current_parent and current_parent != self.doc.parent_website_sitemap:
current_parent = frappe.conn.get_value("Website Route", self.doc.name, "parent_website_route")
if current_parent and current_parent != self.doc.parent_website_route:
# move-up
# sitemap
frappe.conn.sql("""update `tabWebsite Sitemap` set idx=idx-1
where parent_website_sitemap=%s and idx>%s""", (current_parent, self.doc.idx))
frappe.conn.sql("""update `tabWebsite Route` set idx=idx-1
where parent_website_route=%s and idx>%s""", (current_parent, self.doc.idx))
# source table
frappe.conn.sql("""update `tab{0}` set idx=idx-1
where parent_website_sitemap=%s and idx>%s""".format(self.doc.ref_doctype),
where parent_website_route=%s and idx>%s""".format(self.doc.ref_doctype),
(current_parent, self.doc.idx))
self.doc.idx = None
def set_idx(self):
if self.doc.idx==None:
self.doc.idx = int(frappe.conn.sql("""select ifnull(max(ifnull(idx, -1)), -1)
from `tabWebsite Sitemap`
where ifnull(parent_website_sitemap, '')=%s and name!=%s""",
(self.doc.parent_website_sitemap or '',
from `tabWebsite Route`
where ifnull(parent_website_route, '')=%s and name!=%s""",
(self.doc.parent_website_route or '',
self.doc.name))[0][0]) + 1
else:
if self.doc.parent_website_sitemap:
if self.doc.parent_website_route:
self.doc.idx = cint(self.doc.idx)
previous_idx = frappe.conn.sql("""select max(idx)
from `tab{}` where ifnull(parent_website_sitemap, '')=%s
from `tab{}` where ifnull(parent_website_route, '')=%s
and ifnull(idx, -1) < %s""".format(self.doc.ref_doctype),
(self.doc.parent_website_sitemap, self.doc.idx))[0][0]
(self.doc.parent_website_route, self.doc.idx))[0][0]
if previous_idx and previous_idx != self.doc.idx - 1:
frappe.throw("{}: {}, {}".format(
@@ -78,7 +77,7 @@ class DocType(DocTypeNestedSet):
from frappe.website.render import clear_cache
self.old_name = self.doc.name
self.doc.name = self.get_url()
frappe.conn.sql("""update `tabWebsite Sitemap` set name=%s where name=%s""",
frappe.conn.sql("""update `tabWebsite Route` set name=%s where name=%s""",
(self.doc.name, self.old_name))
self.rename_links()
self.rename_descendants()
@@ -86,28 +85,28 @@ class DocType(DocTypeNestedSet):
def rename_links(self):
for doctype in frappe.conn.sql_list("""select parent from tabDocField where fieldtype='Link' and
fieldname='parent_website_sitemap' and options='Website Sitemap'"""):
fieldname='parent_website_route' and options='Website Route'"""):
for name in frappe.conn.sql_list("""select name from `tab{}`
where parent_website_sitemap=%s""".format(doctype), self.old_name):
frappe.conn.set_value(doctype, name, "parent_website_sitemap", self.doc.name)
where parent_website_route=%s""".format(doctype), self.old_name):
frappe.conn.set_value(doctype, name, "parent_website_route", self.doc.name)
def rename_descendants(self):
# rename children
for name in frappe.conn.sql_list("""select name from `tabWebsite Sitemap`
where parent_website_sitemap=%s""", self.doc.name):
child = frappe.bean("Website Sitemap", name)
child.doc.parent_website_sitemap = self.doc.name
for name in frappe.conn.sql_list("""select name from `tabWebsite Route`
where parent_website_route=%s""", self.doc.name):
child = frappe.bean("Website Route", name)
child.doc.parent_website_route = self.doc.name
child.save()
def check_if_page_name_is_unique(self):
exists = False
if self.doc.page_or_generator == "Page":
# for a page, name and website sitemap config form a unique key
exists = frappe.conn.sql("""select name from `tabWebsite Sitemap`
where name=%s and website_sitemap_config!=%s""", (self.doc.name, self.doc.website_sitemap_config))
exists = frappe.conn.sql("""select name from `tabWebsite Route`
where name=%s and website_template!=%s""", (self.doc.name, self.doc.website_template))
else:
# for a generator, name, ref_doctype and docname make a unique key
exists = frappe.conn.sql("""select name from `tabWebsite Sitemap`
exists = frappe.conn.sql("""select name from `tabWebsite Route`
where name=%s and (ifnull(ref_doctype, '')!=%s or ifnull(docname, '')!=%s)""",
(self.doc.name, self.doc.ref_doctype, self.doc.docname))
@@ -116,8 +115,8 @@ class DocType(DocTypeNestedSet):
self.doc.name, _("Please change it to continue")))
def make_private_if_parent_is_private(self):
if self.doc.parent_website_sitemap:
parent_pubic_read = frappe.conn.get_value("Website Sitemap", self.doc.parent_website_sitemap,
if self.doc.parent_website_route:
parent_pubic_read = frappe.conn.get_value("Website Route", self.doc.parent_website_route,
"public_read")
if not parent_pubic_read:
@@ -126,27 +125,27 @@ class DocType(DocTypeNestedSet):
def on_trash(self):
from frappe.website.render import clear_cache
# remove website sitemap permissions
to_remove = frappe.conn.sql_list("""select name from `tabWebsite Sitemap Permission`
where website_sitemap=%s""", (self.doc.name,))
frappe.delete_doc("Website Sitemap Permission", to_remove, ignore_permissions=True)
to_remove = frappe.conn.sql_list("""select name from `tabWebsite Route Permission`
where website_route=%s""", (self.doc.name,))
frappe.delete_doc("Website Route Permission", to_remove, ignore_permissions=True)
clear_cache(self.doc.name)
def add_to_sitemap(options):
bean = frappe.new_bean("Website Sitemap")
bean = frappe.new_bean("Website Route")

for key in sitemap_fields:
bean.doc.fields[key] = options.get(key)
if not bean.doc.page_name:
bean.doc.page_name = options.link_name
bean.doc.website_sitemap_config = options.link_name
bean.doc.website_template = options.link_name

bean.insert(ignore_permissions=True)
return bean.doc.idx
def update_sitemap(website_sitemap, options):
bean = frappe.bean("Website Sitemap", website_sitemap)
def update_sitemap(website_route, options):
bean = frappe.bean("Website Route", website_route)
for key in sitemap_fields:
bean.doc.fields[key] = options.get(key)
@@ -155,22 +154,22 @@ def update_sitemap(website_sitemap, options):
# for pages
bean.doc.page_name = options.link_name
bean.doc.website_sitemap_config = options.link_name
bean.doc.website_template = options.link_name
bean.save(ignore_permissions=True)

return bean.doc.idx
def remove_sitemap(page_name=None, ref_doctype=None, docname=None):
if page_name:
frappe.delete_doc("Website Sitemap", page_name, ignore_permissions=True)
frappe.delete_doc("Website Route", page_name, ignore_permissions=True)
elif ref_doctype and docname:
frappe.delete_doc("Website Sitemap", frappe.conn.sql_list("""select name from `tabWebsite Sitemap`
frappe.delete_doc("Website Route", frappe.conn.sql_list("""select name from `tabWebsite Route`
where ref_doctype=%s and docname=%s""", (ref_doctype, docname)), ignore_permissions=True)
def cleanup_sitemap():
"""remove sitemap records where its config do not exist anymore"""
to_delete = frappe.conn.sql_list("""select name from `tabWebsite Sitemap` ws
where not exists(select name from `tabWebsite Sitemap Config` wsc
where wsc.name=ws.website_sitemap_config)""")
to_delete = frappe.conn.sql_list("""select name from `tabWebsite Route` ws
where not exists(select name from `tabWebsite Template` wsc
where wsc.name=ws.website_template)""")
frappe.delete_doc("Website Sitemap", to_delete, ignore_permissions=True)
frappe.delete_doc("Website Route", to_delete, ignore_permissions=True)

frappe/website/doctype/website_sitemap/website_sitemap.txt → frappe/website/doctype/website_route/website_route.txt 查看文件

@@ -2,7 +2,7 @@
{
"creation": "2013-11-18 15:38:40",
"docstatus": 0,
"modified": "2014-02-18 15:23:12",
"modified": "2014-02-24 12:46:59",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -16,7 +16,7 @@
{
"doctype": "DocField",
"name": "__common__",
"parent": "Website Sitemap",
"parent": "Website Route",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
@@ -27,7 +27,7 @@
"delete": 1,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Website Sitemap",
"parent": "Website Route",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
@@ -38,7 +38,7 @@
},
{
"doctype": "DocType",
"name": "Website Sitemap"
"name": "Website Route"
},
{
"doctype": "DocField",
@@ -86,18 +86,18 @@
},
{
"doctype": "DocField",
"fieldname": "website_sitemap_config",
"fieldname": "website_template",
"fieldtype": "Link",
"label": "Website Sitemap Config",
"options": "Website Sitemap Config"
"label": "Website Template",
"options": "Website Template"
},
{
"doctype": "DocField",
"fieldname": "parent_website_sitemap",
"fieldname": "parent_website_route",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Parent Website Sitemap",
"options": "Website Sitemap",
"options": "Website Route",
"search_index": 1
},
{

frappe/website/doctype/website_sitemap_config/__init__.py → frappe/website/doctype/website_route_permission/__init__.py 查看文件


+ 16
- 0
frappe/website/doctype/website_route_permission/website_route_permission.py 查看文件

@@ -0,0 +1,16 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt

from __future__ import unicode_literals
import frappe

from frappe.website.permissions import remove_empty_permissions, clear_permissions

class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def on_update(self):
remove_empty_permissions()
clear_permissions(self.doc.profile)

+ 85
- 0
frappe/website/doctype/website_route_permission/website_route_permission.txt 查看文件

@@ -0,0 +1,85 @@
[
{
"creation": "2014-01-29 17:56:29",
"docstatus": 0,
"modified": "2014-02-24 13:17:17",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"autoname": "WSP.######",
"doctype": "DocType",
"icon": "icon-shield",
"module": "Website",
"name": "__common__"
},
{
"doctype": "DocField",
"in_list_view": 1,
"name": "__common__",
"parent": "Website Route Permission",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
},
{
"cancel": 0,
"create": 1,
"delete": 0,
"doctype": "DocPerm",
"export": 1,
"import": 0,
"name": "__common__",
"parent": "Website Route Permission",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1,
"role": "Website Manager",
"write": 1
},
{
"doctype": "DocType",
"name": "Website Route Permission"
},
{
"doctype": "DocField",
"fieldname": "website_route",
"fieldtype": "Link",
"label": "Website Route",
"options": "Website Route",
"reqd": 1,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "profile",
"fieldtype": "Link",
"label": "Profile",
"options": "Profile",
"reqd": 1,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "read",
"fieldtype": "Check",
"label": "Read"
},
{
"doctype": "DocField",
"fieldname": "write",
"fieldtype": "Check",
"label": "Write"
},
{
"doctype": "DocField",
"fieldname": "admin",
"fieldtype": "Check",
"label": "Admin"
},
{
"doctype": "DocPerm"
}
]

+ 1
- 1
frappe/website/doctype/website_settings/website_settings.py 查看文件

@@ -16,7 +16,7 @@ class DocType(DocListController):
def validate_home_page(self):
if self.doc.home_page and \
not frappe.conn.get_value("Website Sitemap", {"name": self.doc.home_page}):
not frappe.conn.get_value("Website Route", {"name": self.doc.home_page}):
frappe.throw(_("Invalid Home Page") + " (Standard pages - index, login, products, blog, about, contact)")
def validate_top_bar_items(self):


+ 1
- 1
frappe/website/doctype/website_settings/website_settings.txt 查看文件

@@ -52,7 +52,7 @@
"fieldname": "home_page",
"fieldtype": "Link",
"label": "Home Page",
"options": "Website Sitemap",
"options": "Website Route",
"reqd": 0
},
{


+ 6
- 6
frappe/website/doctype/website_sitemap_permission/website_sitemap_permission.txt 查看文件

@@ -17,7 +17,7 @@
"doctype": "DocField",
"in_list_view": 1,
"name": "__common__",
"parent": "Website Sitemap Permission",
"parent": "Website Route Permission",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
@@ -29,7 +29,7 @@
"export": 1,
"import": 0,
"name": "__common__",
"parent": "Website Sitemap Permission",
"parent": "Website Route Permission",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
@@ -40,14 +40,14 @@
},
{
"doctype": "DocType",
"name": "Website Sitemap Permission"
"name": "Website Route Permission"
},
{
"doctype": "DocField",
"fieldname": "website_sitemap",
"fieldname": "website_route",
"fieldtype": "Link",
"label": "Website Sitemap",
"options": "Website Sitemap",
"label": "Website Route",
"options": "Website Route",
"reqd": 1,
"search_index": 1
},


+ 0
- 0
frappe/website/doctype/website_template/__init__.py 查看文件


frappe/website/doctype/website_sitemap_config/website_sitemap_config.py → frappe/website/doctype/website_template/website_template.py 查看文件

@@ -8,7 +8,7 @@ import frappe
import frappe.utils
import os
from frappe import _
from frappe.website.doctype.website_sitemap.website_sitemap import add_to_sitemap, update_sitemap, cleanup_sitemap
from frappe.website.doctype.website_route.website_route import add_to_sitemap, update_sitemap, cleanup_sitemap
from frappe.utils.nestedset import rebuild_tree

class DocType:
@@ -17,14 +17,14 @@ class DocType:
def after_insert(self):
if self.doc.page_or_generator == "Page":
website_sitemap = frappe.conn.get_value("Website Sitemap",
{"website_sitemap_config": self.doc.name, "page_or_generator": "Page"})
website_route = frappe.conn.get_value("Website Route",
{"website_template": self.doc.name, "page_or_generator": "Page"})
opts = self.doc.fields.copy()
opts.update({"public_read": 1})
if website_sitemap:
update_sitemap(website_sitemap, opts)
if website_route:
update_sitemap(website_route, opts)
else:
add_to_sitemap(opts)
@@ -41,37 +41,39 @@ class DocType:
sort_order = self.doc.sort_order or "asc"
)):
bean = frappe.bean(self.doc.ref_doctype, name)
# regenerate route
bean.run_method("on_update")
def rebuild_website_sitemap_config():
def rebuild_website_template():
# TODO
frappe.flags.in_rebuild_config = True
frappe.conn.sql("""delete from `tabWebsite Sitemap Config`""")
frappe.conn.sql("""delete from `tabWebsite Template`""")
for app in frappe.get_installed_apps():
if app=="webnotes": app="frappe"
build_website_sitemap_config(app)
build_website_template(app)
cleanup_sitemap()
frappe.flags.in_rebuild_config = False
# enable nested set and rebuild
rebuild_tree("Website Sitemap", "parent_website_sitemap")
rebuild_tree("Website Route", "parent_website_route")
frappe.conn.commit()


def build_website_sitemap_config(app):
def build_website_template(app):
config = {"pages": {}, "generators":{}}
pages, generators = get_pages_and_generators(app)
for args in pages:
add_website_sitemap_config(*args)
add_website_template(**args)

for args in generators:
add_website_sitemap_config(*args)
add_website_template(**args)
frappe.conn.commit()

@@ -87,17 +89,19 @@ def get_pages_and_generators(app):
fname = frappe.utils.cstr(fname)
if fname.split(".")[-1] in ("html", "xml", "js", "css"):
if config_type=="pages":
pages.append(["Page", app, path, fname, app_path])
pages.append({"page_or_generator": "Page", "app": app, "path": path,
"fname":fname, "app_path":app_path})
else:
generators.append(["Generator", app, path, fname, app_path])
generators.append({"page_or_generator": "Generator", "app": app, "path": path,
"fname":fname, "app_path":app_path})
return pages, generators
def add_website_sitemap_config(page_or_generator, app, path, fname, app_path):
def add_website_template(page_or_generator, app, path, fname, app_path):
name = fname[:-5] if fname.endswith(".html") else fname
wsc = frappe._dict({
"doctype": "Website Sitemap Config",
"doctype": "Website Template",
"page_or_generator": page_or_generator,
"link_name": name,
"template_path": os.path.relpath(os.path.join(path, fname), app_path),
@@ -119,9 +123,9 @@ def add_website_sitemap_config(page_or_generator, app, path, fname, app_path):
wsc.base_template_path = getattr(module, "base_template_path", None)
wsc.page_title = getattr(module, "page_title", _(name.title()))
if frappe.conn.exists("Website Sitemap Config", wsc.link_name):
if frappe.conn.exists("Website Template", wsc.link_name):
# found by earlier app, override
frappe.conn.sql("""delete from `tabWebsite Sitemap Config` where name=%s""", (wsc.link_name,))
frappe.conn.sql("""delete from `tabWebsite Template` where name=%s""", (wsc.link_name,))
frappe.bean(wsc).insert()

frappe/website/doctype/website_sitemap_config/website_sitemap_config.txt → frappe/website/doctype/website_template/website_template.txt 查看文件

@@ -2,7 +2,7 @@
{
"creation": "2013-11-18 15:35:00",
"docstatus": 0,
"modified": "2014-02-18 15:22:32",
"modified": "2014-02-24 12:47:44",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -16,7 +16,7 @@
{
"doctype": "DocField",
"name": "__common__",
"parent": "Website Sitemap Config",
"parent": "Website Template",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
@@ -28,7 +28,7 @@
"doctype": "DocPerm",
"export": 0,
"name": "__common__",
"parent": "Website Sitemap Config",
"parent": "Website Template",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
@@ -39,7 +39,7 @@
},
{
"doctype": "DocType",
"name": "Website Sitemap Config"
"name": "Website Template"
},
{
"doctype": "DocField",

+ 2
- 2
frappe/website/page/sitemap_browser/sitemap_browser.js 查看文件

@@ -85,7 +85,7 @@ frappe.website.SitemapBrowser = Class.extend({
},
open: function() {
var node = this.selected_node();
frappe.set_route("Form", "Website Sitemap", node.data("label"));
frappe.set_route("Form", "Website Route", node.data("label"));
},
up_or_down: function(up_or_down) {
var node = this.tree.get_selected_node();
@@ -115,7 +115,7 @@ frappe.website.SitemapBrowser = Class.extend({
fieldname: "new_parent",
label: "New Parent",
reqd: 1,
options: "Website Sitemap"
options: "Website Route"
},
{
fieldtype: "Button",


+ 13
- 13
frappe/website/page/sitemap_browser/sitemap_browser.py 查看文件

@@ -7,28 +7,28 @@ from frappe.website.render import clear_cache

@frappe.whitelist()
def get_children(parent=None):
if not frappe.has_permission("Website Sitemap"):
if not frappe.has_permission("Website Route"):
raise frappe.PermissionError
if parent=="Sitemap":
parent = ""

return frappe.conn.sql("""select name as value, 1 as expandable, ref_doctype, docname
from `tabWebsite Sitemap` where
ifnull(parent_website_sitemap, '')=%s
from `tabWebsite Route` where
ifnull(parent_website_route, '')=%s
order by ifnull(idx,0), name asc""", parent, as_dict=True)
@frappe.whitelist()
def move(name, up_or_down):
ret = None
if not frappe.has_permission("Website Sitemap"):
if not frappe.has_permission("Website Route"):
raise frappe.PermissionError

sitemap = frappe.doc("Website Sitemap", name)
sitemap = frappe.doc("Website Route", name)
if up_or_down=="up":
if sitemap.idx > 0:
prev = frappe.doc("Website Sitemap", {
"parent_website_sitemap": sitemap.parent_website_sitemap,
prev = frappe.doc("Website Route", {
"parent_website_route": sitemap.parent_website_route,
"idx": sitemap.idx - 1
})
if prev.name:
@@ -40,8 +40,8 @@ def move(name, up_or_down):
ret = "ok"

else:
nexts = frappe.doc("Website Sitemap", {
"parent_website_sitemap": sitemap.parent_website_sitemap,
nexts = frappe.doc("Website Route", {
"parent_website_route": sitemap.parent_website_route,
"idx": sitemap.idx + 1
})
if nexts.name:
@@ -57,16 +57,16 @@ def move(name, up_or_down):
@frappe.whitelist()
def update_parent(name, new_parent):
if not frappe.has_permission("Website Sitemap"):
if not frappe.has_permission("Website Route"):
raise frappe.PermissionError
sitemap = frappe.doc("Website Sitemap", name)
sitemap = frappe.doc("Website Route", name)
if sitemap.ref_doctype:
generator = frappe.bean(sitemap.ref_doctype, sitemap.docname)
if not generator.meta.has_field("parent_website_sitemap"):
if not generator.meta.has_field("parent_website_route"):
frappe.throw("Does not allow moving.")
generator.doc.parent_website_sitemap = new_parent
generator.doc.parent_website_route = new_parent
generator.save()
else:
frappe.msgprint("Template Pages cannot be moved.")


+ 2
- 2
frappe/website/page/website_home/website_home.js 查看文件

@@ -52,7 +52,7 @@ frappe.module_page["Website"] = [
{
label: frappe._("Website Page Permission"),
description: frappe._("Define read, write, admin permissions for a Website Page."),
doctype:"Website Sitemap Permission",
doctype:"Website Route Permission",
},
]
},
@@ -65,7 +65,7 @@ frappe.module_page["Website"] = [
{
"route":"sitemap-browser",
"label":frappe._("Sitemap Browser"),
"description":frappe._("View or manage Website Sitemap tree."),
"description":frappe._("View or manage Website Route tree."),
doctype:"Website Settings",
icon: "icon-sitemap"
},


+ 33
- 27
frappe/website/permissions.py 查看文件

@@ -7,17 +7,17 @@ import frappe

def remove_empty_permissions():
permissions_cache_to_be_cleared = frappe.conn.sql_list("""select distinct profile
from `tabWebsite Sitemap Permission`
from `tabWebsite Route Permission`
where ifnull(`read`, 0)=0 and ifnull(`write`, 0)=0 and ifnull(`admin`, 0)=0""")
frappe.conn.sql("""delete from `tabWebsite Sitemap Permission`
frappe.conn.sql("""delete from `tabWebsite Route Permission`
where ifnull(`read`, 0)=0 and ifnull(`write`, 0)=0 and ifnull(`admin`, 0)=0""")
clear_permissions(permissions_cache_to_be_cleared)

def get_access(sitemap_page, profile=None):
profile = profile or frappe.session.user
key = "website_sitemap_permissions:{}".format(profile)
key = "website_route_permissions:{}".format(profile)
cache = frappe.cache()
permissions = cache.get_value(key) or {}
@@ -28,37 +28,43 @@ def get_access(sitemap_page, profile=None):
return permissions.get(sitemap_page)
def _get_access(sitemap_page, profile):
lft, rgt, public_read, public_write = frappe.conn.get_value("Website Sitemap", sitemap_page,
["lft", "rgt", "public_read", "public_write"])
lft, rgt, public_read, public_write, page_or_generator = frappe.conn.get_value("Website Route", sitemap_page,
["lft", "rgt", "public_read", "public_write", "page_or_generator"])

if not (lft and rgt):
raise frappe.ValidationError("Please rebuild Website Sitemap Tree")
read = write = admin = private_read = 0

if page_or_generator=="Generator":

if not (lft and rgt):
raise frappe.ValidationError("Please rebuild Website Route Tree")
if profile == "Guest":
return { "read": public_read, "write": 0, "admin": 0 }
if profile == "Guest":
return { "read": public_read, "write": 0, "admin": 0 }
read = write = admin = private_read = 0

if public_write:
read = write = 1
elif public_read:
read = 1
if public_write:
read = write = 1
elif public_read:
read = 1

for perm in frappe.conn.sql("""select wsp.`read`, wsp.`write`, wsp.`admin`,
ws.lft, ws.rgt, ws.name
from `tabWebsite Sitemap Permission` wsp, `tabWebsite Sitemap` ws
where wsp.profile = %s and wsp.website_sitemap = ws.name
order by lft asc""", (profile,), as_dict=True):
if perm.lft <= lft and perm.rgt >= rgt:
if not (public_read or private_read): private_read = perm.read
if not read: read = perm.read
if not write: write = perm.write
if not admin: admin = perm.admin
if write: read = write
for perm in frappe.conn.sql("""select wsp.`read`, wsp.`write`, wsp.`admin`,
ws.lft, ws.rgt, ws.name
from `tabWebsite Route Permission` wsp, `tabWebsite Route` ws
where wsp.profile = %s and wsp.website_route = ws.name
order by lft asc""", (profile,), as_dict=True):
if perm.lft <= lft and perm.rgt >= rgt:
if not (public_read or private_read): private_read = perm.read
if not read: read = perm.read
if not write: write = perm.write
if not admin: admin = perm.admin
if write: read = write
if read and write and admin:
break

else:
read = write = admin = private_read = 1
return { "read": read, "write": write, "admin": admin, "private_read": private_read }

def clear_permissions(profiles=None):
@@ -69,4 +75,4 @@ def clear_permissions(profiles=None):
cache = frappe.cache()
for profile in profiles:
cache.delete_value("website_sitemap_permissions:{}".format(profile))
cache.delete_value("website_route_permissions:{}".format(profile))

+ 1
- 1
frappe/website/render.py 查看文件

@@ -111,7 +111,7 @@ def clear_cache(path=None):
delete_page_cache(path)
else:
for p in frappe.conn.sql_list("""select name from `tabWebsite Sitemap`"""):
for p in frappe.conn.sql_list("""select name from `tabWebsite Route`"""):
if p is not None:
delete_page_cache(p)


+ 7
- 7
frappe/website/sitemap.py 查看文件

@@ -21,11 +21,11 @@ def get_sitemap_options(path):
return frappe._dict(sitemap_options)
def build_sitemap_options(path):
sitemap_options = frappe.doc("Website Sitemap", path).fields
sitemap_options = frappe.doc("Website Route", path).fields
home_page = get_home_page()
sitemap_config = frappe.doc("Website Sitemap Config",
sitemap_options.get("website_sitemap_config")).fields
sitemap_config = frappe.doc("Website Template",
sitemap_options.get("website_template")).fields
# get sitemap config fields too
for fieldname in ("base_template_path", "template_path", "controller", "no_cache", "no_sitemap",
@@ -41,18 +41,18 @@ def build_sitemap_options(path):
sitemap_options.children = frappe.conn.sql("""select url as name, label as page_title,
1 as public_read from `tabTop Bar Item` where parentfield='sidebar_items' order by idx""", as_dict=True)
else:
sitemap_options.children = frappe.conn.sql("""select * from `tabWebsite Sitemap`
where ifnull(parent_website_sitemap,'')=%s
sitemap_options.children = frappe.conn.sql("""select * from `tabWebsite Route`
where ifnull(parent_website_route,'')=%s
and public_read=1 order by -idx desc, page_title asc""", pathname, as_dict=True)
# establish hierarchy
sitemap_options.parents = frappe.conn.sql("""select name, page_title from `tabWebsite Sitemap`
sitemap_options.parents = frappe.conn.sql("""select name, page_title from `tabWebsite Route`
where lft < %s and rgt > %s order by lft asc""", (sitemap_options.lft, sitemap_options.rgt), as_dict=True)

if not sitemap_options.no_sidebar:
set_sidebar_items(sitemap_options.pathname)
if not sitemap_options.children:
set_sidebar_items(sitemap_options.parent_website_sitemap)
set_sidebar_items(sitemap_options.parent_website_route)

# determine templates to be used
if not sitemap_options.base_template_path:


+ 7
- 7
frappe/website/website_generator.py 查看文件

@@ -6,7 +6,7 @@ import frappe
from frappe.model.controller import DocListController
from frappe.website.utils import cleanup_page_name

from frappe.website.doctype.website_sitemap.website_sitemap import add_to_sitemap, update_sitemap, remove_sitemap
from frappe.website.doctype.website_route.website_route import add_to_sitemap, update_sitemap, remove_sitemap

def call_website_generator(bean, method, *args, **kwargs):
getattr(WebsiteGenerator(bean.doc, bean.doclist), method)(*args, **kwargs)
@@ -26,11 +26,11 @@ class WebsiteGenerator(DocListController):
return page_name

def get_parent_website_sitemap(self):
return self.doc.parent_website_sitemap
def get_parent_website_route(self):
return self.doc.parent_website_route

def setup_generator(self):
self._website_config = frappe.conn.get_values("Website Sitemap Config",
self._website_config = frappe.conn.get_values("Website Template",
{"ref_doctype": self.doc.doctype}, "*")[0]

def on_update(self):
@@ -38,7 +38,7 @@ class WebsiteGenerator(DocListController):
frappe.add_version(self.doclist)
def after_rename(self, olddn, newdn, merge):
frappe.conn.sql("""update `tabWebsite Sitemap`
frappe.conn.sql("""update `tabWebsite Route`
set docname=%s where ref_doctype=%s and docname=%s""", (newdn, self.doc.doctype, olddn))
if merge:
@@ -63,7 +63,7 @@ class WebsiteGenerator(DocListController):
def add_or_update_sitemap(self):
page_name = self.get_page_name()
existing_site_map = frappe.conn.get_value("Website Sitemap", {"ref_doctype": self.doc.doctype,
existing_site_map = frappe.conn.get_value("Website Route", {"ref_doctype": self.doc.doctype,
"docname": self.doc.name})
opts = frappe._dict({
@@ -74,7 +74,7 @@ class WebsiteGenerator(DocListController):
"page_name": page_name,
"link_name": self._website_config.name,
"lastmod": frappe.utils.get_datetime(self.doc.modified).strftime("%Y-%m-%d"),
"parent_website_sitemap": self.get_parent_website_sitemap(),
"parent_website_route": self.get_parent_website_route(),
"page_title": self.get_page_title(),
"public_read": 1 if not self._website_config.no_sidebar else 0
})


正在加载...
取消
保存