diff --git a/webnotes/__init__.py b/webnotes/__init__.py index 10fe74690a..df30cb4e43 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -109,6 +109,7 @@ def init(site, sites_path=None): local.restrictions = None local.user_perms = {} local.test_objects = {} + local.jenv = None setup_module_map() @@ -364,9 +365,9 @@ def reload_doc(module, dt=None, dn=None, force=False): import webnotes.modules return webnotes.modules.reload_doc(module, dt, dn, force=force) -def rename_doc(doctype, old, new, debug=0, force=False, merge=False): +def rename_doc(doctype, old, new, debug=0, force=False, merge=False, ignore_permissions=False): from webnotes.model.rename_doc import rename_doc - return rename_doc(doctype, old, new, force=force, merge=merge) + return rename_doc(doctype, old, new, force=force, merge=merge, ignore_permissions=ignore_permissions) def insert(doclist): import webnotes.model @@ -544,11 +545,8 @@ def get_list(doctype, filters=None, fields=None, docstatus=None, group_by=group_by, order_by=order_by, limit_start=limit_start, limit_page_length=limit_page_length, as_list=as_list, debug=debug) -jenv = None - def get_jenv(): - global jenv - if not jenv: + if not local.jenv: from jinja2 import Environment, ChoiceLoader, PackageLoader, DebugUndefined import webnotes.utils @@ -567,7 +565,9 @@ def get_jenv(): "_": _ }) - return jenv + local.jenv = jenv + + return local.jenv def set_filters(jenv): from webnotes.utils import global_date_format diff --git a/webnotes/cli.py b/webnotes/cli.py index abe4ae66f5..ec2047a8ee 100755 --- a/webnotes/cli.py +++ b/webnotes/cli.py @@ -188,6 +188,8 @@ def setup_utilities(parser): help="Clear website cache") parser.add_argument("--build_sitemap", default=False, action="store_true", help="Build Website Sitemap") + 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", help="Clear cache, doctype cache and defaults") parser.add_argument("--reset_perms", default=False, action="store_true", @@ -441,6 +443,14 @@ def build_sitemap(): rebuild_config() webnotes.destroy() +@cmd +def sync_statics(): + from webnotes.website.doctype.web_page import web_page + webnotes.connect() + web_page.sync_statics() + webnotes.conn.commit() + webnotes.destroy() + @cmd def reset_perms(): webnotes.connect() diff --git a/webnotes/core/doctype/communication/communication.py b/webnotes/core/doctype/communication/communication.py index afc2e72d3d..8dce5ee0ee 100644 --- a/webnotes/core/doctype/communication/communication.py +++ b/webnotes/core/doctype/communication/communication.py @@ -37,7 +37,7 @@ def make(doctype=None, name=None, content=None, subject=None, sent_or_received = raise webnotes.PermissionError("You are not allowed to send emails related to: {doctype} {name}".format( doctype=doctype, name=name)) - _send(doctype=doctype, name=name, content=content, subject=subject, sent_or_received=sent_or_received, + _make(doctype=doctype, name=name, content=content, subject=subject, sent_or_received=sent_or_received, sender=sender, recipients=recipients, communication_medium=communication_medium, send_email=send_email, print_html=print_html, attachments=attachments, send_me_a_copy=send_me_a_copy, set_lead=set_lead, date=date) @@ -116,9 +116,13 @@ def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', s d.content = sent_via.get_content(d) footer = set_portal_link(sent_via, d) - + + send_print_in_body = webnotes.conn.get_value("Email Settings", None, "send_print_in_body_and_attachment") + if not send_print_in_body: + d.content += "

Please see attachment for document details.

