Переглянути джерело

fixes to sitemap and reportview

version-14
Rushabh Mehta 11 роки тому
джерело
коміт
863e3f8a4a
14 змінених файлів з 79 додано та 35 видалено
  1. +3
    -0
      frappe/__init__.py
  2. +1
    -1
      frappe/core/page/data_import_tool/data_import_tool.py
  3. +4
    -9
      frappe/patches/4_0/set_website_sitemap_idx.py
  4. +20
    -1
      frappe/public/css/app_icon.css
  5. +4
    -1
      frappe/public/js/frappe/form/formatters.js
  6. +2
    -1
      frappe/public/js/frappe/ui/listing.js
  7. +5
    -0
      frappe/public/js/frappe/views/reportview.js
  8. +3
    -3
      frappe/utils/file_manager.py
  9. +2
    -2
      frappe/website/css/website.css
  10. +4
    -3
      frappe/website/doctype/blog_post/blog_post.py
  11. +10
    -1
      frappe/website/doctype/blog_post/blog_post.txt
  12. +16
    -9
      frappe/website/doctype/website_sitemap/website_sitemap.py
  13. +4
    -3
      frappe/website/doctype/website_sitemap_config/website_sitemap_config.py
  14. +1
    -1
      frappe/website/website_generator.py

+ 3
- 0
frappe/__init__.py Переглянути файл

@@ -615,3 +615,6 @@ 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})

+ 1
- 1
frappe/core/page/data_import_tool/data_import_tool.py Переглянути файл

