Przeglądaj źródła

[rename] frappe.www.print to frappe.www.printview

version-14
Rushabh Mehta 8 lat temu
committed by Nabin Hait
rodzic
commit
62f0480117
12 zmienionych plików z 48 dodań i 30 usunięć
  1. +1
    -1
      frappe/__init__.py
  2. +19
    -18
      frappe/boot.py
  3. +11
    -0
      frappe/public/js/frappe/desk.js
  4. +1
    -1
      frappe/public/js/frappe/form/print.js
  5. +1
    -1
      frappe/public/js/frappe/misc/user.js
  6. +2
    -1
      frappe/utils/jinja.py
  7. +1
    -1
      frappe/utils/print_format.py
  8. +1
    -1
      frappe/website/doctype/blog_post/blog_post.py
  9. +1
    -1
      frappe/website/doctype/web_form/templates/web_form.html
  10. +7
    -2
      frappe/www/desk.py
  11. +0
    -0
      frappe/www/printview.html
  12. +3
    -3
      frappe/www/printview.py

+ 1
- 1
frappe/__init__.py Wyświetl plik

@@ -1204,7 +1204,7 @@ def get_print(doctype=None, name=None, print_format=None, style=None, html=None,
local.form_dict.doc = doc local.form_dict.doc = doc


if not html: if not html:
html = build_page("print")
html = build_page("printview")


if as_pdf: if as_pdf:
return get_pdf(html, output = output) return get_pdf(html, output = output)


+ 19
- 18
frappe/boot.py Wyświetl plik

@@ -103,35 +103,35 @@ def get_user_page_or_report(parent):


# get pages or reports set on custom role # get pages or reports set on custom role
custom_roles = frappe.db.sql(""" custom_roles = frappe.db.sql("""
select
`tabCustom Role`.{field} as name,
`tabCustom Role`.modified,
`tabCustom Role`.ref_doctype
from `tabCustom Role`, `tabHas Role`
select
`tabCustom Role`.{field} as name,
`tabCustom Role`.modified,
`tabCustom Role`.ref_doctype
from `tabCustom Role`, `tabHas Role`
where where
`tabHas Role`.parent = `tabCustom Role`.name
and `tabCustom Role`.{field} is not null
`tabHas Role`.parent = `tabCustom Role`.name
and `tabCustom Role`.{field} is not null
and `tabHas Role`.role in ({roles}) and `tabHas Role`.role in ({roles})
""".format(field=parent.lower(), roles = ', '.join(['%s']*len(roles))), roles, as_dict=1) """.format(field=parent.lower(), roles = ', '.join(['%s']*len(roles))), roles, as_dict=1)
for p in custom_roles: for p in custom_roles:
has_role[p.name] = {"modified":p.modified, "title": p.name, "ref_doctype": p.ref_doctype} has_role[p.name] = {"modified":p.modified, "title": p.name, "ref_doctype": p.ref_doctype}


standard_roles = frappe.db.sql(""" standard_roles = frappe.db.sql("""
select distinct select distinct
tab{parent}.name,
tab{parent}.modified,
tab{parent}.name,
tab{parent}.modified,
{column} {column}
from `tabHas Role`, `tab{parent}` from `tabHas Role`, `tab{parent}`
where
where
`tabHas Role`.role in ({roles}) `tabHas Role`.role in ({roles})
and `tabHas Role`.parent = `tab{parent}`.name
and `tabHas Role`.parent = `tab{parent}`.name
and tab{parent}.name not in ( and tab{parent}.name not in (
select `tabCustom Role`.{field} from `tabCustom Role`
select `tabCustom Role`.{field} from `tabCustom Role`
where `tabCustom Role`.{field} is not null) where `tabCustom Role`.{field} is not null)
""".format(parent=parent, column=column,
""".format(parent=parent, column=column,
roles = ', '.join(['%s']*len(roles)), field=parent.lower()), roles, as_dict=True) roles = ', '.join(['%s']*len(roles)), field=parent.lower()), roles, as_dict=True)
for p in standard_roles: for p in standard_roles:
if p.name not in has_role: if p.name not in has_role:
has_role[p.name] = {"modified":p.modified, "title": p.title} has_role[p.name] = {"modified":p.modified, "title": p.title}
@@ -148,11 +148,11 @@ def get_user_page_or_report(parent):
(select count(*) from `tabHas Role` (select count(*) from `tabHas Role`
where `tabHas Role`.parent=tab{parent}.name) = 0 where `tabHas Role`.parent=tab{parent}.name) = 0
""".format(parent=parent, column=column), as_dict=1) """.format(parent=parent, column=column), as_dict=1)
for p in pages_with_no_roles: for p in pages_with_no_roles:
if p.name not in has_role: if p.name not in has_role:
has_role[p.name] = {"modified": p.modified, "title": p.title} has_role[p.name] = {"modified": p.modified, "title": p.title}
elif parent == "Report": elif parent == "Report":
for report_name in has_role: for report_name in has_role:
has_role[report_name]["report_type"] = frappe.db.get_value("Report", report_name, "report_type") has_role[report_name]["report_type"] = frappe.db.get_value("Report", report_name, "report_type")
@@ -230,7 +230,8 @@ def load_print(bootinfo, doclist):
load_print_css(bootinfo, print_settings) load_print_css(bootinfo, print_settings)


