@@ -615,3 +615,6 @@ def set_filters(jenv): | |||||
def get_template(path): | def get_template(path): | ||||
return get_jenv().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}) |
@@ -525,7 +525,7 @@ def import_doclist(path, overwrite=False, ignore_links=False, ignore_insert=Fals | |||||
b = frappe.bean(d) | b = frappe.bean(d) | ||||
b.ignore_links = ignore_links | b.ignore_links = ignore_links | ||||
if insert: | if insert: | ||||
d.doc.fields["__islocal"] = True | |||||
b.doc.fields["__islocal"] = True | |||||
try: | try: | ||||
b.insert_or_update() | b.insert_or_update() | ||||
except NameError: | except NameError: | ||||
@@ -2,13 +2,8 @@ import frappe | |||||
def execute(): | def execute(): | ||||
frappe.conn.sql("""update `tabWebsite Sitemap` set idx=null""") | 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 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() |
@@ -1,5 +1,6 @@ | |||||
.app-icon { | .app-icon { | ||||
border-radius: 5px; | border-radius: 5px; | ||||
overflow: hidden; | |||||
padding: 20px; | padding: 20px; | ||||
display: inline-block; | display: inline-block; | ||||
margin: auto; | margin: auto; | ||||
@@ -14,7 +15,7 @@ | |||||
display: inline-block; | display: inline-block; | ||||
} | } | ||||
.app-icon svg { | |||||
.app-icon svg, .app-icon img { | |||||
height: 30px; | height: 30px; | ||||
width: 30px; | width: 30px; | ||||
} | } | ||||
@@ -27,6 +28,24 @@ | |||||
padding: 12px; | 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) { | @media (max-width: 768px) { | ||||
.app-icon { | .app-icon { | ||||
padding: 12px; | padding: 12px; | ||||
@@ -34,7 +34,10 @@ frappe.form.formatters = { | |||||
return value; | return value; | ||||
if(!value) | if(!value) | ||||
return ""; | 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, '"'), value:value}); | |||||
} else if(docfield && docfield.options) { | |||||
return repl('%(icon)s<a href="#Form/%(doctype)s/%(name)s">%(label)s</a>', { | return repl('%(icon)s<a href="#Form/%(doctype)s/%(name)s">%(label)s</a>', { | ||||
doctype: encodeURIComponent(docfield.options), | doctype: encodeURIComponent(docfield.options), | ||||
name: encodeURIComponent(value), | name: encodeURIComponent(value), | ||||
@@ -350,7 +350,7 @@ frappe.ui.Listing = Class.extend({ | |||||
var v = filter.field.get_parsed_value(); | var v = filter.field.get_parsed_value(); | ||||
if(v.indexOf(label)!=-1) { | if(v.indexOf(label)!=-1) { | ||||
// already set | // already set | ||||
return false; | |||||
return this; | |||||
} else { | } else { | ||||
// second filter set for this field | // second filter set for this field | ||||
if(fieldname=='_user_tags') { | if(fieldname=='_user_tags') { | ||||
@@ -372,5 +372,6 @@ frappe.ui.Listing = Class.extend({ | |||||
this.filter_list.add_filter(doctype, fieldname, '=', label); | this.filter_list.add_filter(doctype, fieldname, '=', label); | ||||
} | } | ||||
} | } | ||||
return this; | |||||
} | } | ||||
}); | }); |
@@ -222,6 +222,11 @@ frappe.views.ReportView = frappe.ui.Listing.extend({ | |||||
var docfield = columnDef.docfield; | var docfield = columnDef.docfield; | ||||
if(docfield.fieldname==="_user_tags") docfield.fieldtype = "Tag"; | if(docfield.fieldname==="_user_tags") docfield.fieldtype = "Tag"; | ||||
if(docfield.fieldname==="_comments") docfield.fieldtype = "Comment"; | 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); | return frappe.format(value, docfield, null, dataContext); | ||||
} | } | ||||
} | } | ||||
@@ -41,9 +41,9 @@ def save_uploaded(dt, dn): | |||||
raise Exception | raise Exception | ||||
def save_url(file_url, dt, dn): | 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({ | f = frappe.bean({ | ||||
"doctype": "File Data", | "doctype": "File Data", | ||||
@@ -4,10 +4,10 @@ | |||||
} | } | ||||
} | } | ||||
h1, h2, h3, h4, h5 { | |||||
/*h1, h2, h3, h4, h5 { | |||||
font-weight: bold; | font-weight: bold; | ||||
} | } | ||||
*/ | |||||
a { | a { | ||||
cursor: pointer; | cursor: pointer; | ||||
} | } | ||||
@@ -17,9 +17,6 @@ class DocType(WebsiteGenerator): | |||||
def get_page_title(self): | def get_page_title(self): | ||||
return self.doc.title | 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): | def validate(self): | ||||
if not self.doc.blog_intro: | if not self.doc.blog_intro: | ||||
self.doc.blog_intro = self.doc.content[:140] | 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: | if self.doc.published and not self.doc.published_on: | ||||
self.doc.published_on = today() | 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 | # update posts | ||||
frappe.conn.sql("""update tabBlogger set posts=(select count(*) from `tabBlog Post` | frappe.conn.sql("""update tabBlogger set posts=(select count(*) from `tabBlog Post` | ||||
where ifnull(blogger,'')=tabBlogger.name) | where ifnull(blogger,'')=tabBlogger.name) | ||||
where name=%s""", (self.doc.blogger,)) | where name=%s""", (self.doc.blogger,)) | ||||
def on_update(self): | def on_update(self): | ||||
WebsiteGenerator.on_update(self) | WebsiteGenerator.on_update(self) | ||||
@@ -2,7 +2,7 @@ | |||||
{ | { | ||||
"creation": "2013-03-28 10:35:30", | "creation": "2013-03-28 10:35:30", | ||||
"docstatus": 0, | "docstatus": 0, | ||||
"modified": "2014-02-17 13:00:42", | |||||
"modified": "2014-02-20 12:55:06", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"owner": "Administrator" | "owner": "Administrator" | ||||
}, | }, | ||||
@@ -83,6 +83,15 @@ | |||||
"label": "Blog Category", | "label": "Blog Category", | ||||
"options": "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", | "doctype": "DocField", | ||||
"fieldname": "section_break_5", | "fieldname": "section_break_5", | ||||
@@ -45,18 +45,24 @@ class DocType(DocTypeNestedSet): | |||||
def set_idx(self): | def set_idx(self): | ||||
if self.doc.idx==None: | 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""", | where ifnull(parent_website_sitemap, '')=%s and name!=%s""", | ||||
(self.doc.parent_website_sitemap or '', | (self.doc.parent_website_sitemap or '', | ||||
self.doc.name))[0][0] or 0) + 1 | |||||
self.doc.name))[0][0]) + 1 | |||||
else: | 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): | def on_update(self): | ||||
if not frappe.flags.in_rebuild_config: | if not frappe.flags.in_rebuild_config: | ||||
@@ -138,6 +144,7 @@ def update_sitemap(website_sitemap, options): | |||||
for key in sitemap_fields: | for key in sitemap_fields: | ||||
bean.doc.fields[key] = options.get(key) | bean.doc.fields[key] = options.get(key) | ||||
if not bean.doc.page_name: | if not bean.doc.page_name: | ||||
# for pages | # for pages | ||||
bean.doc.page_name = options.link_name | bean.doc.page_name = options.link_name | ||||
@@ -32,15 +32,16 @@ class DocType: | |||||
condition = "" | condition = "" | ||||
if self.doc.condition_field: | if self.doc.condition_field: | ||||
condition = " where ifnull(%s, 0)=1" % 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}` | 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, | doctype = self.doc.ref_doctype, | ||||
condition = condition, | condition = condition, | ||||
sort_field = self.doc.sort_field or "name", | sort_field = self.doc.sort_field or "name", | ||||
sort_order = self.doc.sort_order or "asc" | 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(): | def rebuild_website_sitemap_config(): | ||||
# TODO | # TODO | ||||
@@ -85,7 +85,7 @@ class WebsiteGenerator(DocListController): | |||||
else: | else: | ||||
idx = add_to_sitemap(opts) | 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) | frappe.conn.set(self.doc, "idx", idx) | ||||
def update_permissions(self, opts): | def update_permissions(self, opts): | ||||