" + mail = get_email(d.recipients, sender=d.sender, subject=d.subject, - msg=d.content, footer=footer) + msg=d.content, footer=footer, print_html=print_html if send_print_in_body else None) if send_me_a_copy: mail.cc.append(webnotes.conn.get_value("Profile", webnotes.session.user, "email")) diff --git a/webnotes/core/page/setup/setup.txt b/webnotes/core/page/setup/setup.txt index faf64a661d..3978b77034 100644 --- a/webnotes/core/page/setup/setup.txt +++ b/webnotes/core/page/setup/setup.txt @@ -2,7 +2,7 @@ { "creation": "2012-06-14 15:07:28", "docstatus": 0, - "modified": "2014-02-07 14:48:08", + "modified": "2014-02-07 14:50:08", "modified_by": "Administrator", "owner": "Administrator" }, diff --git a/webnotes/model/sync.py b/webnotes/model/sync.py index 804651435f..bb0d994b20 100644 --- a/webnotes/model/sync.py +++ b/webnotes/model/sync.py @@ -17,7 +17,7 @@ def sync_all(force=0): webnotes.clear_cache() def sync_for(app_name, force=0, sync_everything = False, verbose=False): - for module_name in webnotes.local.app_modules[app_name]: + for module_name in webnotes.local.app_modules.get(app_name) or []: folder = os.path.dirname(webnotes.get_module(app_name + "." + module_name).__file__) walk_and_sync(folder, force, sync_everything, verbose=verbose) diff --git a/webnotes/public/js/wn/views/communication.js b/webnotes/public/js/wn/views/communication.js index 012f9fde10..d46013def1 100644 --- a/webnotes/public/js/wn/views/communication.js +++ b/webnotes/public/js/wn/views/communication.js @@ -274,22 +274,13 @@ wn.views.CommunicationComposer = Class.extend({ }); }, - send_email: function(btn, form_values, selected_attachments, print_format_html) { + send_email: function(btn, form_values, selected_attachments, print_html) { var me = this; - if(form_values.attach_document_print) { - var print_html = print_format_html; - if(cint(wn.boot.send_print_in_body_and_attachment)) { - form_values.content = form_values.content - + "


" + print_html; - } else { - form_values.content = form_values.content + "

" - + "Please see attachment for document details.

