diff --git a/frappe/__init__.py b/frappe/__init__.py index 59507ea25b..67fda8b335 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -397,9 +397,10 @@ def has_website_permission(doctype, ptype="read", doc=None, user=None, verbose=F :param doc: Checks User permissions for given doc. :param user: [optional] Check for given user. Default: current user.""" - if not user: user = session.user + if not user: + user = session.user - for method in get_hooks("has_website_permission").get(doctype, []): + for method in (get_hooks("has_website_permission") or {}).get(doctype, []): if not call(get_attr(method), doc=doc, ptype=ptype, user=user, verbose=verbose): return False @@ -905,21 +906,32 @@ def get_print(doctype, name, print_format=None, style=None, as_pdf=False): else: return html -def attach_print(doctype, name, file_name): +def attach_print(doctype, name, file_name=None): from frappe.utils import scrub_urls + if not file_name: file_name = name + print_settings = db.get_singles_dict("Print Settings") + + local.flags.ignore_print_permissions = True + if int(print_settings.send_print_as_pdf or 0): - return { + out = { "fname": file_name + ".pdf", "fcontent": get_print(doctype, name, as_pdf=True) } else: - return { + out = { "fname": file_name + ".html", "fcontent": scrub_urls(get_print(doctype, name)).encode("utf-8") } + print print_settings, out + + local.flags.ignore_print_permissions = False + + return out + logging_setup_complete = False def get_logger(module=None): from frappe.setup_logging import setup_logging diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index 49e53b899b..380f284967 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -119,6 +119,12 @@ class DocType(Document): delete_notification_count_for(doctype=self.name) frappe.clear_cache(doctype=self.name) + # save singles when made + if self.issingle and not frappe.db.get_singles_dict(self.name): + doc = frappe.new_doc(self.name) + doc.flags.ignore_mandatory=True + doc.save() + def before_rename(self, old, new, merge=False): """Throw exception if merge. DocTypes cannot be merged.""" if merge: diff --git a/frappe/email/doctype/email_alert/email_alert.json b/frappe/email/doctype/email_alert/email_alert.json index 6e97754cea..a97d396651 100644 --- a/frappe/email/doctype/email_alert/email_alert.json +++ b/frappe/email/doctype/email_alert/email_alert.json @@ -118,6 +118,13 @@ "permlevel": 0, "reqd": 1 }, + { + "fieldname": "attach_print", + "fieldtype": "Check", + "label": "Attach Print", + "permlevel": 0, + "precision": "" + }, { "fieldname": "message_examples", "fieldtype": "HTML", @@ -127,7 +134,7 @@ } ], "icon": "icon-envelope", - "modified": "2015-02-05 05:11:37.924396", + "modified": "2015-03-11 16:43:51.288063", "modified_by": "Administrator", "module": "Email", "name": "Email Alert", diff --git a/frappe/email/doctype/email_alert/email_alert.py b/frappe/email/doctype/email_alert/email_alert.py index e5324258eb..ebd45d5bed 100644 --- a/frappe/email/doctype/email_alert/email_alert.py +++ b/frappe/email/doctype/email_alert/email_alert.py @@ -90,6 +90,9 @@ def evaluate_alert(doc, alert, event): return # send alert + print "test" + frappe.sendmail(recipients=recipients, subject=alert.subject, message= frappe.render_template(alert.message, {"doc": doc, "alert":alert}), - bulk=True, ref_doctype = doc.doctype, ref_docname = doc.name) + bulk=True, ref_doctype = doc.doctype, ref_docname = doc.name, + attachments = [frappe.attach_print(doc.doctype, doc.name)] if alert.attach_print else None) diff --git a/frappe/public/css/common.css b/frappe/public/css/common.css index bcca7545a5..3a71ec83c1 100644 --- a/frappe/public/css/common.css +++ b/frappe/public/css/common.css @@ -46,26 +46,23 @@ a.disabled:hover { } a.grey, .sidebar-section a, -.nav-pills a, .control-value a, .data-row a { - text-decoration: underline; + text-decoration: none; } a.grey:hover, .sidebar-section a:hover, -.nav-pills a:hover, .control-value a:hover, .data-row a:hover, a.grey:focus, .sidebar-section a:focus, -.nav-pills a:focus, .control-value a:focus, .data-row a:focus { text-decoration: underline; } a.text-muted, a.text-extra-muted { - text-underline: none; + text-decoration: none; } a.text-muted:hover, a.text-muted:focus, diff --git a/frappe/public/css/desk.css b/frappe/public/css/desk.css index 7a9b8320b0..bde4e82f8f 100644 --- a/frappe/public/css/desk.css +++ b/frappe/public/css/desk.css @@ -46,26 +46,23 @@ a.disabled:hover { } a.grey, .sidebar-section a, -.nav-pills a, .control-value a, .data-row a { - text-decoration: underline; + text-decoration: none; } a.grey:hover, .sidebar-section a:hover, -.nav-pills a:hover, .control-value a:hover, .data-row a:hover, a.grey:focus, .sidebar-section a:focus, -.nav-pills a:focus, .control-value a:focus, .data-row a:focus { text-decoration: underline; } a.text-muted, a.text-extra-muted { - text-underline: none; + text-decoration: none; } a.text-muted:hover, a.text-muted:focus, diff --git a/frappe/public/css/sidebar.css b/frappe/public/css/sidebar.css index d7770ee4ef..3219888e0e 100644 --- a/frappe/public/css/sidebar.css +++ b/frappe/public/css/sidebar.css @@ -85,7 +85,6 @@ body[data-route^="Module"] .main-menu .form-sidebar { display: none !important; } .layout-side-section .sidebar-menu > li > a { - text-decoration: underline; display: inline-block; } .layout-side-section .sidebar-menu { diff --git a/frappe/public/css/website.css b/frappe/public/css/website.css index 96c4c55dd8..35ba21a02e 100644 --- a/frappe/public/css/website.css +++ b/frappe/public/css/website.css @@ -46,26 +46,23 @@ a.disabled:hover { } a.grey, .sidebar-section a, -.nav-pills a, .control-value a, .data-row a { - text-decoration: underline; + text-decoration: none; } a.grey:hover, .sidebar-section a:hover, -.nav-pills a:hover, .control-value a:hover, .data-row a:hover, a.grey:focus, .sidebar-section a:focus, -.nav-pills a:focus, .control-value a:focus, .data-row a:focus { text-decoration: underline; } a.text-muted, a.text-extra-muted { - text-underline: none; + text-decoration: none; } a.text-muted:hover, a.text-muted:focus, @@ -539,6 +536,12 @@ fieldset { border-top: 1px solid #d1d8dd; margin: 0px -15px -20px -15px; } +.blog-text { + padding: 15px 0px; +} +.blog-text p { + margin-bottom: 30px; +} .blogger { padding: 10px 15px; border-top: 1px solid #d1d8dd; @@ -685,7 +688,7 @@ a.active { .offcanvas .sidebar-menu { margin-bottom: 0; } - .offcanvas ul { + .offcanvas .sidebar ul { margin: 0px; } .offcanvas .sidebar-page-sidebar { diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index ce0c942b4a..02aca005ef 100644 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -902,7 +902,7 @@ frappe.ui.form.ControlLink = frappe.ui.form.ControlData.extend({ $('').prependTo(this.input_area); diff --git a/frappe/public/less/common.less b/frappe/public/less/common.less index 1601f96439..7e5be68561 100644 --- a/frappe/public/less/common.less +++ b/frappe/public/less/common.less @@ -47,17 +47,17 @@ a.disabled, a.disabled:hover { text-decoration: none; } -a.grey, .sidebar-section a, .nav-pills a, .control-value a, .data-row a { - .underline(); +a.grey, .sidebar-section a, .control-value a, .data-row a { + text-decoration: none; } -a.grey:hover, .sidebar-section a:hover, .nav-pills a:hover, .control-value a:hover, .data-row a:hover, -a.grey:focus, .sidebar-section a:focus, .nav-pills a:focus, .control-value a:focus, .data-row a:focus { - .underline-hover(); +a.grey:hover, .sidebar-section a:hover, .control-value a:hover, .data-row a:hover, +a.grey:focus, .sidebar-section a:focus, .control-value a:focus, .data-row a:focus { + text-decoration: underline; } a.text-muted, a.text-extra-muted { - text-underline: none; + text-decoration: none; } a.text-muted:hover, diff --git a/frappe/public/less/sidebar.less b/frappe/public/less/sidebar.less index fe718e8f14..64279e1974 100644 --- a/frappe/public/less/sidebar.less +++ b/frappe/public/less/sidebar.less @@ -43,7 +43,6 @@ body[data-route^="Module"] .main-menu { } .sidebar-menu > li > a { - .underline; display: inline-block; } diff --git a/frappe/public/less/website.less b/frappe/public/less/website.less index 7260c8ef96..472aa78744 100644 --- a/frappe/public/less/website.less +++ b/frappe/public/less/website.less @@ -244,6 +244,14 @@ fieldset { margin: 0px -15px -20px -15px; } +.blog-text { + padding: 15px 0px; + + p { + margin-bottom: 30px; + } +} + .blogger { padding: 10px 15px; border-top: 1px solid @border-color; @@ -363,7 +371,7 @@ a.active { .offcanvas-mobile-mixin(); .offcanvas { - ul { + .sidebar ul { margin: 0px; } diff --git a/frappe/templates/generators/blog_post.html b/frappe/templates/generators/blog_post.html index 0a7e601eb1..f9ac7f95a2 100644 --- a/frappe/templates/generators/blog_post.html +++ b/frappe/templates/generators/blog_post.html @@ -11,7 +11,7 @@ , {{ updated }}

-
+
{{ content }}
diff --git a/frappe/templates/generators/web_form.html b/frappe/templates/generators/web_form.html index d306770fa3..076f53564f 100644 --- a/frappe/templates/generators/web_form.html +++ b/frappe/templates/generators/web_form.html @@ -5,10 +5,13 @@ {% endblock %} {% block content %} -{% if introduction_text %} -

{{ introduction_text }}

-
-{% endif %} + +
+ {% if introduction_text %} +

{{ introduction_text }}

+
+ {% endif %} +
{% if login_required and frappe.user=="Guest" %}
{{ _("Please login to create a new {0}").format(_(doc_type)) }} @@ -253,11 +256,11 @@ frappe.ready(function() { callback: function(data) { if(!data.exc) { $form.addClass("hide"); - $(".comments").addClass("hide"); + $(".comments, .introduction").addClass("hide"); scroll(0, 0); $(".form-message") - .html("{{ success_message or 'Thank You!' }}" - + '

Continue

') + .html('{{ success_message or __("Thank You") }}' + + '

{{ _("Continue") }}

') .removeClass("hide"); } window.saving = false; diff --git a/frappe/templates/includes/contact.js b/frappe/templates/includes/contact.js index 019ac69094..1d5adaceae 100644 --- a/frappe/templates/includes/contact.js +++ b/frappe/templates/includes/contact.js @@ -1,7 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // MIT License. See license.txt -$(document).ready(function() { +frappe.ready(function() { $('.btn-send').click(function() { var email = $('[name="email"]').val(); diff --git a/frappe/templates/pages/print.py b/frappe/templates/pages/print.py index d40708ff02..a446d3485c 100644 --- a/frappe/templates/pages/print.py +++ b/frappe/templates/pages/print.py @@ -56,7 +56,8 @@ def get_html(doc, name=None, print_format=None, meta=None, doc.flags.in_print = True - validate_print_permission(doc) + if not frappe.flags.ignore_print_permissions: + validate_print_permission(doc) if hasattr(doc, "before_print"): doc.before_print() diff --git a/frappe/utils/install.py b/frappe/utils/install.py index fb4d25ec17..b499e084a6 100644 --- a/frappe/utils/install.py +++ b/frappe/utils/install.py @@ -47,6 +47,10 @@ def after_install(): import_country_and_currency() + # save default print setting + print_settings = frappe.get_doc("Print Settings") + print_settings.save() + # all roles to admin frappe.get_doc("User", "Administrator").add_roles(*frappe.db.sql_list("""select name from tabRole""")) diff --git a/frappe/website/doctype/blog_post/blog_post.py b/frappe/website/doctype/blog_post/blog_post.py index 8e0b33bc2c..f033d74f2a 100644 --- a/frappe/website/doctype/blog_post/blog_post.py +++ b/frappe/website/doctype/blog_post/blog_post.py @@ -141,7 +141,7 @@ def get_blog_list(doctype, txt=None, filters=None, limit_start=0, limit_page_len ifnull(t1.blog_intro, t1.content) as content, t2.full_name, t2.avatar, t1.blogger, (select count(name) from `tabComment` where - comment_doctype='Blog Post' and comment_docname=t1.name) as comments + comment_doctype='Blog Post' and comment_docname=t1.name and comment_type="Comment") as comments from `tabBlog Post` t1, `tabBlogger` t2 where ifnull(t1.published,0)=1 and t1.blogger = t2.name diff --git a/frappe/website/doctype/contact_us_settings/contact_us_settings.json b/frappe/website/doctype/contact_us_settings/contact_us_settings.json index e3cdf1293c..0e2546de24 100644 --- a/frappe/website/doctype/contact_us_settings/contact_us_settings.json +++ b/frappe/website/doctype/contact_us_settings/contact_us_settings.json @@ -4,13 +4,6 @@ "docstatus": 0, "doctype": "DocType", "fields": [ - { - "fieldname": "help", - "fieldtype": "HTML", - "label": "Help", - "options": "
Link for Contact Page is \"/contact\"
", - "permlevel": 0 - }, { "fieldname": "introduction_section", "fieldtype": "Section Break", @@ -97,7 +90,7 @@ "icon": "icon-cog", "idx": 1, "issingle": 1, - "modified": "2015-02-05 05:11:36.090289", + "modified": "2015-03-11 18:08:13.531919", "modified_by": "Administrator", "module": "Website", "name": "Contact Us Settings",