Преглед на файлове

website minor

version-14
Rushabh Mehta преди 11 години
родител
ревизия
3889f901b0
променени са 11 файла, в които са добавени 42 реда и са изтрити 44 реда
  1. +1
    -1
      webnotes/api.py
  2. +10
    -1
      webnotes/cli.py
  3. +0
    -1
      webnotes/public/css/bootstrap.css
  4. +3
    -0
      webnotes/public/js/wn/views/reportview.js
  5. +1
    -0
      webnotes/templates/generators/website_group.html
  6. +3
    -5
      webnotes/templates/generators/website_group.py
  7. +2
    -1
      webnotes/templates/website_group/forum.html
  8. +4
    -3
      webnotes/templates/website_group/forum.py
  9. +1
    -5
      webnotes/website/doctype/web_page/web_page.py
  10. +4
    -18
      webnotes/website/doctype/website_group/website_group.py
  11. +13
    -9
      webnotes/webutils.py

+ 1
- 1
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]


+ 10
- 1
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()



+ 0
- 1
webnotes/public/css/bootstrap.css Целия файл

@@ -5824,4 +5824,3 @@ td.visible-print {
display: none !important;
}
}
/*# sourceMappingURL=bootstrap.css.map */

+ 3
- 0
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;


+ 1
- 0
webnotes/templates/generators/website_group.html Целия файл

@@ -26,6 +26,7 @@
{%- endif -%}
website.group = "{{ group.name }}";
website.view = "{{ view.name }}";
website.pathname = "{{ pathname }}";
</script>

{% include view.template_path %}


+ 3
- 5
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"):


+ 2
- 1
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")
});


+ 4
- 3
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]


+ 1
- 5
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:


+ 4
- 18
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

+ 13
- 9
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()


Зареждане…
Отказ
Запис