" - } - } else { - var print_html = ""; + if(!form_values.attach_document_print) { + print_html = ""; } - + if(form_values.send_email) { if(cur_frm && !wn.model.can_email(me.doc.doctype, cur_frm)) { msgprint(wn._("You are not allowed to send emails related to this document.")); diff --git a/webnotes/public/js/wn/views/formview.js b/webnotes/public/js/wn/views/formview.js index f7a51be878..970bf43dfa 100644 --- a/webnotes/public/js/wn/views/formview.js +++ b/webnotes/public/js/wn/views/formview.js @@ -37,7 +37,7 @@ wn.views.FormFactory = wn.views.Factory.extend({ // doc not found, but starts with New, // make a new doc and set it var new_str = wn._("New") + " "; - if(dn && dn.substr(0, new_str.length)==new_star) { + if(dn && dn.substr(0, new_str.length)==new_str) { var new_name = wn.model.make_new_doc_and_get_name(dt); if(new_name===dn) { me.load(dt, dn); diff --git a/webnotes/templates/emails/standard.html b/webnotes/templates/emails/standard.html index 12fc2ea276..0ecfafd6a3 100644 --- a/webnotes/templates/emails/standard.html +++ b/webnotes/templates/emails/standard.html @@ -8,14 +8,6 @@ /* ------------------------------------- GLOBAL ------------------------------------- */ -* { - margin:0; - padding:0; - font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; - font-size: 100%; - line-height: 1.6; -} - img { max-width: 100%; } @@ -23,15 +15,26 @@ img { body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; - width: 100%!important; + width: 100% !important; height: 100%; +} + +.wrapper { background-color: #eee; } +.wrapper * { + margin:0; + padding:0; + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; + font-size: 100%; + line-height: 1.6; +} + /* ------------------------------------- ELEMENTS ------------------------------------- */ -a { +.wrapper a { color: #348eda; } @@ -69,7 +72,7 @@ a { margin-bottom: 0; } -.first{ +.first { margin-top: 0; } @@ -113,7 +116,9 @@ table.footer-wrap a{ /* ------------------------------------- TYPOGRAPHY ------------------------------------- */ -h1,h2,h3{ +.wrapper h1, +.wrapper h2, +.wrapper h3{ font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; line-height: 1.1; margin-top:15px; @@ -123,26 +128,29 @@ h1,h2,h3{ font-weight:200; } -h1 { +.wrapper h1 { font-size: 36px; } -h2 { +.wrapper h2 { font-size: 28px; } -h3 { +.wrapper h3 { font-size: 22px; } -hr { +.wrapper hr { margin: 20px 0; border-top: 1px solid #eee; } -p, ul, ol { +.wrapper p, +.wrapper ul, +.wrapper ol { margin-bottom: 10px; font-weight: normal; font-size:14px; } -ul li, ol li { +.wrapper ul li, +.wrapper ol li { margin-left:5px; list-style-position: inside; } @@ -180,7 +188,9 @@ ul li, ol li { - + + +
@@ -230,5 +240,9 @@ ul li, ol li {
+
+ + + \ No newline at end of file diff --git a/webnotes/templates/generators/web_page.html b/webnotes/templates/generators/web_page.html index 929d7c9cb7..75768df88b 100644 --- a/webnotes/templates/generators/web_page.html +++ b/webnotes/templates/generators/web_page.html @@ -1,6 +1,6 @@ {% block title %} {{ title }} {% endblock %} -{% block header %}{% if show_title %}

{{ title }}

{% endif %}{% endblock %} +{% block header %}

{{ title }}

{% endblock %} {% block breadcrumbs %}{% include "templates/includes/breadcrumbs.html" %}{% endblock %} diff --git a/webnotes/templates/generators/website_group.py b/webnotes/templates/generators/website_group.py index e99d584a88..9fca8cc909 100644 --- a/webnotes/templates/generators/website_group.py +++ b/webnotes/templates/generators/website_group.py @@ -16,7 +16,7 @@ def get_context(context): if not has_access(group, view): raise webnotes.PermissionError - group_context = get_group_context(group, view, bean) + group_context = get_group_context(group, view, bean, context) group_context.update(context) return group_context @@ -32,7 +32,7 @@ def get_context(context): 'You are not permitted to view this page.' } -def get_group_context(group, view, bean): +def get_group_context(group, view, bean, context): cache_key = "website_group_context:{}:{}".format(group, view) views = get_views(bean.doc.group_type) view = webnotes._dict(views.get(view)) @@ -42,18 +42,18 @@ def get_group_context(group, view, bean): if group_context: return group_context - group_context = build_group_context(group, view, bean, views) + group_context = build_group_context(group, view, bean, views, context) if can_cache(view.get("no_cache")): webnotes.cache().set_value(cache_key, group_context) return group_context -def build_group_context(group, view, bean, views): +def build_group_context(group, view, bean, views, context): title = "{} - {}".format(bean.doc.group_title, view.get("label")) for name, opts in views.iteritems(): - opts["url"] = opts["url"].format(group=group, post="") + opts["url"] = opts["url"].format(pathname=context.pathname, post="") group_context = webnotes._dict({ "group": bean.doc.fields, diff --git a/webnotes/templates/includes/breadcrumbs.html b/webnotes/templates/includes/breadcrumbs.html index b9979cd715..aa7fc5f773 100644 --- a/webnotes/templates/includes/breadcrumbs.html +++ b/webnotes/templates/includes/breadcrumbs.html @@ -1,8 +1,6 @@ -{% if parents -%} -{%- endif %} \ No newline at end of file + \ No newline at end of file diff --git a/webnotes/templates/includes/inline_post.html b/webnotes/templates/includes/inline_post.html index 478b032ef5..a1f14f0036 100644 --- a/webnotes/templates/includes/inline_post.html +++ b/webnotes/templates/includes/inline_post.html @@ -1,5 +1,5 @@ -{% set post_url = "/" + post.website_group + "?view=post&name=" + post.name %} -{% set edit_url = "/" + post.website_group + "?view=edit&name=" + post.name %} +{% set post_url = webnotes.local.request.path + "?view=post&name=" + post.name %} +{% set edit_url = webnotes.local.request.path + "?view=edit&name=" + post.name %}
- {{ brand_html or ""}} + {{ brand_html or "Home"}}