diff --git a/webnotes/api.py b/webnotes/api.py index 6a20402d04..444b73b9ad 100644 --- a/webnotes/api.py +++ b/webnotes/api.py @@ -25,7 +25,7 @@ def handle(): """ parts = webnotes.request.path[1:].split("/") call = doctype = name = None - + if len(parts) > 1: call = parts[1] diff --git a/webnotes/cli.py b/webnotes/cli.py index ec2047a8ee..88d055c028 100755 --- a/webnotes/cli.py +++ b/webnotes/cli.py @@ -633,9 +633,18 @@ def serve(port=8000, profile=False): @cmd def request(args): import webnotes.handler + import webnotes.api webnotes.connect() - webnotes.form_dict = webnotes._dict([a.split("=") for a in args.split("&")]) + if "?" in args: + webnotes.local.form_dict = webnotes._dict([a.split("=") for a in args.split("?")[-1].split("&")]) + else: + webnotes.local.form_dict = webnotes._dict() + + if args.startswith("/api/method"): + webnotes.local.form_dict.cmd = args.split("?")[0].split("/")[-1] + webnotes.handler.execute_cmd(webnotes.form_dict.cmd) + print webnotes.response webnotes.destroy() diff --git a/webnotes/public/css/bootstrap.css b/webnotes/public/css/bootstrap.css index 0daaedd464..684fb4ff71 100644 --- a/webnotes/public/css/bootstrap.css +++ b/webnotes/public/css/bootstrap.css @@ -5824,4 +5824,3 @@ td.visible-print { display: none !important; } } -/*# sourceMappingURL=bootstrap.css.map */ diff --git a/webnotes/public/js/wn/views/reportview.js b/webnotes/public/js/wn/views/reportview.js index 51aac8af0e..b6595e27e0 100644 --- a/webnotes/public/js/wn/views/reportview.js +++ b/webnotes/public/js/wn/views/reportview.js @@ -290,6 +290,9 @@ wn.views.ReportView = wn.ui.Listing.extend({ }); this.grid.onHeaderClick.subscribe(function(e, args) { + if(e.target.className === "slick-resizable-handle") + return; + var df = args.column.docfield, sort_by = df.parent + "." + df.fieldname; diff --git a/webnotes/templates/generators/website_group.html b/webnotes/templates/generators/website_group.html index dbbed07c94..0a88766ace 100644 --- a/webnotes/templates/generators/website_group.html +++ b/webnotes/templates/generators/website_group.html @@ -26,6 +26,7 @@ {%- endif -%} website.group = "{{ group.name }}"; website.view = "{{ view.name }}"; + website.pathname = "{{ pathname }}"; {% include view.template_path %} diff --git a/webnotes/templates/generators/website_group.py b/webnotes/templates/generators/website_group.py index 9fca8cc909..642467b541 100644 --- a/webnotes/templates/generators/website_group.py +++ b/webnotes/templates/generators/website_group.py @@ -9,11 +9,11 @@ doctype = "Website Group" no_cache = 1 def get_context(context): - bean = webnotes.bean(context.ref_doctype, context.docname) + bean = context.bean group, view = guess_group_view(bean, context) try: - if not has_access(group, view): + if not has_access(context.access, view): raise webnotes.PermissionError group_context = get_group_context(group, view, bean, context) @@ -92,9 +92,7 @@ def get_views(group_type): return deepcopy(handler.get_views() or {}) return {} -def has_access(group, view): - access = get_access(group) - +def has_access(access, view): if view=="settings": return access.get("admin") elif view in ("add", "edit"): diff --git a/webnotes/templates/website_group/forum.html b/webnotes/templates/website_group/forum.html index fc7989c014..df97d4f54d 100644 --- a/webnotes/templates/website_group/forum.html +++ b/webnotes/templates/website_group/forum.html @@ -15,7 +15,8 @@ $(function() { limit_start: $(".post").length, limit_length: 20, group: website.group, - view: website.view + view: website.view, + pathname: website.pathname }, $wrapper: $(".post-list") }); diff --git a/webnotes/templates/website_group/forum.py b/webnotes/templates/website_group/forum.py index 3dc145d50c..4209826697 100644 --- a/webnotes/templates/website_group/forum.py +++ b/webnotes/templates/website_group/forum.py @@ -15,7 +15,7 @@ def get_context(group_context): forum_context = {} if group_context.view.name in ("popular", "feed"): - forum_context["post_list_html"] = get_post_list_html(group_context["group"]["name"], group_context["view"]) + forum_context["post_list_html"] = get_post_list_html(group_context["group"]["name"], group_context["view"], group_context.pathname) elif group_context.view.name == "edit": forum_context["session_user"] = webnotes.session.user @@ -30,8 +30,9 @@ def get_context(group_context): return forum_context @webnotes.whitelist(allow_guest=True) -def get_post_list_html(group, view, limit_start=0, limit_length=20): - access = get_access(group) +def get_post_list_html(group, view, pathname, limit_start=0, limit_length=20): + print pathname + access = get_access(pathname) if isinstance(view, basestring): view = get_views()[view] diff --git a/webnotes/website/doctype/web_page/web_page.py b/webnotes/website/doctype/web_page/web_page.py index ad638da3b7..1a6f2aa108 100644 --- a/webnotes/website/doctype/web_page/web_page.py +++ b/webnotes/website/doctype/web_page/web_page.py @@ -7,11 +7,7 @@ from webnotes.webutils import WebsiteGenerator from webnotes import _ from markdown2 import markdown -class DocType(WebsiteGenerator): - def autoname(self): - from webnotes.webutils import cleanup_page_name - self.doc.name = cleanup_page_name(self.doc.title) - +class DocType(WebsiteGenerator): def validate(self): for d in self.doclist.get({"parentfield": "toc"}): if d.web_page == self.doc.name: diff --git a/webnotes/website/doctype/website_group/website_group.py b/webnotes/website/doctype/website_group/website_group.py index 779f499913..b9625c9156 100644 --- a/webnotes/website/doctype/website_group/website_group.py +++ b/webnotes/website/doctype/website_group/website_group.py @@ -5,28 +5,14 @@ from __future__ import unicode_literals import webnotes from webnotes.webutils import WebsiteGenerator, cleanup_page_name from webnotes.templates.generators.website_group import get_context +from webnotes.model.doc import make_autoname class DocType(WebsiteGenerator): def __init__(self, d, dl): self.doc, self.doclist = d, dl - + def autoname(self): - self.validate_group_name() - self.doc.name = self.doc.group_name - - def validate(self): - # TODO use titlecase package - self.doc.group_title = self.doc.group_title.title() - self.validate_page_name() - - def validate_group_name(self): - self.doc.group_name = cleanup_page_name(self.doc.group_name or self.doc.group_title) - - def validate_page_name(self): - self.doc.page_name = cleanup_page_name(self.doc.page_name or self.doc.group_name) + self.doc.name = make_autoname("Website-Group-.######") - if not self.doc.page_name: - webnotes.throw(_("Page Name is mandatory"), raise_exception=webnotes.MandatoryError) - def get_page_title(self): - return self.doc.group_title + return self.doc.group_title \ No newline at end of file diff --git a/webnotes/webutils.py b/webnotes/webutils.py index fd47183683..3a8a21ae56 100644 --- a/webnotes/webutils.py +++ b/webnotes/webutils.py @@ -91,12 +91,11 @@ def get_context(page_name): if can_cache(): context = webnotes.cache().get_value(cache_key) - access = get_access(page_name) if not context: context = get_sitemap_options(page_name) # permission may be required for rendering - context["access"] = access + context["access"] = get_access(context.pathname) context = build_context(context) @@ -104,7 +103,9 @@ def get_context(page_name): del context["access"] webnotes.cache().set_value(cache_key, context) - context["access"] = access + else: + context["access"] = get_access(context.pathname) + context.update(context.data or {}) # TODO private pages @@ -309,22 +310,25 @@ def call_website_generator(bean, method, *args, **kwargs): getattr(WebsiteGenerator(bean.doc, bean.doclist), method)(*args, **kwargs) class WebsiteGenerator(DocListController): + def autoname(self): + from webnotes.webutils import cleanup_page_name + self.doc.name = cleanup_page_name(self.get_page_title()) + def set_page_name(self): """set page name based on parent page_name and title""" page_name = cleanup_page_name(self.get_page_title()) - if self.doc.parent_website_sitemap: - page_name = self.doc.parent_website_sitemap + "/" + page_name - webnotes.conn.set(self.doc, self._website_config.page_name_field, page_name) + if self.doc.is_new(): + self.doc.fields[self._website_config.page_name_field] = page_name + else: + webnotes.conn.set(self.doc, self._website_config.page_name_field, page_name) - return page_name - def setup_generator(self): if webnotes.flags.in_install_app: return self._website_config = webnotes.conn.get_values("Website Sitemap Config", {"ref_doctype": self.doc.doctype}, "*")[0] - + def on_update(self): self.update_sitemap()