From 19e9834850f52c461595b15c24dadc4f1752d927 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 17 Aug 2017 18:34:14 +0530 Subject: [PATCH] [added] print style --- frappe/app.py | 9 +- frappe/boot.py | 2 + .../desk/page/setup_wizard/setup_wizard.css | 9 +- frappe/modules/import_file.py | 3 +- frappe/modules/utils.py | 5 +- .../print_settings/print_settings.json | 6 +- .../print_settings/test_print_settings.js | 23 ++ .../printing/doctype/print_style/__init__.py | 0 .../doctype/print_style/print_style.js | 8 + .../doctype/print_style/print_style.json | 214 ++++++++++++++++++ .../doctype/print_style/print_style.py | 23 ++ .../doctype/print_style/test_print_style.js | 23 ++ .../doctype/print_style/test_print_style.py | 10 + frappe/printing/print_style/__init__.py | 0 .../printing/print_style/classic/__init__.py | 0 .../printing/print_style/classic/classic.json | 14 ++ .../printing/print_style/modern/__init__.py | 0 .../printing/print_style/modern/modern.json | 14 ++ .../print_style/monochrome/__init__.py | 0 .../print_style/monochrome/monochrome.json | 14 ++ frappe/public/css/form.css | 9 +- frappe/public/js/frappe/dom.js | 1 + frappe/public/js/frappe/form/print.js | 23 +- .../frappe/form/templates/print_layout.html | 4 +- frappe/public/less/form.less | 9 +- frappe/templates/styles/classic.css | 16 -- frappe/templates/styles/modern.css | 19 -- frappe/templates/styles/monochrome.css | 26 --- frappe/website/render.py | 3 +- frappe/www/404.html | 12 + frappe/www/printview.py | 13 +- 31 files changed, 420 insertions(+), 92 deletions(-) create mode 100644 frappe/printing/doctype/print_settings/test_print_settings.js create mode 100644 frappe/printing/doctype/print_style/__init__.py create mode 100644 frappe/printing/doctype/print_style/print_style.js create mode 100644 frappe/printing/doctype/print_style/print_style.json create mode 100644 frappe/printing/doctype/print_style/print_style.py create mode 100644 frappe/printing/doctype/print_style/test_print_style.js create mode 100644 frappe/printing/doctype/print_style/test_print_style.py create mode 100644 frappe/printing/print_style/__init__.py create mode 100644 frappe/printing/print_style/classic/__init__.py create mode 100644 frappe/printing/print_style/classic/classic.json create mode 100644 frappe/printing/print_style/modern/__init__.py create mode 100644 frappe/printing/print_style/modern/modern.json create mode 100644 frappe/printing/print_style/monochrome/__init__.py create mode 100644 frappe/printing/print_style/monochrome/monochrome.json delete mode 100644 frappe/templates/styles/classic.css delete mode 100644 frappe/templates/styles/modern.css delete mode 100644 frappe/templates/styles/monochrome.css diff --git a/frappe/app.py b/frappe/app.py index 84df9e7a0b..2cd714fa9f 100644 --- a/frappe/app.py +++ b/frappe/app.py @@ -150,13 +150,13 @@ def handle_exception(e): elif http_status_code==403: frappe.respond_as_web_page(_("Not Permitted"), _("You do not have enough permissions to complete the action"), - http_status_code=http_status_code, indicator_color='red') + http_status_code=http_status_code, indicator_color='red', fullpage=True) return_as_message = True elif http_status_code==404: frappe.respond_as_web_page(_("Not Found"), _("The resource you are looking for is not available"), - http_status_code=http_status_code, indicator_color='red') + http_status_code=http_status_code, indicator_color='red', fullpage=True) return_as_message = True else: @@ -166,7 +166,7 @@ def handle_exception(e): frappe.respond_as_web_page("Server Error", traceback, http_status_code=http_status_code, - indicator_color='red') + indicator_color='red', fullpage=True) return_as_message = True if e.__class__ == frappe.AuthenticationError: @@ -178,7 +178,8 @@ def handle_exception(e): make_error_snapshot(e) if return_as_message: - response = frappe.website.render.render("message", http_status_code=http_status_code) + response = frappe.website.render.render("message", + http_status_code=http_status_code, fullpage=True) return response diff --git a/frappe/boot.py b/frappe/boot.py index 5d042f82ce..0f4039c596 100644 --- a/frappe/boot.py +++ b/frappe/boot.py @@ -236,6 +236,8 @@ def load_print(bootinfo, doclist): print_settings.doctype = ":Print Settings" doclist.append(print_settings) load_print_css(bootinfo, print_settings) + doclist.extend(frappe.get_all('Print Style', 'name', + dict(disabled=0), update=dict(doctype=':Print Style'))) def load_print_css(bootinfo, print_settings): import frappe.www.printview diff --git a/frappe/desk/page/setup_wizard/setup_wizard.css b/frappe/desk/page/setup_wizard/setup_wizard.css index 5313a6b4bc..f61ea87863 100644 --- a/frappe/desk/page/setup_wizard/setup_wizard.css +++ b/frappe/desk/page/setup_wizard/setup_wizard.css @@ -8,13 +8,9 @@ } @media (min-width: 768px) { - .setup-wizard-slide.single-column { + .setup-wizard-slide { max-width: 500px; } - - .setup-wizard-slide.two-column { - max-width: 768px; - } } .setup-wizard-slide .lead { @@ -45,7 +41,7 @@ } .setup-wizard-slide.with-form { - margin: 30px auto; + margin: 60px auto; padding: 10px 50px; border: 1px solid #d1d8dd; box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.1); @@ -145,7 +141,6 @@ cursor: pointer; } - .setup-wizard-message-image { margin: 15px auto; } diff --git a/frappe/modules/import_file.py b/frappe/modules/import_file.py index 9a2c080d9b..ade3614c8e 100644 --- a/frappe/modules/import_file.py +++ b/frappe/modules/import_file.py @@ -87,7 +87,8 @@ def read_doc_from_file(path): ignore_values = { "Report": ["disabled"], "Print Format": ["disabled"], - "Email Alert": ["enabled"] + "Email Alert": ["enabled"], + "Print Style": ["disabled"] } ignore_doctypes = [""] diff --git a/frappe/modules/utils.py b/frappe/modules/utils.py index 79933a60a5..9e43a28c6f 100644 --- a/frappe/modules/utils.py +++ b/frappe/modules/utils.py @@ -10,8 +10,9 @@ import frappe.utils from frappe import _ lower_case_files_for = ['DocType', 'Page', 'Report', - "Workflow", 'Module Def', 'Desktop Item', 'Workflow State', 'Workflow Action', 'Print Format', - "Website Theme", 'Web Form', 'Email Alert'] + "Workflow", 'Module Def', 'Desktop Item', 'Workflow State', + 'Workflow Action', 'Print Format', "Website Theme", 'Web Form', + 'Email Alert', 'Print Style'] def export_module_json(doc, is_standard, module): """Make a folder for the given doc and add its json file (make it a standard diff --git a/frappe/printing/doctype/print_settings/print_settings.json b/frappe/printing/doctype/print_settings/print_settings.json index b191ac663a..40bf15d18b 100644 --- a/frappe/printing/doctype/print_settings/print_settings.json +++ b/frappe/printing/doctype/print_settings/print_settings.json @@ -260,7 +260,7 @@ "columns": 0, "default": "Modern", "fieldname": "print_style", - "fieldtype": "Select", + "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -271,7 +271,7 @@ "label": "Print Style", "length": 0, "no_copy": 0, - "options": "Modern\nClassic\nStandard\nMonochrome", + "options": "Print Style", "permlevel": 0, "print_hide": 0, "print_hide_if_no_value": 0, @@ -597,7 +597,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2017-05-03 05:58:55.562540", + "modified": "2017-08-17 02:15:55.025352", "modified_by": "Administrator", "module": "Printing", "name": "Print Settings", diff --git a/frappe/printing/doctype/print_settings/test_print_settings.js b/frappe/printing/doctype/print_settings/test_print_settings.js new file mode 100644 index 0000000000..af61095e97 --- /dev/null +++ b/frappe/printing/doctype/print_settings/test_print_settings.js @@ -0,0 +1,23 @@ +/* eslint-disable */ +// rename this file from _test_[name] to test_[name] to activate +// and remove above this line + +QUnit.test("test: Print Settings", function (assert) { + let done = assert.async(); + + // number of asserts + assert.expect(1); + + frappe.run_serially([ + // insert a new Print Settings + () => frappe.tests.make('Print Settings', [ + // values to be set + {key: 'value'} + ]), + () => { + assert.equal(cur_frm.doc.key, 'value'); + }, + () => done() + ]); + +}); diff --git a/frappe/printing/doctype/print_style/__init__.py b/frappe/printing/doctype/print_style/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/printing/doctype/print_style/print_style.js b/frappe/printing/doctype/print_style/print_style.js new file mode 100644 index 0000000000..3b50ba3038 --- /dev/null +++ b/frappe/printing/doctype/print_style/print_style.js @@ -0,0 +1,8 @@ +// Copyright (c) 2017, Frappe Technologies and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Print Style', { + refresh: function(frm) { + + } +}); diff --git a/frappe/printing/doctype/print_style/print_style.json b/frappe/printing/doctype/print_style/print_style.json new file mode 100644 index 0000000000..29e88a460a --- /dev/null +++ b/frappe/printing/doctype/print_style/print_style.json @@ -0,0 +1,214 @@ +{ + "allow_copy": 0, + "allow_guest_to_view": 0, + "allow_import": 0, + "allow_rename": 1, + "autoname": "field:print_style_name", + "beta": 0, + "creation": "2017-08-17 01:25:56.910716", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "editable_grid": 1, + "engine": "InnoDB", + "fields": [ + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "print_style_name", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Print Style Name", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "disabled", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Disabled", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "standard", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Standard", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "css", + "fieldtype": "Code", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "CSS", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "preview", + "fieldtype": "Attach Image", + "hidden": 1, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Preview", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + } + ], + "has_web_view": 0, + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_field": "preview", + "image_view": 0, + "in_create": 0, + "is_submittable": 0, + "issingle": 0, + "istable": 0, + "max_attachments": 0, + "modified": "2017-08-17 02:18:08.132853", + "modified_by": "Administrator", + "module": "Printing", + "name": "Print Style", + "name_case": "", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "set_user_permissions": 0, + "share": 1, + "submit": 0, + "write": 1 + } + ], + "quick_entry": 0, + "read_only": 0, + "read_only_onload": 0, + "show_name_in_global_search": 0, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1, + "track_seen": 0 +} \ No newline at end of file diff --git a/frappe/printing/doctype/print_style/print_style.py b/frappe/printing/doctype/print_style/print_style.py new file mode 100644 index 0000000000..310babd5df --- /dev/null +++ b/frappe/printing/doctype/print_style/print_style.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2017, Frappe Technologies and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class PrintStyle(Document): + def validate(self): + if (self.standard==1 + and not frappe.local.conf.get("developer_mode") + and not (frappe.flags.in_import or frappe.flags.in_test)): + + frappe.throw(frappe._("Standard Print Style cannot be changed. Please duplicate to edit.")) + + def on_update(self): + self.export_doc() + + def export_doc(self): + # export + from frappe.modules.utils import export_module_json + export_module_json(self, self.standard == 1, 'Printing') diff --git a/frappe/printing/doctype/print_style/test_print_style.js b/frappe/printing/doctype/print_style/test_print_style.js new file mode 100644 index 0000000000..4fceaad65d --- /dev/null +++ b/frappe/printing/doctype/print_style/test_print_style.js @@ -0,0 +1,23 @@ +/* eslint-disable */ +// rename this file from _test_[name] to test_[name] to activate +// and remove above this line + +QUnit.test("test: Print Style", function (assert) { + let done = assert.async(); + + // number of asserts + assert.expect(1); + + frappe.run_serially([ + // insert a new Print Style + () => frappe.tests.make('Print Style', [ + // values to be set + {key: 'value'} + ]), + () => { + assert.equal(cur_frm.doc.key, 'value'); + }, + () => done() + ]); + +}); diff --git a/frappe/printing/doctype/print_style/test_print_style.py b/frappe/printing/doctype/print_style/test_print_style.py new file mode 100644 index 0000000000..cee57f8826 --- /dev/null +++ b/frappe/printing/doctype/print_style/test_print_style.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2017, Frappe Technologies and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +class TestPrintStyle(unittest.TestCase): + pass diff --git a/frappe/printing/print_style/__init__.py b/frappe/printing/print_style/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/printing/print_style/classic/__init__.py b/frappe/printing/print_style/classic/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/printing/print_style/classic/classic.json b/frappe/printing/print_style/classic/classic.json new file mode 100644 index 0000000000..149bf6dc09 --- /dev/null +++ b/frappe/printing/print_style/classic/classic.json @@ -0,0 +1,14 @@ +{ + "creation": "2017-08-17 02:00:12.502887", + "css": "/*\n\tcommon style for whole page\n\tThis should include:\n\t+ page size related settings\n\t+ font family settings\n\t+ line spacing settings\n*/\n.print-format div,\n.print-format span,\n.print-format td,\n.print-format h1,\n.print-format h2,\n.print-format h3,\n.print-format h4 {\n\tfont-family: Georgia, serif;\n}\n", + "disabled": 0, + "docstatus": 0, + "doctype": "Print Style", + "idx": 1, + "modified": "2017-08-17 05:02:24.128436", + "modified_by": "Administrator", + "name": "Classic", + "owner": "Administrator", + "print_style_name": "Classic", + "standard": 1 +} \ No newline at end of file diff --git a/frappe/printing/print_style/modern/__init__.py b/frappe/printing/print_style/modern/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/printing/print_style/modern/modern.json b/frappe/printing/print_style/modern/modern.json new file mode 100644 index 0000000000..15822e6c2d --- /dev/null +++ b/frappe/printing/print_style/modern/modern.json @@ -0,0 +1,14 @@ +{ + "creation": "2017-08-17 02:16:58.060374", + "css": ".print-heading {\n\ttext-align: right;\n\ttext-transform: uppercase;\n\tcolor: #666;\n\tpadding-bottom: 20px;\n\tmargin-bottom: 20px;\n\tborder-bottom: 1px solid #d1d8dd;\n}\n\n.print-heading h2 {\n\tfont-size: 24px;\n}\n\n.print-format th {\n\tbackground-color: #eee !important;\n\tborder-bottom: 0px !important;\n}\n\n/* modern format: don't remove this line */", + "disabled": 0, + "docstatus": 0, + "doctype": "Print Style", + "idx": 0, + "modified": "2017-08-17 05:02:05.043839", + "modified_by": "Administrator", + "name": "Modern", + "owner": "Administrator", + "print_style_name": "Modern", + "standard": 1 +} \ No newline at end of file diff --git a/frappe/printing/print_style/monochrome/__init__.py b/frappe/printing/print_style/monochrome/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/printing/print_style/monochrome/monochrome.json b/frappe/printing/print_style/monochrome/monochrome.json new file mode 100644 index 0000000000..4e4c1b393e --- /dev/null +++ b/frappe/printing/print_style/monochrome/monochrome.json @@ -0,0 +1,14 @@ +{ + "creation": "2017-08-17 02:16:20.992989", + "css": ".print-format * {\n\tcolor: #000 !important;\n}\n\n.print-format .alert {\n\tbackground-color: inherit;\n\tborder: 1px dashed #333;\n}\n\n.print-format .table-bordered,\n.print-format .table-bordered > thead > tr > th,\n.print-format .table-bordered > tbody > tr > th,\n.print-format .table-bordered > tfoot > tr > th,\n.print-format .table-bordered > thead > tr > td,\n.print-format .table-bordered > tbody > tr > td,\n.print-format .table-bordered > tfoot > tr > td {\n\tborder: 1px solid #333;\n}\n\n.print-format hr {\n\tborder-top: 1px solid #333;\n}\n\n.print-heading {\n\tborder-bottom: 2px solid #333;\n}\n", + "disabled": 0, + "docstatus": 0, + "doctype": "Print Style", + "idx": 0, + "modified": "2017-08-17 05:02:14.874082", + "modified_by": "Administrator", + "name": "Monochrome", + "owner": "Administrator", + "print_style_name": "Monochrome", + "standard": 1 +} \ No newline at end of file diff --git a/frappe/public/css/form.css b/frappe/public/css/form.css index 00674934af..453266c2e0 100644 --- a/frappe/public/css/form.css +++ b/frappe/public/css/form.css @@ -11,6 +11,12 @@ padding: 10px 0px; border-bottom: 1px solid #d1d8dd; } +.print-toolbar > div { + padding-right: 0px; +} +.print-toolbar > div:last-child { + padding-right: 15px; +} .form-inner-toolbar { padding: 10px 15px 0px; background-color: #fafbfc; @@ -588,7 +594,8 @@ select.form-control { .password-strength-message { margin-top: -10px; } -.control-code { +.control-code, +.control-code.bold { height: 400px; font-family: Monaco, "Courier New", monospace; background-color: black; diff --git a/frappe/public/js/frappe/dom.js b/frappe/public/js/frappe/dom.js index f3727ae16f..0a3890df29 100644 --- a/frappe/public/js/frappe/dom.js +++ b/frappe/public/js/frappe/dom.js @@ -93,6 +93,7 @@ frappe.dom = { se.appendChild(document.createTextNode(txt)); } document.getElementsByTagName('head')[0].appendChild(se); + return se; }, add: function(parent, newtag, className, cs, innerHTML, onclick) { if(parent && parent.substr)parent = frappe.dom.by_id(parent); diff --git a/frappe/public/js/frappe/form/print.js b/frappe/public/js/frappe/form/print.js index cc99eae370..c7b82482f0 100644 --- a/frappe/public/js/frappe/form/print.js +++ b/frappe/public/js/frappe/form/print.js @@ -35,7 +35,13 @@ frappe.ui.form.PrintPreview = Class.extend({ this.print_sel = this.wrapper .find(".print-preview-select") .on("change", function () { - me.multilingual_preview() + me.multilingual_preview(); + }); + + this.print_style_select = this.wrapper + .find('.print-style-select') + .on("change", function () { + me.multilingual_preview(); }); //On selection of language get code and pass it to preview method @@ -64,11 +70,13 @@ frappe.ui.form.PrintPreview = Class.extend({ this.wrapper.find(".btn-download-pdf").click(function () { if (!me.is_old_style()) { + let print_style = me.selected_style(); var w = window.open( frappe.urllib.get_full_url("/api/method/frappe.utils.print_format.download_pdf?" + "doctype=" + encodeURIComponent(me.frm.doc.doctype) + "&name=" + encodeURIComponent(me.frm.doc.name) + "&format=" + me.selected_format() + + (print_style ? '&style=' + print_style : '') + "&no_letterhead=" + (me.with_letterhead() ? "0" : "1") + (me.lang_code ? ("&_lang=" + me.lang_code) : "")) ); @@ -79,7 +87,7 @@ frappe.ui.form.PrintPreview = Class.extend({ }); this.wrapper.find(".btn-print-edit").on("click", function () { - var print_format = me.get_print_format(); + let print_format = me.get_print_format(); if (print_format && print_format.name) { if (print_format.print_format_builder) { frappe.set_route("print-format-builder", print_format.name); @@ -147,11 +155,13 @@ frappe.ui.form.PrintPreview = Class.extend({ }, new_page_preview: function (printit) { var me = this; + let print_style = me.selected_style(); var w = window.open(frappe.urllib.get_full_url("/printview?" + "doctype=" + encodeURIComponent(me.frm.doc.doctype) + "&name=" + encodeURIComponent(me.frm.doc.name) + (printit ? "&trigger_print=1" : "") + "&format=" + me.selected_format() + + (print_style ? '&style=' + print_style : '') + "&no_letterhead=" + (me.with_letterhead() ? "0" : "1") + (me.lang_code ? ("&_lang=" + me.lang_code) : ""))); if (!w) { @@ -164,6 +174,7 @@ frappe.ui.form.PrintPreview = Class.extend({ args: { doc: this.frm.doc, print_format: this.selected_format(), + style: this.selected_style(), no_letterhead: !this.with_letterhead() ? 1 : 0, _lang: this.lang_code }, @@ -191,8 +202,11 @@ frappe.ui.form.PrintPreview = Class.extend({ }, refresh_print_options: function () { this.print_formats = frappe.meta.get_print_formats(this.frm.doctype); + this.print_style_select.empty() + .add_options([''].concat(Object.keys(locals[':Print Style'] || {}).sort())); return this.print_sel .empty().add_options(this.print_formats); + }, with_old_style: function (opts) { frappe.require("/assets/js/print_format_v3.min.js", function () { @@ -215,6 +229,9 @@ frappe.ui.form.PrintPreview = Class.extend({ selected_format: function () { return this.print_sel.val() || this.frm.meta.default_print_format || "Standard"; }, + selected_style: function () { + return this.print_style_select.val() || ''; + }, is_old_style: function (format) { return this.get_print_format(format).print_format_type === "Client"; }, @@ -233,6 +250,8 @@ frappe.ui.form.PrintPreview = Class.extend({ return this.print_letterhead.is(":checked") ? 1 : 0; }, set_style: function (style) { + $('#print-style').remove(); + console.log(style || frappe.boot.print_css); frappe.dom.set_style(style || frappe.boot.print_css, "print-style"); } }); diff --git a/frappe/public/js/frappe/form/templates/print_layout.html b/frappe/public/js/frappe/form/templates/print_layout.html index eac092f390..e5f25261ef 100644 --- a/frappe/public/js/frappe/form/templates/print_layout.html +++ b/frappe/public/js/frappe/form/templates/print_layout.html @@ -2,6 +2,8 @@ -
+
diff --git a/frappe/public/less/form.less b/frappe/public/less/form.less index e9c80cb84c..086527a605 100644 --- a/frappe/public/less/form.less +++ b/frappe/public/less/form.less @@ -14,6 +14,13 @@ margin: 0px; padding: 10px 0px; border-bottom: 1px solid @border-color; + + > div { + padding-right: 0px; + } + > div:last-child { + padding-right: 15px; + } } .form-inner-toolbar { @@ -735,7 +742,7 @@ select.form-control { margin-top: -10px; } -.control-code { +.control-code, .control-code.bold { height: 400px; font-family: Monaco, "Courier New", monospace; background-color: black; diff --git a/frappe/templates/styles/classic.css b/frappe/templates/styles/classic.css deleted file mode 100644 index b35e1044fd..0000000000 --- a/frappe/templates/styles/classic.css +++ /dev/null @@ -1,16 +0,0 @@ -/* - common style for whole page - This should include: - + page size related settings - + font family settings - + line spacing settings -*/ -.print-format div, -.print-format span, -.print-format td, -.print-format h1, -.print-format h2, -.print-format h3, -.print-format h4 { - font-family: serif; -} diff --git a/frappe/templates/styles/modern.css b/frappe/templates/styles/modern.css deleted file mode 100644 index 72b8c0cd71..0000000000 --- a/frappe/templates/styles/modern.css +++ /dev/null @@ -1,19 +0,0 @@ -.print-heading { - text-align: right; - text-transform: uppercase; - color: #666; - padding-bottom: 20px; - margin-bottom: 20px; - border-bottom: 1px solid #d1d8dd; -} - -.print-heading h2 { - font-size: 24px; -} - -.print-format th { - background-color: #eee !important; - border-bottom: 0px !important; -} - -/* modern format: don't remove this line */ \ No newline at end of file diff --git a/frappe/templates/styles/monochrome.css b/frappe/templates/styles/monochrome.css deleted file mode 100644 index 0e68c34e29..0000000000 --- a/frappe/templates/styles/monochrome.css +++ /dev/null @@ -1,26 +0,0 @@ -.print-format * { - color: #000 !important; -} - -.print-format .alert { - background-color: inherit; - border: 1px dashed #333; -} - -.print-format .table-bordered, -.print-format .table-bordered > thead > tr > th, -.print-format .table-bordered > tbody > tr > th, -.print-format .table-bordered > tfoot > tr > th, -.print-format .table-bordered > thead > tr > td, -.print-format .table-bordered > tbody > tr > td, -.print-format .table-bordered > tfoot > tr > td { - border: 1px solid #333; -} - -.print-format hr { - border-top: 1px solid #333; -} - -.print-heading { - border-bottom: 2px solid #333; -} diff --git a/frappe/website/render.py b/frappe/website/render.py index 8892d403a4..33e82efd18 100644 --- a/frappe/website/render.py +++ b/frappe/website/render.py @@ -279,7 +279,8 @@ def render_403(e, pathname): frappe.local.response['context'] = dict( indicator_color = 'red', primary_action = '/login', - primary_label = _('Login') + primary_label = _('Login'), + fullpage=True ) return render_page("message"), e.http_status_code diff --git a/frappe/www/404.html b/frappe/www/404.html index 0759721ae8..a57bc8ebb8 100644 --- a/frappe/www/404.html +++ b/frappe/www/404.html @@ -3,6 +3,18 @@ {%- block title -%}{{_("Not Found")}}{%- endblock -%} {% block page_content %} + +
{{_("Page Missing or Moved")}} diff --git a/frappe/www/printview.py b/frappe/www/printview.py index 1ed4ee3782..0c20bb0c25 100644 --- a/frappe/www/printview.py +++ b/frappe/www/printview.py @@ -7,7 +7,6 @@ import frappe, os, copy, json, re from frappe import _ from frappe.modules import get_doc_path -from jinja2 import TemplateNotFound from frappe.utils import cint, strip_html from markdown2 import markdown from six import string_types @@ -173,7 +172,7 @@ def convert_markdown(doc, meta): @frappe.whitelist() def get_html_and_style(doc, name=None, print_format=None, meta=None, - no_letterhead=None, trigger_print=False): + no_letterhead=None, trigger_print=False, style=None): """Returns `html` and `style` of print format, used in PDF etc""" if isinstance(doc, string_types) and isinstance(name, string_types): @@ -186,7 +185,7 @@ def get_html_and_style(doc, name=None, print_format=None, meta=None, return { "html": get_html(doc, name=name, print_format=print_format, meta=meta, no_letterhead=no_letterhead, trigger_print=trigger_print), - "style": get_print_style(print_format=print_format) + "style": get_print_style(style=style, print_format=print_format) } def validate_print_permission(doc): @@ -349,7 +348,7 @@ def get_print_style(style=None, print_format=None, for_legacy=False): print_settings = frappe.get_doc("Print Settings") if not style: - style = print_settings.print_style or "Standard" + style = print_settings.print_style or '' context = { "print_settings": print_settings, @@ -359,10 +358,8 @@ def get_print_style(style=None, print_format=None, for_legacy=False): css = frappe.get_template("templates/styles/standard.css").render(context) - try: - css += frappe.get_template("templates/styles/" + style.lower() + ".css").render(context) - except TemplateNotFound: - pass + if style and frappe.db.exists('Print Style', style): + css = css + '\n' + frappe.db.get_value('Print Style', style, 'css') # move @import to top for at_import in list(set(re.findall("(@import url\([^\)]+\)[;]?)", css))):