def load_print_css(bootinfo, print_settings): def load_print_css(bootinfo, print_settings):
bootinfo.print_css = frappe.get_attr("frappe.www.print.get_print_style")(print_settings.print_style or "Modern", for_legacy=True)
import frappe.www.printview
bootinfo.print_css = frappe.www.printview.get_print_style(print_settings.print_style or "Modern", for_legacy=True)


def get_unseen_notes(): def get_unseen_notes():
return frappe.db.sql('''select name, title, content, notify_on_every_login from tabNote where notify_on_login=1 return frappe.db.sql('''select name, title, content, notify_on_every_login from tabNote where notify_on_login=1


+ 11
- 0
frappe/public/js/frappe/desk.js Wyświetl plik

@@ -31,6 +31,16 @@ frappe.Application = Class.extend({
startup: function() { startup: function() {
frappe.socket.init(); frappe.socket.init();
frappe.model.init(); frappe.model.init();

if(frappe.boot.status==='failed') {
frappe.msgprint({
message: frappe.boot.error,
title: __('Session Start Failed'),
indicator: 'red',
})
throw 'boot failed';
}

this.load_bootinfo(); this.load_bootinfo();
this.make_nav_bar(); this.make_nav_bar();
this.set_favicon(); this.set_favicon();
@@ -193,6 +203,7 @@ frappe.Application = Class.extend({
if(frappe.boot.print_css) { if(frappe.boot.print_css) {
frappe.dom.set_style(frappe.boot.print_css) frappe.dom.set_style(frappe.boot.print_css)
} }
frappe.user.name = frappe.boot.user.name;
} else { } else {
this.set_as_guest(); this.set_as_guest();
} }


+ 1
- 1
frappe/public/js/frappe/form/print.js Wyświetl plik

@@ -130,7 +130,7 @@ frappe.ui.form.PrintPreview = Class.extend({
}, },
new_page_preview: function(printit) { new_page_preview: function(printit) {
var me = this; var me = this;
var w = window.open(frappe.urllib.get_full_url("/print?"
var w = window.open(frappe.urllib.get_full_url("/printview?"
+"doctype="+encodeURIComponent(me.frm.doc.doctype) +"doctype="+encodeURIComponent(me.frm.doc.doctype)
+"&name="+encodeURIComponent(me.frm.doc.name) +"&name="+encodeURIComponent(me.frm.doc.name)
+(printit ? "&trigger_print=1" : "") +(printit ? "&trigger_print=1" : "")


+ 1
- 1
frappe/public/js/frappe/misc/user.js Wyświetl plik

@@ -55,7 +55,7 @@ frappe.ui.set_user_background = function(src, selector, style) {
frappe.provide('frappe.user'); frappe.provide('frappe.user');


$.extend(frappe.user, { $.extend(frappe.user, {
name: (frappe.boot ? frappe.boot.user.name : 'Guest'),
name: 'Guest',
full_name: function(uid) { full_name: function(uid) {
return uid===user ? return uid===user ?
__("You") : __("You") :


+ 2
- 1
frappe/utils/jinja.py Wyświetl plik

@@ -60,6 +60,7 @@ def get_allowed_functions_for_jenv():
from frappe.modules import scrub from frappe.modules import scrub
import mimetypes import mimetypes
from html2text import html2text from html2text import html2text
from frappe.www.printview import get_visible_columns


datautils = {} datautils = {}
if frappe.db: if frappe.db:
@@ -121,7 +122,7 @@ def get_allowed_functions_for_jenv():
} }


if not frappe.flags.in_setup_help: if not frappe.flags.in_setup_help:
out['get_visible_columns'] = frappe.get_attr("frappe.www.print.get_visible_columns")
out['get_visible_columns'] = get_visible_columns
out['frappe']['date_format'] = date_format out['frappe']['date_format'] = date_format
out['frappe']["db"] = { out['frappe']["db"] = {
"get_value": frappe.db.get_value, "get_value": frappe.db.get_value,


+ 1
- 1
frappe/utils/print_format.py Wyświetl plik

@@ -12,7 +12,7 @@ from pyPdf import PdfFileWriter, PdfFileReader
no_cache = 1 no_cache = 1
no_sitemap = 1 no_sitemap = 1


base_template_path = "templates/www/print.html"
base_template_path = "templates/www/printview.html"
standard_format = "templates/print_formats/standard.html" standard_format = "templates/print_formats/standard.html"


@frappe.whitelist() @frappe.whitelist()


+ 1
- 1
frappe/website/doctype/blog_post/blog_post.py Wyświetl plik

@@ -90,7 +90,7 @@ def get_list_context(context=None):
get_list = get_blog_list, get_list = get_blog_list,
hide_filters = True, hide_filters = True,
children = get_children(), children = get_children(),
show_search = True,
# show_search = True,
title = _('Blog') title = _('Blog')
) )




+ 1
- 1
frappe/website/doctype/web_form/templates/web_form.html Wyświetl plik

@@ -34,7 +34,7 @@
{% endif %} {% endif %}
{%- if allow_print and not is_list and not _login_required -%} {%- if allow_print and not is_list and not _login_required -%}
<div class='text-right'> <div class='text-right'>
<a class='text-muted small' href='/print?doctype={{ doc.doctype}}&name={{ doc.name }}
<a class='text-muted small' href='/printview?doctype={{ doc.doctype}}&name={{ doc.name }}
{%- if print_format -%}&format={{ print_format }}{%- endif -%}' target="_blank"> {%- if print_format -%}&format={{ print_format }}{%- endif -%}' target="_blank">
<i class='fa fa-print'></i> {{ _("Print") }}</a> <i class='fa fa-print'></i> {{ _("Print") }}</a>
</div> </div>


+ 7
- 2
frappe/www/desk.py Wyświetl plik

@@ -18,7 +18,11 @@ def get_context(context):
frappe.throw(_("You are not permitted to access this page."), frappe.PermissionError) frappe.throw(_("You are not permitted to access this page."), frappe.PermissionError)


hooks = frappe.get_hooks() hooks = frappe.get_hooks()
boot = frappe.sessions.get()
try:
boot = frappe.sessions.get()
except Exception as e:
boot = frappe._dict(status='failed', error = str(e))
print frappe.get_traceback()


# this needs commit # this needs commit
csrf_token = frappe.sessions.get_csrf_token() csrf_token = frappe.sessions.get_csrf_token()
@@ -37,7 +41,8 @@ def get_context(context):
"sounds": hooks["sounds"], "sounds": hooks["sounds"],
"boot": boot if context.get("for_mobile") else boot_json, "boot": boot if context.get("for_mobile") else boot_json,
"csrf_token": csrf_token, "csrf_token": csrf_token,
"background_image": boot.user.background_image or boot.default_background_image,
"background_image": (boot.status != 'failed' and
(boot.user.background_image or boot.default_background_image) or None),
"google_analytics_id": frappe.conf.get("google_analytics_id"), "google_analytics_id": frappe.conf.get("google_analytics_id"),
"mixpanel_id": frappe.conf.get("mixpanel_id") "mixpanel_id": frappe.conf.get("mixpanel_id")
} }


frappe/www/print.html → frappe/www/printview.html Wyświetl plik


frappe/www/print.py → frappe/www/printview.py Wyświetl plik

@@ -14,7 +14,7 @@ from markdown2 import markdown
no_cache = 1 no_cache = 1
no_sitemap = 1 no_sitemap = 1


base_template_path = "templates/www/print.html"
base_template_path = "templates/www/printview.html"
standard_format = "templates/print_formats/standard.html" standard_format = "templates/print_formats/standard.html"


def get_context(context): def get_context(context):
@@ -148,9 +148,9 @@ def get_html(doc, name=None, print_format=None, meta=None,
"footer": letter_head.footer, "footer": letter_head.footer,
"print_settings": frappe.get_doc("Print Settings") "print_settings": frappe.get_doc("Print Settings")
} }
html = template.render(args, filters={"len": len}) html = template.render(args, filters={"len": len})
if cint(trigger_print): if cint(trigger_print):
html += trigger_print_script html += trigger_print_script



Ładowanie…
Anuluj
Zapisz