@@ -525,7 +525,7 @@ def import_doclist(path, overwrite=False, ignore_links=False, ignore_insert=Fals
b = frappe.bean(d)
b.ignore_links = ignore_links
if insert:
d.doc.fields["__islocal"] = True
b.doc.fields["__islocal"] = True
try:
b.insert_or_update()
except NameError:


+ 4
- 9
frappe/patches/4_0/set_website_sitemap_idx.py Переглянути файл

@@ -2,13 +2,8 @@ import frappe

def execute():
frappe.conn.sql("""update `tabWebsite Sitemap` set idx=null""")
# frappe.conn.sql("""update `tabWeb Page` set idx=null""")
# frappe.conn.sql("""update `tabBlog Post` set idx=null""")
# frappe.conn.sql("""update `tabBlog Category` set idx=null""")
# frappe.conn.sql("""update `tabWebsite Group` set idx=null""")
# frappe.conn.sql("""delete from `tabTable of Contents`""")

for doctype in ["Blog Category", "Blog Post", "Web Page", "Website Group"]:
for name in frappe.conn.get_values("Website Sitemap", {"ref_doctype":doctype}, "docname"):
frappe.bean(doctype, name[0]).save()
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()

+ 20
- 1
frappe/public/css/app_icon.css Переглянути файл

@@ -1,5 +1,6 @@
.app-icon {
border-radius: 5px;
overflow: hidden;
padding: 20px;
display: inline-block;
margin: auto;
@@ -14,7 +15,7 @@
display: inline-block;
}

.app-icon svg {
.app-icon svg, .app-icon img {
height: 30px;
width: 30px;
}
@@ -27,6 +28,24 @@
padding: 12px;
}

.app-icon-img.app-icon-small {
padding: 0px;
height: 54px;
width: 54px;
}

.app-icon-img {
padding: 0px;
height: 70px;
width: 70px;
}

.app-icon-img img {
width: 100%;
height: 100%;
}


@media (max-width: 768px) {
.app-icon {
padding: 12px;


+ 4
- 1
frappe/public/js/frappe/form/formatters.js Переглянути файл

@@ -34,7 +34,10 @@ frappe.form.formatters = {
return value;
if(!value)
return "";
if(docfield && docfield.options) {
if(docfield && docfield.link_onclick) {
return repl('<a onclick="%(onclick)s">%(value)s</a>',
{onclick: docfield.link_onclick.replace(/"/g, '&quot;'), value:value});
} else if(docfield && docfield.options) {
return repl('%(icon)s<a href="#Form/%(doctype)s/%(name)s">%(label)s</a>', {
doctype: encodeURIComponent(docfield.options),
name: encodeURIComponent(value),


+ 2
- 1
frappe/public/js/frappe/ui/listing.js Переглянути файл

@@ -350,7 +350,7 @@ frappe.ui.Listing = Class.extend({
var v = filter.field.get_parsed_value();
if(v.indexOf(label)!=-1) {
// already set
return false;
return this;
} else {
// second filter set for this field
if(fieldname=='_user_tags') {
@@ -372,5 +372,6 @@ frappe.ui.Listing = Class.extend({
this.filter_list.add_filter(doctype, fieldname, '=', label);
}
}
return this;
}
});

+ 5
- 0
frappe/public/js/frappe/views/reportview.js Переглянути файл

@@ -222,6 +222,11 @@ frappe.views.ReportView = frappe.ui.Listing.extend({
var docfield = columnDef.docfield;
if(docfield.fieldname==="_user_tags") docfield.fieldtype = "Tag";
if(docfield.fieldname==="_comments") docfield.fieldtype = "Comment";
if(docfield.fieldtype==="Link" && docfield.fieldname!=="name") {
docfield.link_onclick =
repl('frappe.container.page.reportview.set_filter("%(fieldname)s", "%(value)s").page.reportview.run()',
{fieldname:docfield.fieldname, value:value});
}
return frappe.format(value, docfield, null, dataContext);
}
}


+ 3
- 3
frappe/utils/file_manager.py Переглянути файл

@@ -41,9 +41,9 @@ def save_uploaded(dt, dn):
raise Exception

def save_url(file_url, dt, dn):
if not (file_url.startswith("http://") or file_url.startswith("https://")):
frappe.msgprint("URL must start with 'http://' or 'https://'")
return None, None
# if not (file_url.startswith("http://") or file_url.startswith("https://")):
# frappe.msgprint("URL must start with 'http://' or 'https://'")
# return None, None
f = frappe.bean({
"doctype": "File Data",


+ 2
- 2
frappe/website/css/website.css Переглянути файл

@@ -4,10 +4,10 @@
}
}

h1, h2, h3, h4, h5 {
/*h1, h2, h3, h4, h5 {
font-weight: bold;
}
*/
a {
cursor: pointer;
}


+ 4
- 3
frappe/website/doctype/blog_post/blog_post.py Переглянути файл

@@ -17,9 +17,6 @@ class DocType(WebsiteGenerator):
def get_page_title(self):
return self.doc.title
def get_parent_website_sitemap(self):
return frappe.conn.get_value("Website Sitemap", {"ref_doctype": "Blog Category", "docname": self.doc.blog_category})

def validate(self):
if not self.doc.blog_intro:
self.doc.blog_intro = self.doc.content[:140]
@@ -31,10 +28,14 @@ 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",
{"ref_doctype": "Blog Category", "docname": self.doc.blog_category})

# update posts
frappe.conn.sql("""update tabBlogger set posts=(select count(*) from `tabBlog Post`
where ifnull(blogger,'')=tabBlogger.name)
where name=%s""", (self.doc.blogger,))

def on_update(self):
WebsiteGenerator.on_update(self)


+ 10
- 1
frappe/website/doctype/blog_post/blog_post.txt Переглянути файл

@@ -2,7 +2,7 @@
{
"creation": "2013-03-28 10:35:30",
"docstatus": 0,
"modified": "2014-02-17 13:00:42",
"modified": "2014-02-20 12:55:06",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -83,6 +83,15 @@
"label": "Blog Category",
"options": "Blog Category"
},
{
"doctype": "DocField",
"fieldname": "parent_website_sitemap",
"fieldtype": "Link",
"hidden": 1,
"label": "Parent Website Sitemap",
"options": "Website Sitemap",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "section_break_5",


+ 16
- 9
frappe/website/doctype/website_sitemap/website_sitemap.py Переглянути файл

@@ -45,18 +45,24 @@ class DocType(DocTypeNestedSet):
def set_idx(self):
if self.doc.idx==None:
self.doc.idx = int(frappe.conn.sql("""select max(ifnull(idx, -1)) from `tabWebsite Sitemap`
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 '',
self.doc.name))[0][0] or 0) + 1
self.doc.name))[0][0]) + 1
else:
if cint(self.doc.idx) != 0 and self.doc.parent_website_sitemap:
if not frappe.conn.sql("""select name from `tabWebsite Sitemap` where
ifnull(parent_website_sitemap, '')=%s and ifnull(idx, -1)=%s""",
(self.doc.parent_website_sitemap or '', cint(self.doc.idx) - 1)):

frappe.throw("{}: {}".format(
_("Sitemap Ordering Error. Index missing"), self.doc.idx-1))
if self.doc.parent_website_sitemap:
self.doc.idx = cint(self.doc.idx)
previous_idx = frappe.conn.sql("""select max(idx)
from `tab{}` where ifnull(parent_website_sitemap, '')=%s
and ifnull(idx, -1) < %s""".format(self.doc.ref_doctype),
(self.doc.parent_website_sitemap, self.doc.idx))[0][0]
if previous_idx and previous_idx != self.doc.idx - 1:
frappe.throw("{}: {}, {}".format(
_("Sitemap Ordering Error. Index missing"), self.doc.name, self.doc.idx-1))

def on_update(self):
if not frappe.flags.in_rebuild_config:
@@ -138,6 +144,7 @@ def update_sitemap(website_sitemap, options):
for key in sitemap_fields:
bean.doc.fields[key] = options.get(key)
if not bean.doc.page_name:
# for pages
bean.doc.page_name = options.link_name


+ 4
- 3
frappe/website/doctype/website_sitemap_config/website_sitemap_config.py Переглянути файл

@@ -32,15 +32,16 @@ class DocType:
condition = ""
if self.doc.condition_field:
condition = " where ifnull(%s, 0)=1" % self.doc.condition_field
for name in frappe.conn.sql_list("""select name from `tab{doctype}`
{condition} order by {sort_field} {sort_order}""".format(
{condition} order by idx asc, {sort_field} {sort_order}""".format(
doctype = self.doc.ref_doctype,
condition = condition,
sort_field = self.doc.sort_field or "name",
sort_order = self.doc.sort_order or "asc"
)):
frappe.bean(self.doc.ref_doctype, name).run_method("on_update")
bean = frappe.bean(self.doc.ref_doctype, name)
bean.run_method("on_update")
def rebuild_website_sitemap_config():
# TODO


+ 1
- 1
frappe/website/website_generator.py Переглянути файл

@@ -85,7 +85,7 @@ class WebsiteGenerator(DocListController):
else:
idx = add_to_sitemap(opts)
if idx and self.doc.idx != idx:
if idx!=None and self.doc.idx != idx:
frappe.conn.set(self.doc, "idx", idx)
def update_permissions(self, opts):


Завантаження…
Відмінити
Зберегти